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

core, cmd/utils: when configured via flag, in block execution: prefetch all reads from account/storage tries #29807

Merged
merged 4 commits into from
Jun 11, 2024

Conversation

jwasinger
Copy link
Contributor

@jwasinger jwasinger commented May 20, 2024

Pulled out from #29719

@jwasinger jwasinger changed the title cmd/utils, consensus/beacon, core/state: when configured via stub flag: prefetch all reads from account/storage tries, terminate prefetcher synchronously. cmd/utils, consensus/beacon, core/state: when configured via flag: prefetch all reads from account/storage tries, terminate prefetcher synchronously. May 20, 2024
@jwasinger jwasinger changed the title cmd/utils, consensus/beacon, core/state: when configured via flag: prefetch all reads from account/storage tries, terminate prefetcher synchronously. cmd/utils, consensus/beacon, core/state: when configured via flag, in block execution: prefetch all reads from account/storage tries, terminate prefetcher synchronously. May 20, 2024
@zhaoxiangjunupi
Copy link

jiejuelema

core/state/statedb.go Outdated Show resolved Hide resolved
cmd/utils/flags.go Outdated Show resolved Hide resolved
core/state/state_object.go Outdated Show resolved Hide resolved
@jwasinger jwasinger changed the title cmd/utils, consensus/beacon, core/state: when configured via flag, in block execution: prefetch all reads from account/storage tries, terminate prefetcher synchronously. core, cmd/utils: when configured via flag, in block execution: prefetch all reads from account/storage tries, terminate prefetcher synchronously. May 20, 2024
@Mazzika1
Copy link

Okay

@Mazzika1
Copy link

Oaky

@jwasinger
Copy link
Contributor Author

jwasinger commented May 21, 2024

Haven't quite got this working yet.... Seems somewhat okay now.

@jwasinger
Copy link
Contributor Author

Full sync benchmark nodes are running around block 12.2 million (bench7 is running this PR with the witness collection flag enabled, bench8 is master)

image

image

image

Witness collection mode is causing additional prefetch reads which all hit the db cache. There appears to be no performance impact.

Prefetcher duplicate/waste metrics cease to be meaningful if --collectwitnesses is passed. The account/storage loads are higher (but again, these hit the db cache so it's not a problem).

image

@@ -954,6 +954,12 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Value: metrics.DefaultConfig.InfluxDBOrganization,
Category: flags.MetricsCategory,
}

CollectWitnessesFlag = &cli.BoolFlag{
Name: "collectwitnesses",
Copy link
Member

Choose a reason for hiding this comment

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

Please name this debug.collectwitness and move it to the debug namespace in the usage section so we know it's not something to rely on.

As for the description, perhaps: Enable state witness generation during block execution. Work in progress flag, don't use.

Copy link
Member

Choose a reason for hiding this comment

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

Also Pls rename the flag to DebugCollectWitness

Copy link
Member

Choose a reason for hiding this comment

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

Please name this debug.collectwitness and move it to the debug namespace in the usage section so we know it's not something to rely on.

core/blockchain.go Outdated Show resolved Hide resolved
core/blockchain.go Outdated Show resolved Hide resolved
eth/ethconfig/config.go Outdated Show resolved Hide resolved
eth/backend.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
@@ -604,6 +610,9 @@ func (s *StateDB) getStateObject(addr common.Address) *stateObject {
if acc == nil {
return nil
}
if s.collectWitness && s.prefetcher != nil {
s.prefetcher.prefetch(common.Hash{}, s.originalRoot, common.Address{}, [][]byte{addr[:]})
}
Copy link
Member

Choose a reason for hiding this comment

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

You need to add the read to the prefetcher if you load from the trie too. Since the prefetcher's trie and the statedb trie are different. Yes, it's a bit of double work, but we only do that while generating the snapshot, so it's fine really.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't follow.

core/blockchain.go Outdated Show resolved Hide resolved
core/blockchain.go Outdated Show resolved Hide resolved
cmd/utils/flags.go Outdated Show resolved Hide resolved
@jwasinger
Copy link
Contributor Author

@karalabe I think I've mostly addressed your feedback and simplified the PR.

@jwasinger jwasinger changed the title core, cmd/utils: when configured via flag, in block execution: prefetch all reads from account/storage tries, terminate prefetcher synchronously. core, cmd/utils: when configured via flag, in block execution: prefetch all reads from account/storage tries Jun 6, 2024
cmd/utils/flags.go Outdated Show resolved Hide resolved
…g: prefetch all reads from account/storage tries, terminate prefetcher synchronously.
@karalabe karalabe force-pushed the witness-collection-stub branch 3 times, most recently from d9450f0 to 1be108b Compare June 6, 2024 12:58
core/state/statedb.go Outdated Show resolved Hide resolved
@karalabe karalabe added this to the 1.14.6 milestone Jun 10, 2024
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

SGTM

@karalabe karalabe merged commit 85587d5 into ethereum:master Jun 11, 2024
3 checks passed
@jwasinger jwasinger deleted the witness-collection-stub branch June 11, 2024 11:05
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.

None yet

5 participants