Add configurable alignment to FastSerializer#1560
Merged
brianrob merged 6 commits intomicrosoft:mainfrom Feb 3, 2022
Merged
Conversation
* 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
Co-authored-by: Noah Falk <noahfalk@users.noreply.github.com>
brianrob
reviewed
Jan 28, 2022
brianrob
reviewed
Jan 28, 2022
Member
brianrob
left a comment
There was a problem hiding this comment.
Overall, LTGM. A couple of small things.
added 2 commits
January 28, 2022 10:02
…om:josalem/perfview into dev/josalem/allow-unaligned-stream-reading
brianrob
approved these changes
Feb 3, 2022
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.
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 allGotocalls 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