Current: The TrieLayerCache maintains a chain of diff layers with parent pointers, designed for reorg support. Full sync never reorgs.
What's wasted:
- Layer chain walks (up to 4 layers per lookup via
get())
- Parent pointer maintenance
retain() calls to prune orphaned layers after commits
- Arc cloning during RCU updates
Proposed: For full sync, use a single flat HashMap trie cache instead of the layered scheme. When committing, just write everything to disk and clear the cache. No layers, no chains, no bloom, no RCU.
Even simpler: An LRU cache keyed by trie node path. The most recently written nodes stay in memory (hot), old nodes evict to disk. This naturally handles the "working set" nature of EVM execution without any bloom/layer overhead.
Effort: Medium-High. Requires an alternative code path for batch mode storage.
The build rebloom takes about 25% of the merkle spikes. This should be smoother in execution and reduce memory consumption.
Current: The
TrieLayerCachemaintains a chain of diff layers with parent pointers, designed for reorg support. Full sync never reorgs.What's wasted:
get())retain()calls to prune orphaned layers after commitsProposed: For full sync, use a single flat
HashMaptrie cache instead of the layered scheme. When committing, just write everything to disk and clear the cache. No layers, no chains, no bloom, no RCU.Even simpler: An LRU cache keyed by trie node path. The most recently written nodes stay in memory (hot), old nodes evict to disk. This naturally handles the "working set" nature of EVM execution without any bloom/layer overhead.
Effort: Medium-High. Requires an alternative code path for batch mode storage.
The build rebloom takes about 25% of the merkle spikes. This should be smoother in execution and reduce memory consumption.