Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sei-cosmos/store/multiversion/mvkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,14 @@ func (store *VersionIndexedStore) WriteToMultiVersionStore() {
// defer store.mtx.Unlock()
// defer telemetry.MeasureSince(time.Now(), "store", "mvkv", "write_mvs")
store.multiVersionStore.SetWriteset(store.transactionIndex, store.incarnation, store.writeset)
store.multiVersionStore.SetReadset(store.transactionIndex, store.readset)
// Swap readset with the slot's old one — avoids clone allocation.
// The old readset (if any) has stale data; Reset will clear it.
old := store.multiVersionStore.SetReadset(store.transactionIndex, store.readset)
if old != nil {
store.readset = old
} else {
store.readset = make(ReadSet)
}
store.multiVersionStore.SetIterateset(store.transactionIndex, store.iterateset)
}

Expand Down
16 changes: 8 additions & 8 deletions sei-cosmos/store/multiversion/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type MultiVersionStore interface {
SetEstimatedWriteset(index int, incarnation int, writeset WriteSet)
GetAllWritesetKeys() map[int][]string
CollectIteratorItems(index int) *db.MemDB
SetReadset(index int, readset ReadSet)
SetReadset(index int, readset ReadSet) ReadSet
GetReadset(index int) ReadSet
ClearReadset(index int)
VersionedIndexedStore(index int, incarnation int, abortChannel chan occ.Abort) *VersionIndexedStore
Expand Down Expand Up @@ -248,16 +248,16 @@ func (s *Store) GetAllWritesetKeys() map[int][]string {
return writesetKeys
}

func (s *Store) SetReadset(index int, readset ReadSet) {
// Clone the readset so the caller (VIS) can reuse its map via clear().
clone := make(ReadSet, len(readset))
for k, v := range readset {
clone[k] = v
}
func (s *Store) SetReadset(index int, readset ReadSet) ReadSet {
// Swap ownership: take the caller's readset directly (no clone) and
// return the old one for the caller to reuse. This eliminates the
// per-call clone allocation (~5.6 GB / 30s).
sl := s.slot(index)
sl.mu.Lock()
sl.readset = clone
old := sl.readset
sl.readset = readset
sl.mu.Unlock()
return old
}

func (s *Store) GetReadset(index int) ReadSet {
Expand Down
Loading