Skip to content

Conversation

fmoletta
Copy link
Contributor

@fmoletta fmoletta commented Apr 11, 2025

Motivation
After recent changes in main, rebuilding now takes a lot longer than state sync. This PR aims to mitigate this hit by introducing other performance upgrades

Description

  • Increase parallelism when rebuilding storages
  • Reduce intermediate hashing when rebuilding state tries

These changes have increased storage rebuild speed to around the same as before the changes to store, and has reduced time estimates for state rebuild, but doesn't manage to make the state rebuild keep up with the state sync. These changes have not affected state sync speed

Closes #issue_number

@fmoletta fmoletta changed the title feat(l1): improve rebuilding speed feat(l1): improve rebuilding speed during snap sync Apr 11, 2025
Copy link

github-actions bot commented Apr 11, 2025

Lines of code report

Total lines added: 13
Total lines removed: 0
Total lines changed: 13

Detailed view
+---------------------------------------------------+-------+------+
| File                                              | Lines | Diff |
+---------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/sync/trie_rebuild.rs | 257   | +13  |
+---------------------------------------------------+-------+------+

@fmoletta fmoletta marked this pull request as ready for review April 11, 2025 19:46
@fmoletta fmoletta requested a review from a team as a code owner April 11, 2025 19:46
/// Max storages to rebuild in parallel
const MAX_PARALLEL_REBUILDS: usize = 15;

const MAX_SNAPSHOT_READS_WITHOUT_COMMIT: usize = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the criteria for this number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trial and error mostly. The gist is that less commits make rebuild go faster but large commits can slow down other processes. I sought the highest value that would not slow down state sync.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wonder if these values that might be ideal for Holesky, are also appropriate for the other networks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These values should be the least affected by a change of network as rebuild happens in the background and only interacts with the DB, it is not really affected by peer availability/speed at which we receive data from peers, and we cannot really split it into different processes to scale to a bigger trie size.
They could possibly change along with changes/improvements to trie caches and the DB.
These are also strong candidates to become customizable via config file (such as in #2331 )

@fmoletta fmoletta added this pull request to the merge queue Apr 25, 2025
Merged via the queue into main with commit 098a152 Apr 25, 2025
18 checks passed
@fmoletta fmoletta deleted the improve-rebuild-speed branch April 25, 2025 22:04
pedrobergamini pushed a commit to pedrobergamini/ethrex that referenced this pull request Aug 24, 2025
**Motivation**
After recent changes in main, rebuilding now takes a lot longer than
state sync. This PR aims to mitigate this hit by introducing other
performance upgrades
<!-- Why does this pull request exist? What are its goals? -->

**Description**
* Increase parallelism when rebuilding storages
* Reduce intermediate hashing when rebuilding state tries
<!-- A clear and concise general description of the changes this PR
introduces -->
These changes have increased storage rebuild speed to around the same as
before the changes to store, and has reduced time estimates for state
rebuild, but doesn't manage to make the state rebuild keep up with the
state sync. These changes have not affected state sync speed
<!-- Link to issues: Resolves lambdaclass#111, Resolves lambdaclass#222 -->

Closes #issue_number
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.

3 participants