-
Notifications
You must be signed in to change notification settings - Fork 705
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
Add configurable alignment to FastSerializer #1560
Merged
brianrob
merged 6 commits into
microsoft:main
from
josalem:dev/josalem/allow-unaligned-stream-reading
Feb 3, 2022
Merged
Add configurable alignment to FastSerializer #1560
brianrob
merged 6 commits into
microsoft:main
from
josalem:dev/josalem/allow-unaligned-stream-reading
Feb 3, 2022
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
* Fix unseen bug where Goto(label) where label > alignment size would cause reads at the wrong position
jander-msft
reviewed
Jan 27, 2022
wiktork
reviewed
Jan 27, 2022
brianrob
reviewed
Jan 27, 2022
noahfalk
approved these changes
Jan 27, 2022
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.
LGTM
Co-authored-by: Noah Falk <noahfalk@users.noreply.github.com>
brianrob
reviewed
Jan 28, 2022
brianrob
reviewed
Jan 28, 2022
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.
Overall, LTGM. A couple of small things.
…om:josalem/perfview into dev/josalem/allow-unaligned-stream-reading
brianrob
approved these changes
Feb 3, 2022
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.
IOStreamStreamReader had a hard coded 8 byte alignment. EventPipe streams do not have any alignment requirements (save for some 4 byte alignments inside blocks). This means that blocks can have sizes that are not aligned. EventPipeEventSource will not dispatch events read from the stream until reads complete. In live cases where these blocks are unaligned, but no new data is coming down the pipe, the reader can attempt to enforce the alignment and end up blocking until new data arrives. This results in latency for event dispatch. For infrequent events, this can be a long period of time causing users to think they haven't received events.
For example:
EventBlock 1, EventBlock 2, and EventBlock 3 all arrive with aligned lengths. EventBlock 4 arrives with an unaligned length. Until more data arrives on the stream, none of the events in EventBlock 4 will be dispatched to the user.
This change adds a configuration switch for changing the alignment of the reader. The default is the old behavior (8 byte alignment) and the live reading for EventPipe was changed to 1 byte alignment.
Changing to an alignment of 1 uncovered a bug where calling
Goto(StreamLabel)
with a label greater than the alignment length would cause the subsequent read to return bytes from the wrong position in the stream. Up until now, this wasn't an issue for EventPipe because allGoto
calls were for jumps < 4 due to the internal alignment, which is always less than 8.This patch also fixes that bug.
TODO: tag all the issues this will close. I believe there are issues in dotnet/runtime, dotnet/diagnostics, dotnet/dotnet-monitor, and microsoft/perfview that are tracking this issue.
CC @tommcdon @jander-msft @wiktork