-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: remove some major bottlenecks in deletion
Our deleting code had some major bottlenecks, like calling calculate hashes twice (one for the old roots and one for updated ones) and filtering the nodes that are in the proof, which was causing a linear search on proof_positins **for each element in nodes**. This commit fixes that by: - Creating a calculate_nodes_delete function that computes in parallel both updated and current roots, so we don't need to loop twice. In the future we could even use vectorized computation of sha512_256 two further speed things up. - Don't filter proof positions from the nodes vector in calculate_nodes_delete. This will waste a little memory as nodes in the proof are returned, but won't cause a new allocation as we are returning nodes as is. - calculate_hashes now won't delete, so it gets simplified to only work when checking or updating proofs. After running the new code for two days with floresta, the speedup is clear, with calculate_nodes_delete taking less than 2% of the CPU time for block validation. Before this path it was using >40%.
- Loading branch information
1 parent
eb22a17
commit ccf72e9
Showing
2 changed files
with
219 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters