-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Reduce api/sessionrecording's Reader API and misc. improvements #50883
Open
dustinspecker
wants to merge
24
commits into
dustin.specker/move-proto-reader-to-api
Choose a base branch
from
dustin.specker/modify-session-recording-reader-api
base: dustin.specker/move-proto-reader-to-api
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Reduce api/sessionrecording's Reader API and misc. improvements #50883
dustinspecker
wants to merge
24
commits into
dustin.specker/move-proto-reader-to-api
from
dustin.specker/modify-session-recording-reader-api
Conversation
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
Before, this was taking an io.ReadCloser, but newGzipReader was always being used by sessionrecording with io.NopCloser. So, just take an io.Reader.
After accepting only a io.Reader, gzipReader doesn't make much sense anymore. Instead, update sessionrecording.Reader to construct a gzip.Reader with Multistream disabled.
Previously, newGzipWriter took an io.WriteCloser, but the only time newGzipWriter was being used was with a Closer that did nothing. So just take an io.Writer instead. This also enables removing the bufferCloser struct.
This is mostly to help clarify what the different readers do.
Reader.Reset was only being used by tests. Remove Reset from the API, so it does not need to be supported for consumers. Update tests to not require Reset usage.
This prevents any unsafe int64 to int conversions.
Before, a session recording reader was being created for each uploaded part. There are situations where duplicate event indices may be uploaded. This was causing the test cases to have to de-duplicate events. Now, combine all uploaded parts into a single byte slice (bytes.Buffer) to be read by a single session recording reader. The reader already knows to drop duplicate event indices.
… struct This will prevent Go from needing to allocate and zero out 64K for each invocation of Read. This may possibly reduce the chances of Go doing a heap allocation.
dustinspecker
commented
Jan 8, 2025
slog.Int64("skipped_events", p.SkippedEvents), | ||
slog.Int64("out_of_order_events", p.OutOfOrderEvents), | ||
slog.Int64("total_events", p.TotalEvents), | ||
) | ||
} | ||
|
||
// Close releases reader resources |
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.
rosstimothy brought up the following on the original pull request.
"Is is possible that gzipReader is assigned after the check on line 129? For instance what if Read is being executed in another goroutine?"
This was true, but is no longer true since sessionrecording.Reader does this behavior by default.
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.
This pull request:
sessionrecording.Reader
API, notableReset
slog.LogValuer
This pull request builds on top of #50501
changelog: reduce api/sessionrecording.Reader API