-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimise the implementation of ledgerDbPast
Instead of O(n), it is now O(log n * log n) (binary search with at each step an operation logarithmic in the size). Since we're now much more often asking for past ledger snapshots in the ChainSyncClient, it has become more important to optimise this. Microbenchmarks with size = 2160 (using `r = RealPoint` with a real hash): snapshot to lookup | before | after -------------------|------------|---------- oldest | 40. μs | 1.3 μs middle | 20. μs | 0.238 μs newest | 0.035 μs | 0.035 μs missing in middle | 40. μs | 1.3 μs Newest is a special case that is handled separately, so it didn't change. The other operations are now more than 10x faster. See the comments for more implementation details.
- Loading branch information
Showing
3 changed files
with
128 additions
and
25 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