internal/keyspan: apply various micro-optimizations#1743
Merged
jbowens merged 4 commits intocockroachdb:masterfrom Jun 9, 2022
Merged
internal/keyspan: apply various micro-optimizations#1743jbowens merged 4 commits intocockroachdb:masterfrom
jbowens merged 4 commits intocockroachdb:masterfrom
Conversation
Member
nicktrav
approved these changes
Jun 9, 2022
Contributor
nicktrav
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @itsbilal)
Previously, DefragmentingIter checked for invalid spans within
defragment{Forward,Backward}. This incurred unnecessary validity checks in some
cases, and in others forced a function call that could've been replaced by an
inlined validity check. This commit moves these validity checks into the
caller, where necessary.
```
name old time/op new time/op delta
IteratorSeekNoRangeKeys/batch=false-10 5.09µs ± 1% 4.53µs ± 1% -10.94% (p=0.000 n=10+9)
IteratorSeekNoRangeKeys/batch=true-10 9.85µs ± 1% 9.54µs ± 3% -3.15% (p=0.000 n=9+10)
```
Inline the startBound and endBound helpers used in MergingIter. This also removes a redundant span validity check in some cases. ``` name old time/op new time/op delta IteratorSeekNoRangeKeys/batch=false-10 4.57µs ± 1% 4.59µs ± 1% ~ (p=0.164 n=19+20) IteratorSeekNoRangeKeys/batch=true-10 9.53µs ± 2% 9.04µs ± 4% -5.11% (p=0.000 n=19+18) ```
Refactor the InterleavingIter's bound checking to remove unnecessary Span struct copies as parameters and return values. ``` name old time/op new time/op delta IteratorSeekNoRangeKeys/batch=false-10 4.59µs ± 1% 4.28µs ± 1% -6.79% (p=0.000 n=20+19) IteratorSeekNoRangeKeys/batch=true-10 9.04µs ± 4% 8.78µs ± 1% -2.94% (p=0.000 n=18+20) ```
jbowens
commented
Jun 9, 2022
Contributor
Author
jbowens
left a comment
There was a problem hiding this comment.
TFTR!
Reviewable status: 1 of 4 files reviewed, all discussions resolved (waiting on @itsbilal and @nicktrav)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
These commits introduce a new microbenchmark
BenchmarkIteratorSeekNoRangeKeysand apply a few micro-optimizations that help move the needle on cockroachdb/cockroach#82559.