-
Notifications
You must be signed in to change notification settings - Fork 864
perf(evm): skip redundant initial Snapshot in OCC executor path #2819
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
perf(evm): skip redundant initial Snapshot in OCC executor path #2819
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
f95aa5e to
b620ffb
Compare
a3a9cf5 to
2286d83
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## perf/lazy-cachemultistore #2819 +/- ##
=============================================================
+ Coverage 56.77% 56.78% +0.01%
=============================================================
Files 2070 2070
Lines 168336 168351 +15
=============================================================
+ Hits 95572 95600 +28
+ Misses 64280 64259 -21
- Partials 8484 8492 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
b620ffb to
13f343e
Compare
e91f6e4 to
ae6bbe8
Compare
In the OCC executor path, each EVM transaction creates 3 CacheMultiStore layers: 1. prepareTask: CMS with VersionIndexedStore wrappers (OCC isolation) 2. NewDBImpl: Snapshot() creates CMS wrapping #1 (GetCommittedState baseline) 3. Prepare: Snapshot() creates CMS wrapping #2 (EVM revert support) Layer #2 is redundant because no state changes occur between NewDBImpl and Prepare (called by go-ethereum's StateTransition.Execute). Prepare's Snapshot provides the same GetCommittedState baseline. Add NewDBImplWithoutSnapshot() that skips the initial Snapshot, used only in the OCC hot path (app.go executeEVMTxWithGigaExecutor). The original NewDBImpl is preserved for all other callers (tests, RPC, ante handlers) that may write state before the first explicit Snapshot. Also add defensive guards on GetCommittedState and flushEvents for the case where snapshottedCtxs is empty. Results (M4 Max benchmark, diff vs previous): - DBImpl.Snapshot alloc: -9.8 GB - cachemulti.newStoreWithoutGiga: -10.5 GB - Total alloc_space: 457 GB → 313 GB (-31%) - Idle CPU (usleep+kevent): 42.9s → 30.1s (-30%, workers busier) - TPS steady-state: 7,200-8,600 (median ~8,000) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
de7b59d to
f1c3021
Compare
ae6bbe8 to
08c4efe
Compare
|
This PR was auto-merged by GitHub during a stack reorder (branch force-push made head appear merged into base). No code was actually merged to main. This PR has been superseded — see the restacked PR chain starting at #2849. |
Summary
Snapshot()call inNewDBImplfor the OCC executor hot pathNewDBImplWithoutSnapshot()used only byexecuteEVMTxWithGigaExecutorNewDBImplpreserved for all other callers (tests, RPC, ante handlers)Problem
In the OCC executor path, each EVM transaction creates 3 CacheMultiStore layers:
CMS2 exists to provide a
GetCommittedStatebaseline viasnapshottedCtxs[0]. But no state changes occur betweenNewDBImplandPrepare(called by go-ethereum'sStateTransition.Execute), so Prepare's Snapshot provides the same baseline.Profiling after #2808 (30s, M4 Max, 1000 EVM transfers/block):
DBImpl.Snapshotalloc_space (cum)cachemulti.newStoreWithoutGigaalloc_spaceChanges
giga/deps/xevm/state/statedb.go: AddNewDBImplWithoutSnapshot()constructor + defensive guard onflushEventsgiga/deps/xevm/state/state.go: Defensive guard onGetCommittedStatefor emptysnapshottedCtxsapp/app.go: Hot path usesNewDBImplWithoutSnapshotBenchmark Results (M4 Max, 1000 EVM transfers/block, 30s profile)
DBImpl.Snapshotalloc_spacecachemulti.newStoreWithoutGigaallocnewCacheMultiStoreFromCMSalloc (cum)memclrNoHeapPointersCPUNote: TPS is flat despite -31% alloc because freed CPU shifts from idle to allocation overhead (
memclrNoHeapPointers). Workers complete faster but the GC/allocator remains the bottleneck.pprof -alloc_space -diff_basehighlightspprof -top -diff_basehighlights (CPU)Why safe
core.ApplyMessage→StateTransition.Executealways callsPrepare()→Snapshot()before any EVM state reads/writesGetCommittedStateusessnapshottedCtxs[0]which is set byPrepare'sSnapshot()— same committed state baselineNewDBImplcallers (tests, RPC, ante) keep the initialSnapshot()for isolationsnapshottedCtxsis emptyTest plan
go test ./giga/deps/xevm/state/... -count=1— pass (including TestSnapshot)go test ./giga/tests/... -count=1— pass (all 14 giga tests)gofmt -s -wclean🤖 Generated with Claude Code