forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58045: storageccl: make KeyRewriter lookup O(logn) and memoized r=dt a=dt The previous code was O(n) in terms of number of tables, and could be very slow for very large numbers of tables. The O(n) code on the two-prefix benchmark clocked in at about 10ns/op. Sorting the prefixes allows binary searching to find a matching one, but on this small benchmark, the binary search version alone actually takes closer to 30ns/op. Adding memoization should help considerably, both in the small benchmark, but also in real world usage too: as keys are passed to the rewriter in order and will almost always be matched by the same table prefix, memoization of just the last match likely has nearly 100% hit rate, and means that the log n lookup should only happen ~once per range. Co-authored-by: David Taylor <[email protected]>
- Loading branch information
Showing
4 changed files
with
49 additions
and
30 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