Small speedups in RecyclerBytesStreamOutput#140257
Closed
DaveCTurner wants to merge 1 commit intoelastic:mainfrom
Closed
Small speedups in RecyclerBytesStreamOutput#140257DaveCTurner wants to merge 1 commit intoelastic:mainfrom
RecyclerBytesStreamOutput#140257DaveCTurner wants to merge 1 commit intoelastic:mainfrom
Conversation
1. No need to compute `vIntLength(i)` in the very common case that
there's more than 5 bytes of space left on the current page.
2. No need to subtract the current offset from the return value of
`putVInt()` only to add it back again: we can just return the updated
offset directly.
3. No need to use `putVInt()` when we've already handled the multibyte
case.
4. `writeVLong()` also shows up in profiling sometimes so deserves
similar optimizations to `writeVInt()`.
Microbenchmark results before change:
1. As committed
Benchmark Mode Cnt Score Error Units
RecyclerBytesStreamOutputBenchmark.writeVInt avgt 3 1734.806 ± 45.790 ns/op
RecyclerBytesStreamOutputBenchmark.writeVLong avgt 3 6196.593 ± 405.058 ns/op
2. With arrays of length 16kiB+1 to overflow page
Benchmark Mode Cnt Score Error Units
RecyclerBytesStreamOutputBenchmark.writeVInt avgt 3 71214.075 ± 6742.644 ns/op
RecyclerBytesStreamOutputBenchmark.writeVLong avgt 3 186032.816 ± 2546.869 ns/op
Microbenchmark results after change:
1. As committed
Benchmark Mode Cnt Score Error Units
RecyclerBytesStreamOutputBenchmark.writeVInt avgt 3 1456.083 ± 8.507 ns/op
RecyclerBytesStreamOutputBenchmark.writeVLong avgt 3 1699.816 ± 77.845 ns/op
2. With arrays of length 16kiB+1 to overflow page
Benchmark Mode Cnt Score Error Units
RecyclerBytesStreamOutputBenchmark.writeVInt avgt 3 64393.687 ± 3891.214 ns/op
RecyclerBytesStreamOutputBenchmark.writeVLong avgt 3 74050.944 ± 7618.977 ns/op
Collaborator
|
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
Contributor
Author
|
Ah wait there's a bug in this (and a big gap in the tests it seems!) |
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.
No need to compute
vIntLength(i)in the very common case thatthere's more than 5 bytes of space left on the current page.
No need to subtract the current offset from the return value of
putVInt()only to add it back again: we can just return the updatedoffset directly.
No need to use
putVInt()when we've already handled the multibytecase.
writeVLong()also shows up in profiling sometimes so deservessimilar optimizations to
writeVInt().Microbenchmark results before change:
As committed
With arrays of length 16kiB+1 to overflow page
Microbenchmark results after change:
As committed
With arrays of length 16kiB+1 to overflow page