diff --git a/gno.land/pkg/sdk/vm/keeper.go b/gno.land/pkg/sdk/vm/keeper.go index eac14036bfa..da7230b655d 100644 --- a/gno.land/pkg/sdk/vm/keeper.go +++ b/gno.land/pkg/sdk/vm/keeper.go @@ -95,7 +95,7 @@ func (vm *VMKeeper) Initialize( baseStore := ms.GetStore(vm.baseKey) iavlStore := ms.GetStore(vm.iavlKey) - alloc := gno.NewAllocator(maxAllocTx, 10000, gno.NewHeap()) + alloc := gno.NewAllocator(maxAllocTx, gno.NewHeap()) vm.gnoStore = gno.NewStore(alloc, baseStore, iavlStore) vm.gnoStore.SetNativeStore(stdlibs.NativeStore) @@ -698,7 +698,7 @@ func (vm *VMKeeper) QueryFuncs(ctx sdk.Context, pkgPath string) (fsigs FunctionS // TODO: modify query protocol to allow MsgEval. // TODO: then, rename to "Eval". func (vm *VMKeeper) QueryEval(ctx sdk.Context, pkgPath string, expr string) (res string, err error) { - alloc := gno.NewAllocator(maxAllocQuery, 10000, gno.NewHeap()) + alloc := gno.NewAllocator(maxAllocQuery, gno.NewHeap()) gnostore := vm.newGnoTransactionStore(ctx) // throwaway (never committed) pkgAddr := gno.DerivePkgAddr(pkgPath) // Get Package. @@ -765,7 +765,7 @@ func (vm *VMKeeper) QueryEval(ctx sdk.Context, pkgPath string, expr string) (res // TODO: modify query protocol to allow MsgEval. // TODO: then, rename to "EvalString". func (vm *VMKeeper) QueryEvalString(ctx sdk.Context, pkgPath string, expr string) (res string, err error) { - alloc := gno.NewAllocator(maxAllocQuery, 10000, gno.NewHeap()) + alloc := gno.NewAllocator(maxAllocQuery, gno.NewHeap()) gnostore := vm.newGnoTransactionStore(ctx) // throwaway (never committed) pkgAddr := gno.DerivePkgAddr(pkgPath) // Get Package. diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index e3c14fb8991..da4b88f6b18 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -292,7 +292,7 @@ func gnoTestPkg( // XXX: make maxAllocTx configurable. maxAllocTx := int64(50 * 1000 * 1000) - m.Alloc = gno.NewAllocator(maxAllocTx, 10000, gno.NewHeap()) + m.Alloc = gno.NewAllocator(maxAllocTx, gno.NewHeap()) } m.RunMemPackage(memPkg, true) err := runTestFiles(m, tfiles, memPkg.Name, verbose, printRuntimeMetrics, runFlag, io) diff --git a/gnovm/pkg/gnolang/alloc.go b/gnovm/pkg/gnolang/alloc.go index 2ec4e9343bd..eb56da62d12 100644 --- a/gnovm/pkg/gnolang/alloc.go +++ b/gnovm/pkg/gnolang/alloc.go @@ -9,12 +9,10 @@ import ( // (optionally?) condensed (objects to be GC'd will be discarded), // but for now, allocations strictly increment across the whole tx. type Allocator struct { - maxBytes int64 - bytes int64 - lastGcRun int64 - minGcRun int64 - heap *Heap - detonate bool + maxBytes int64 + bytes int64 + heap *Heap + detonate bool } // for gonative, which doesn't consider the allocator. @@ -71,14 +69,13 @@ const ( allocHeapItem = _allocBase + _allocPointer + _allocTypedValue ) -func NewAllocator(maxBytes int64, minGcRun int64, heap *Heap) *Allocator { +func NewAllocator(maxBytes int64, heap *Heap) *Allocator { if maxBytes == 0 { return nil } return &Allocator{ maxBytes: maxBytes, heap: heap, - minGcRun: minGcRun, } } @@ -123,17 +120,9 @@ func (alloc *Allocator) Allocate(size int64) { } alloc.detonate = alloc.bytes > alloc.maxBytes } - } else if alloc.ShouldRunGC() { - alloc.lastGcRun = alloc.bytes - deleted := alloc.heap.MarkAndSweep() - alloc.DeallocDeleted(deleted) } } -func (alloc *Allocator) ShouldRunGC() bool { - return false // return alloc.bytes >= 2*alloc.lastGcRun && alloc.bytes >= alloc.minGcRun -} - func (alloc *Allocator) DeallocDeleted(objs []*GcObj) { for _, obj := range objs { alloc.DeallocObj(obj.tv) diff --git a/gnovm/pkg/gnolang/gno_test.go b/gnovm/pkg/gnolang/gno_test.go index ceb20df8411..8becc41c9e0 100644 --- a/gnovm/pkg/gnolang/gno_test.go +++ b/gnovm/pkg/gnolang/gno_test.go @@ -162,7 +162,7 @@ func foo(b int) *Foo { ` n := MustParseFile("main.go", c) m.RunFiles(n) - m.Alloc = NewAllocator(22000, 3000, NewHeap()) + m.Alloc = NewAllocator(22000, NewHeap()) m.RunMain() } diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index da711ce4ea4..844b88fad1f 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -146,7 +146,7 @@ func NewMachineWithOptions(opts MachineOptions) *Machine { } alloc := opts.Alloc if alloc == nil { - alloc = NewAllocator(opts.MaxAllocBytes, 10000, NewHeap()) + alloc = NewAllocator(opts.MaxAllocBytes, NewHeap()) } store := opts.Store if store == nil {