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

perf: improve genesis handling #10878

Merged
merged 7 commits into from
Sep 13, 2024
Merged

perf: improve genesis handling #10878

merged 7 commits into from
Sep 13, 2024

Conversation

DaniPopes
Copy link
Member

  • cache genesis hash and header (which includes state root) with OnceLock fields; these are currently computed at least 2 times each on each reth invocation, if not more (sealed_genesis_header computes header and hash which itself computes header again if not set)
  • remove a ton of clones and btreemap collections in impl HistoryWriter for DatabaseProvider by passing required values in impl IntoIterators
  • pass state provider by reference in init_genesis; it's not really "cheap" to clone (5 arcs + PruneModes which could allocate)

crates/chainspec/src/spec.rs Show resolved Hide resolved
@onbjerg onbjerg added the C-perf A change motivated by improving speed, memory usage or disk footprint label Sep 13, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm, pending @onbjerg nits

@@ -275,7 +277,11 @@ impl ChainSpec {
}

/// Get the header for the genesis block.
pub fn genesis_header(&self) -> Header {
pub fn genesis_header(&self) -> &Header {
self.genesis_header.get_or_init(|| self.make_genesis_header())
Copy link
Collaborator

Choose a reason for hiding this comment

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

cool, this definitely works

@mattsse mattsse dismissed onbjerg’s stale review September 13, 2024 16:13

bossman did le docs

@mattsse
Copy link
Collaborator

mattsse commented Sep 13, 2024

smol import conflict

@DaniPopes DaniPopes added this pull request to the merge queue Sep 13, 2024
Merged via the queue into main with commit b23bb7e Sep 13, 2024
34 checks passed
@DaniPopes DaniPopes deleted the dani/perf-genesis branch September 13, 2024 18:02
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants