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

Different Merkle prefetching #431

Closed Scooletz closed 1 week ago

Scooletz commented 1 week ago

This PR amends the prefetching one more time. The previous implementation was not thread safe and resulted in some undefined behavior from time to time (reading/writing when it should not to). The current implementation moves back to being single threaded and scheduling its work using ThreadPool.UnsafeQueueUserWorkItem and by implementing IThreadPoolWorkItem.

BitFilter issue

To limit the overhead of merging a prefetcher filter with the filter from BlockState, the block's filter is used directly so no copying at the end happens. This requires AddAtomic but it should not be a burden (runs show that it's not).

Benchmarks

Case with storage Prefetch Time (seconds)
02.45
01.23
03.30
02.26
github-actions[bot] commented 1 week ago

Code Coverage

Package Line Rate Branch Rate Health
Paprika 83% 81%
Summary 83% (4778 / 5733) 81% (1626 / 2016)

Minimum allowed line rate is 75%