Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snap Sync Fetchers: Highest-Known-Hash Optimization #2941

Merged
merged 11 commits into from
Aug 15, 2023

Conversation

scorbajio
Copy link
Contributor

@scorbajio scorbajio commented Aug 6, 2023

Currently, the account and storage fetchers statically partition large hash ranges of accounts and storage slots to fetch each range sequentially. During fetching, we do not know if any or what hashes exist in a given range, so there is the potential that during a range request, a hash is returned that is higher than multiple range partitions that are queued for requesting. If this happens, the fetchers currently will still request ranges that are known to be empty after having received a hash value that is higher than the limits of queued ranges. This change will track the highest known key hash for the affected fetchers and skip requesting any queued ranges that have limit lower than the known highest hash.

@codecov
Copy link

codecov bot commented Aug 6, 2023

Codecov Report

Merging #2941 (31690c7) into master (6d283b1) will increase coverage by 0.01%.
The diff coverage is 95.83%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 88.66% <ø> (ø)
blockchain 92.58% <ø> (ø)
client 87.51% <95.83%> (+0.02%) ⬆️
common 98.56% <ø> (ø)
ethash ∅ <ø> (∅)
evm 70.43% <ø> (ø)
rlp ∅ <ø> (∅)
statemanager 84.43% <ø> (ø)
trie 89.92% <ø> (+0.03%) ⬆️
tx 95.88% <ø> (ø)
util 86.78% <ø> (ø)
vm 79.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@scorbajio
Copy link
Contributor Author

Optimizing the storage fetcher is more complicated since the response for getStorageRanges is a double array. Will handle that in a future PR.

@scorbajio scorbajio changed the title Snap Sync Fetchers: Highest Known Hash Optimization Snap Sync Fetchers: Highest-Known-Hash Optimization Aug 7, 2023
@scorbajio scorbajio requested a review from g11tech August 7, 2023 19:05
Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

blocking till

is merged so that the PR can be merged with keyHashing enabled

@scorbajio scorbajio requested a review from g11tech August 13, 2023 18:55
@g11tech
Copy link
Contributor

g11tech commented Aug 14, 2023

will test this out today @scorbajio 👍

@@ -287,6 +290,11 @@ export class AccountFetcher extends Fetcher<JobTask, AccountData[], AccountData>
const origin = this.getOrigin(job)
const limit = this.getLimit(job)

if (this.highestKnownHash && compareBytes(limit, this.highestKnownHash) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ahh so this solves the problem that if some range is empty it won't be requested 👍

@g11tech
Copy link
Contributor

g11tech commented Aug 14, 2023

from the code review it seems that we would need similar optimization in storage fetcher?

@scorbajio
Copy link
Contributor Author

from the code review it seems that we would need similar optimization in storage fetcher?

Yes, but since the optimization for the storage fetcher is more complicated, I'm planning on doing it in a followup PR.

@g11tech g11tech merged commit e6dc9db into master Aug 15, 2023
@holgerd77 holgerd77 deleted the snap-tests-and-highest-hash-optimization branch August 15, 2023 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants