Skip to content

Replace Trie Layers with LRU cache in Full sync #6480

@Arkenan

Description

@Arkenan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceBlock execution throughput and performance in generalsyncingSnap sync, Full sync

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions