From 6a7301153322a93d48d022af404fb00a31de48be Mon Sep 17 00:00:00 2001 From: pdrobnjak Date: Fri, 6 Feb 2026 12:21:58 +0100 Subject: [PATCH] perf(store): remove dead sortedStore field from VersionIndexedStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sortedStore *dbm.MemDB field in VersionIndexedStore was allocated in the constructor (NewVersionIndexedStore) but never read or written anywhere in the codebase. Each VIS instance allocated a full MemDB with btree + FreeList — ~21 VIS per transaction × ~200K txs in 30s = ~4.2M dead MemDB allocations. Remove the field and its allocation entirely. Results (M4 Max benchmark, diff vs previous): - NewMemDB via VIS: 14.9 GB → 13.5 MB (eliminated) - btree.NewFreeListG: 15.3 GB → ~4.3 GB (-11 GB) - memclrNoHeapPointers CPU: 10.71s → 5.45s (-49%) - TPS: 7,200-8,600 → 8,400-9,400 (median ~8,000 → ~9,000) Co-Authored-By: Claude Opus 4.6 --- sei-cosmos/store/multiversion/mvkv.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sei-cosmos/store/multiversion/mvkv.go b/sei-cosmos/store/multiversion/mvkv.go index 6ac62068b9..2d0d423138 100644 --- a/sei-cosmos/store/multiversion/mvkv.go +++ b/sei-cosmos/store/multiversion/mvkv.go @@ -82,9 +82,6 @@ type VersionIndexedStore struct { iterateset Iterateset // TODO: need to add iterateset here as well - // used for iterators - populated at the time of iterator instantiation - // TODO: when we want to perform iteration, we need to move all the dirty keys (writeset and readset) into the sortedTree and then combine with the iterators for the underlying stores - sortedStore *dbm.MemDB // always ascending sorted // parent stores (both multiversion and underlying parent store) multiVersionStore MultiVersionStore parent types.KVStore @@ -104,7 +101,6 @@ func NewVersionIndexedStore(parent types.KVStore, multiVersionStore MultiVersion readset: make(map[string][][]byte), writeset: make(map[string][]byte), iterateset: []*iterationTracker{}, - sortedStore: dbm.NewMemDB(), parent: parent, multiVersionStore: multiVersionStore, transactionIndex: transactionIndex,