-
Notifications
You must be signed in to change notification settings - Fork 42
feat(x/vm): apply stack-based StateDB snapshot mechamism for precompile call #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
dep(evmd): go mod tidy refactor: change package name of stack based store refactor(x/vm/store): modify type casting refactor(x/vm): rename store packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cloudgray
Since the actual type of s.cacheCtx.MultiStore()
at this point is *snapshotmulti.Store
, I think it's clearer to cast it explicitly rather than going through the storetypes.CacheMultiStore
interface.
While *snapshotmulti.Store
does implement CacheMultiStore
, making that implicit assumption here could lead to confusion for future maintainers who aren’t aware of the underlying implementation. Being explicit improves readability and reduces ambiguity in understanding what store we’re operating on.
I checked that there are no errors after the suggested change.
s.ctx.EventManager().EmitEvents(events) | ||
cms.Write() | ||
s.cacheCtx.MultiStore().(storetypes.CacheMultiStore).Write() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s.cacheCtx.MultiStore().(storetypes.CacheMultiStore).Write() | |
s.cacheCtx.MultiStore().(*snapshotmulti.Store).Write() |
s.cacheCtx = s.cacheCtx.WithMultiStore(snapshotStore) | ||
s.writeCache = func() { | ||
s.ctx.EventManager().EmitEvents(s.cacheCtx.EventManager().Events()) | ||
s.cacheCtx.MultiStore().(storetypes.CacheMultiStore).Write() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s.cacheCtx.MultiStore().(storetypes.CacheMultiStore).Write() | |
snapshotStore.Write() |
kv.Set([]byte(fmt.Sprintf("%s-tx-%d-%d", key.Name(), tx, j)), genBytes(32)) | ||
} | ||
snapshot := cms.Snapshot() | ||
benchSink = snapshot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious — what’s the purpose of benchSink here?
} | ||
|
||
func TestSnapshotMultiIndexing(t *testing.T) { | ||
cms, _ := setupStore() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor naming suggestion: would it be possible to rename the cms
variable to something like ss
or snapshotStore
?
Since cms
often refers to CacheMultiStore
in the SDK context, it might be a bit misleading here, especially if it’s actually a snapshotmulti.Store
. Renaming it could help reduce confusion for readers familiar with the SDK naming conventions.
@cloudgray |
Description
Summary
Stack-based Snapshot Mechanism
Snapshot()
method of the new store uses approximately 1.4 times more memory than the previously usedCacheMultiStore()
, but it provides a more robust structure that avoids edge cases.Benchmark
The benchmark results show that the new Snapshot() method uses significantly less memory than a deep copy, and the gap widens as the number of iterations increases.
Like CacheMultiStore(), the new Snapshot() method exhibits linear memory growth with increasing iterations, using approximately 1.4× more memory than CacheMultiStore()
Closes: #225
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
main
branchReviewers Checklist
All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.
I have...
Unreleased
section inCHANGELOG.md