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
89 stars 11 forks source link

Different prefetcher #360

Open Scooletz opened 2 months ago

Scooletz commented 2 months ago

This PR alters how the Merkle prefetcher works. It's different from the previous one in the following way.

  1. Prefetcher is usable as is, requiring no additional work in Nethermind state.
  2. All prefetches are scheduled separately with ThreadPool.QueueUserWorkItem
  3. The scheduling call doesn't do the mapping of Address ->Keccak nor StorageCell->(Keccak, Keccak). It checks whether to run a frefetch using BitFilter with hash of raw inputs and then scheduled the work item
  4. To allow the check whether something was run or not, a IPrefetcherMapping is introduced that allows to pass an arbitrary parameter (Address, StorageCell) and define the mapping that will be run in the thread pool work item.

Benchmarks

Using PrefetcherTests.Spin scenarios. Accounts + storage means that each account has 4 slots occupied, so at least one branch will be there.

Scenario Prefetcher used Total commit time
Only accounts n 13s
Only accounts y 11s
Accounts + storage n 30s
Accounts + storage y 24s
Scooletz commented 2 months ago

Something does not work. It causes invalid blocks on Sepolia.

image

github-actions[bot] commented 2 months ago

Code Coverage

Package Line Rate Branch Rate Health
Paprika 85% 80%
Summary 85% (4220 / 4959) 80% (1350 / 1690)

Minimum allowed line rate is 75%