perf(evm): skip redundant initial Snapshot in OCC executor path#2819
Draft
pdrobnjak wants to merge 1 commit intoperf/cache-gaskv-contextfrom
Draft
perf(evm): skip redundant initial Snapshot in OCC executor path#2819pdrobnjak wants to merge 1 commit intoperf/cache-gaskv-contextfrom
pdrobnjak wants to merge 1 commit intoperf/cache-gaskv-contextfrom
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
4 tasks
f95aa5e to
b620ffb
Compare
a3a9cf5 to
2286d83
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## perf/cache-gaskv-context #2819 +/- ##
============================================================
+ Coverage 46.96% 56.67% +9.70%
============================================================
Files 1965 2031 +66
Lines 160635 165979 +5344
============================================================
+ Hits 75442 94061 +18619
+ Misses 78657 63667 -14990
- Partials 6536 8251 +1715
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
64fcc93 to
e91f6e4
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>
e91f6e4 to
ae6bbe8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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