perf: Add resetBatch optimization to fastnode genesis #730
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add reset batch optimization to writing fast nodes at genesis, mirroring whats done for normal node saving.
This is really the same idea as #652 , but at the genesis-only level right now, as thats whats already done for normal nodes, and deemed normal at genesis. (Whereas #652 may have to reason about different guarantees, e.g. signalling when the full batch is completed)
This brings a significant speedup for InitGenesis logic.
Before (370 s + GC):
![image](https://user-images.githubusercontent.com/6440154/230796556-c0e38906-9207-495d-b210-a1476aa58aa9.png)
After (41.3 s):
![image](https://user-images.githubusercontent.com/6440154/230796576-2cb98015-eaf0-48da-a29a-ecc02488aa53.png)
This is also with massive GC reductions (due to far less leveldb.grow operations), and lower peak RAM usage. (One less full-module write copy)