-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Memtrie] Optimize NibbleSlice during the memtrie construction code p…
…ath (#11342) This contains two top optimizations that speed up the memtrie construction code: * Rather than allocating a new Vec<u8> every time we encode nibbles, we use a freelist so that previously allocated Vec<u8> can be reused. This reduces allocations from O(millions) to O(tens). * As a side effect, InputMemTrieNode has to be changed to contain borrowed slices, as we can no longer give owned Box<[u8]> to it. This is totally fine though because anyway the InputMemTrieNode's data needs to be copied into the constructed memtrie nodes in the arena. * Optimize the nibble slice encoding function so that rather than encoding nibble by nibble, we encode the first nibble and then just copy the remaining bytes directly. Also optimize the at(i) function, removing branching entirely (this code now gets compiled to a bunch of arithmetic operations). On shard 5 these optimizations reduce load time from 146s to 122s.
- Loading branch information
1 parent
ae06f37
commit 141e7e5
Showing
13 changed files
with
330 additions
and
104 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
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
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
Oops, something went wrong.