perf: suppress dead Cosmos events in giga executor path#2904
perf: suppress dead Cosmos events in giga executor path#2904
Conversation
Cache ChainID, BlockContext, ChainConfig, and BaseFee once per block instead of recomputing them for every transaction. These values are identical for all txs in a block but were previously causing redundant store reads, Keccak256 hashing, and big.Int allocations on every call. The cache is constructed as a local variable and passed as a parameter to executeEVMTxWithGigaExecutor, avoiding any mutable state on App. Both giga execution paths (synchronous and OCC) are covered. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cosmos-level events (coin_spent, coin_received, transfer, etc.) emitted during giga executor tx execution are never consumed: the ExecTxResult is built without populating the Events field, and events are not consensus-critical (stripped from deterministicExecTxResult). EVM logs (Solidity events) flow through a completely separate path (tempState.logs -> receipts + MsgEVMTransactionResponse) and are unaffected. When GIGA_SUPPRESS_COSMOS_EVENTS=true: - EventManager.EmitEvent/EmitEvents return immediately (no mutex, no append, no bech32 encoding in event attributes) - Snapshot() creates suppressed EventManagers - Finalize() skips the flushEvents() consolidation loop This eliminates ~55s of mutex contention per 30s profile window: - AccAddress.String() bech32 cache mutex: ~27s - EventManager.EmitEvents RWMutex: ~28s Also updates benchmark/analysis/ with findings from the AccAddress.String sync.Map optimization (PR #2902) and this event suppression discovery. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #2904 +/- ##
===========================================
- Coverage 57.21% 48.38% -8.84%
===========================================
Files 2093 671 -1422
Lines 171755 50621 -121134
===========================================
- Hits 98276 24491 -73785
+ Misses 64709 23984 -40725
+ Partials 8770 2146 -6624
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
We truly appreciate your contribution and the time you’ve invested in this PR. |
Summary
GIGA_SUPPRESS_COSMOS_EVENTS=trueenv var flag to skip Cosmos-level event emission (coin_spent, coin_received, etc.) during giga executor tx executionExecTxResult.Eventsis never populated, events are not consensus-critical, anddeterministicExecTxResultstrips themtempState.logs→ receipts) and are unaffectedImplementation
EventManager.suppressedfield —EmitEvent/EmitEventsreturn immediately (no mutex, no append, no bech32 encoding)NewSuppressedEventManager()constructor for the suppressed variantDBImpl.cosmosEventsSuppressed—Snapshot()creates suppressed EventManagersFinalize()skipsflushEvents()loop entirely when suppressedProfile impact (benchmark-compare.sh, 120s)
Mutex contention eliminated: -48.35s (7.6% of total)
EventManager.EmitEvents: -48.21ssync.(*Mutex).Unlock: -48.35sAllocations eliminated: ~1.65 GB
Events.AppendEvents: -1,068 MBEvents.AppendEvent: -729 MBTPS was flat in isolation because the bottleneck shifts to
Snapshot()→CacheMultiStoreallocation. The contention and allocation savings will compound once that path is optimized.Test plan
giga/deps/xevm/statetests passsei-cosmos/typestests passGIGA_SUPPRESS_COSMOS_EVENTS=true🤖 Generated with Claude Code