Skip to content

Conversation

@darioush
Copy link

@darioush darioush commented Nov 22, 2024

Why this should be merged

The current trie_prefetcher is modified significantly compared to upstream, which makes it difficult to merge changes from upstream.
This PR aims to preserve the existing behavior but only with minor inline modifications to upstream code.

How this works

Uses a wrapper for DB to track the central worker pool.
Adds a couple hooks for stopping the background processes.

How this was tested

CI, benchmark for trie size ~50m k/vs and adding 100, 200, 500 kvs/ block

Should be added to release notes?

Added

Darioush Jalali added 2 commits November 25, 2024 10:42
@darioush darioush changed the title [wip] libevm trie prefetcher refactor: trie_prefetcher to match upstream structurally Nov 25, 2024
@darioush darioush changed the title refactor: trie_prefetcher to match upstream structurally refactor trie_prefetcher to be similar to upstream structurally Nov 25, 2024
@darioush
Copy link
Author

                                                 │ master-50m-2account-run-cc.txt │    alt2-50m-2account-run-cc.txt     │
                                                 │             sec/op             │    sec/op     vs base               │
PrefetcherDatabase/updates_100_prefetchers_0-16                       1.522 ± 23%    1.622 ± 23%       ~ (p=0.481 n=10)
PrefetcherDatabase/updates_100_prefetchers_1-16                       1.237 ±  6%    1.320 ±  8%  +6.64% (p=0.043 n=10)
PrefetcherDatabase/updates_100_prefetchers_4-16                      274.6m ± 38%   290.8m ± 39%       ~ (p=0.684 n=10)
PrefetcherDatabase/updates_100_prefetchers_16-16                     73.52m ±  5%   71.74m ±  8%       ~ (p=0.315 n=10)
PrefetcherDatabase/updates_200_prefetchers_0-16                      682.6m ±  5%   702.1m ±  1%       ~ (p=0.089 n=10)
PrefetcherDatabase/updates_200_prefetchers_1-16                      659.6m ±  3%   680.8m ±  3%  +3.22% (p=0.003 n=10)
PrefetcherDatabase/updates_200_prefetchers_4-16                      208.8m ±  3%   213.9m ±  4%       ~ (p=0.190 n=10)
PrefetcherDatabase/updates_200_prefetchers_16-16                     122.9m ±  5%   116.5m ±  1%  -5.19% (p=0.007 n=10)
PrefetcherDatabase/updates_500_prefetchers_0-16                       1.161 ±  2%    1.185 ±  1%       ~ (p=0.089 n=10)
PrefetcherDatabase/updates_500_prefetchers_1-16                       1.172 ±  2%    1.167 ±  1%       ~ (p=0.853 n=10)
PrefetcherDatabase/updates_500_prefetchers_4-16                      389.2m ±  2%   391.1m ±  2%       ~ (p=0.393 n=10)
PrefetcherDatabase/updates_500_prefetchers_16-16                     271.3m ±  1%   266.7m ±  1%  -1.69% (p=0.000 n=10)
geomean                                                              446.7m         454.0m        +1.64%

@darioush
Copy link
Author

                                                 │ master-50m-2account-run-cc.txt │    alt2-50m-2account-run-cc.txt     │
                                                 │           allocs/op            │  allocs/op    vs base               │
PrefetcherDatabase/updates_100_prefetchers_0-16                      1.255M ±  0%   1.254M ±  0%       ~ (p=0.165 n=10)
PrefetcherDatabase/updates_100_prefetchers_1-16                      1.267M ±  0%   1.267M ±  0%       ~ (p=0.579 n=10)
PrefetcherDatabase/updates_100_prefetchers_4-16                      391.1k ± 25%   390.9k ± 25%       ~ (p=0.912 n=10)
PrefetcherDatabase/updates_100_prefetchers_16-16                     180.6k ±  3%   178.0k ±  2%       ~ (p=0.912 n=10)
PrefetcherDatabase/updates_200_prefetchers_0-16                      756.1k ±  0%   755.6k ±  0%       ~ (p=0.436 n=10)
PrefetcherDatabase/updates_200_prefetchers_1-16                      776.3k ±  0%   777.3k ±  0%       ~ (p=0.052 n=10)
PrefetcherDatabase/updates_200_prefetchers_4-16                      422.8k ±  0%   423.1k ±  0%       ~ (p=0.393 n=10)
PrefetcherDatabase/updates_200_prefetchers_16-16                     325.5k ±  3%   317.6k ±  0%       ~ (p=0.289 n=10)
PrefetcherDatabase/updates_500_prefetchers_0-16                      1.582M ±  0%   1.582M ±  0%       ~ (p=0.436 n=10)
PrefetcherDatabase/updates_500_prefetchers_1-16                      1.630M ±  0%   1.633M ±  0%  +0.19% (p=0.019 n=10)
PrefetcherDatabase/updates_500_prefetchers_4-16                      840.1k ±  0%   843.2k ±  0%  +0.37% (p=0.000 n=10)
PrefetcherDatabase/updates_500_prefetchers_16-16                     743.5k ±  0%   744.8k ±  0%  +0.18% (p=0.002 n=10)
geomean                                                              703.2k         701.3k        -0.27%

@darioush darioush marked this pull request as ready for review November 25, 2024 19:00
@darioush darioush requested review from a team and ceyonur as code owners November 25, 2024 19:00
@darioush darioush requested a review from ARR4N November 25, 2024 19:00
ARR4N
ARR4N previously approved these changes Nov 26, 2024
ceyonur
ceyonur previously approved these changes Dec 10, 2024
@darioush
Copy link
Author

Let's wait for Etna to activate then we can ship this in the following version

@darioush darioush added the DO NOT MERGE This PR is not meant to be merged in its current state label Dec 10, 2024
@darioush darioush dismissed stale reviews from ceyonur and ARR4N via 0b5bed8 December 16, 2024 18:08
@darioush darioush removed the DO NOT MERGE This PR is not meant to be merged in its current state label Dec 16, 2024
Signed-off-by: Darioush Jalali <[email protected]>
Darioush Jalali added 2 commits December 16, 2024 10:11
Signed-off-by: Darioush Jalali <[email protected]>
Signed-off-by: Darioush Jalali <[email protected]>
ARR4N
ARR4N previously approved these changes Dec 17, 2024
Copy link
Contributor

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIce 👍
I'm just worried about func (p *subfetcherPool) execute(fn func(Trie)) which looks a bit strange

Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Darioush Jalali <[email protected]>
Darioush Jalali and others added 4 commits December 17, 2024 10:11
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Darioush Jalali <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Darioush Jalali <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Darioush Jalali <[email protected]>
qdm12
qdm12 previously approved these changes Dec 17, 2024
Copy link
Contributor

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but with my limited knowledge especially on geth original and modified files though

Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Darioush Jalali <[email protected]>
@darioush darioush merged commit e0381a9 into master Dec 30, 2024
14 checks passed
@darioush darioush deleted the trie-prefetcher-alt2 branch December 30, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants