-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vastly optimize the MRU inventory handling.
Profiling showed the MRU inventory handling was taking 5% of the total block handling time. Upon inspection this is because the original implementation was extremely inefficient using iteration to find the oldest node for eviction. This commit reworks it to use a map and list in order to achieve close to O(1) performance for lookups, insertion, and eviction. The following benchmark results show the difference: Before: BenchmarkMruInventoryList 100 1069168 ns/op After: BenchmarkMruInventoryList 10000000 152 ns/op Closes #21
- Loading branch information
Showing
1 changed file
with
35 additions
and
21 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