-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dbnode] Decode ReadBits improvements #2197
Conversation
@@ -29,9 +29,8 @@ import ( | |||
// istream encapsulates a readable stream. | |||
type istream struct { | |||
r *bufio.Reader // encoded stream | |||
err error // error encountered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing the error? Shouldn't ReadBit still fail if the stream has failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is set from the result of readByteFromStream
, but in all of the cases we call this, the parent call also returns that error (e.g. ReadBit
). So I see no reason to keep the error stored as state on the stream object itself if we already would have returned it. Is there a reason to keep it, though, that I'm missing? The value of removing it is that we can then remove these if-conditions that are in multiple methods to check if the error is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a noticeable difference on flame graphs? Branch prediction should help reduce the cost of these when there's no error
Mostly concerned about losing some future proofing if the actual impact turns out to be very small
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it is small but noticeable on the flamegraph. Most of ReadBits
is attributable to readByte
, and that increases when we remove this err checks (meaning less CPU work in the ReadBits
func, as you can see on the far right of the ReadBits
in the graphs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd still lean on the side of caution here; otherwise there's a bit of a weird reliance that is.r.Byte()
will error in the expected fashion otherwise, and if the underlying reader changes you may get weird behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sounds good to me. I'll update to only include the casting changes.
Are there large changes on the flame graphs? |
@@ -30,7 +30,7 @@ import ( | |||
const ( | |||
defaultDefaultTimeUnit = xtime.Second | |||
defaultByteFieldDictLRUSize = 4 | |||
defaultIStreamReaderSizeM3TSZ = 16 | |||
defaultIStreamReaderSizeM3TSZ = 8 * 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also FYI I was playing around with this setting since it drives how large a buffer we keep in this stream. Seems like it does have some effects on the flamegraphs where the larger buffer avoids time going to the buffer fill
as often. But the runtimes still seemed pretty variable so it didn't seem like a change we definitely want to make.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, yeah this might be worth playing around with - potentially in a way that only effects query instead of definitely dbnode as well.
setupProf(usePools, iterations) | ||
} | ||
|
||
func setupProf(usePools bool, iterations int) stop { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest refactor to this file no longer supported profiling since the defer p.Stop()
was being done in the setupBlocks
subfunction, so this fixes that.
Codecov Report
@@ Coverage Diff @@
## master #2197 +/- ##
======================================
Coverage 71.7% 71.7%
======================================
Files 1022 1022
Lines 88943 88943
======================================
Hits 63779 63779
Misses 20817 20817
Partials 4347 4347
Continue to review full report at Codecov.
|
…3 into ra/decode-perf-benchmarking
What this PR does / why we need it:
Changes to
ReadBits
andPeekBits
include:uint
Special notes for your reviewer:
Does this PR introduce a user-facing and/or backwards incompatible change?:
Does this PR require updating code package or user-facing documentation?: