NethermindEth / Paprika

A custom storage engine of Nethermind, benefiting from the alignment of the underlying data structure with the layout of State & Storage trees of Ethereum.
GNU Lesser General Public License v3.0
91 stars 14 forks source link

Better Merkle prefetcher #435

Closed Scooletz closed 1 day ago

Scooletz commented 6 days ago

This PR changes the Prefetcher component to fix a bug. It also addresses a few issues in the construction and usage of the prefetcher in regards to the ComputeMerkleBehavior. It makes the following changes:

  1. Prefetcher always owns the cache / preCommit explicitly with a lock. The lock will not be contended as there will be only one IThreadPoolWorkItem executing at any time. This allows for a simple ownership of this dictionary that should be owned either by Prefetcher (when possible and spinning to prefetch things) or ComputeMerkleBehavior when performing the computation.
  2. RlpMemo.Decompress is from now on called on by Prefetcher whenever the Branch is not loaded into the current block yet. Previously, compressed RlpMemo was stored, which resulted in MarkPathAsDirty and other calls sites, decompressing RlpMemo in the hot path. Now, with the data decompressed. It should just use data.
  3. ChildCommit now delegates the ownership to its parent, similar to what #420 did for Prefixing. This should limit the number of copies further, directly writing to the parent commit as the data are fetched already by Prefetcher
github-actions[bot] commented 5 days ago

Code Coverage

Package Line Rate Branch Rate Health
Paprika 83% 81%
Summary 83% (4853 / 5814) 81% (1652 / 2044)

Minimum allowed line rate is 75%