Skip to content
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

[ActivityInfo] Avoid writing extra byte by updating length #109132

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Oct 22, 2024

Fixes #109078

It was discovered that in some scenarios, the ActivityTracker.AddIdToGuid method's optimization logic fails to update the number of encoded bytes counter for (0xFF, 0xFFF] IDs. As a result, an extra 0x00 byte is encoded in the Guid, which is interpreted as the end of the list.

This PR updates the len variable accordingly, so only one byte is written after bundling the (0xFF, 0xFFF] ID's 4 high order bits into the multicode indicating byte.

Before
1/4/2000/1 -> 14 c7 d0 00 10

After
1/4/2000/1 -> 14 c7 d0 10

@mdh1418
Copy link
Member Author

mdh1418 commented Oct 22, 2024

It seems like the GUID optimization logic (squeeze as much info into as few bits as possible by coupling an odd-numbered nibble Id's highest order nibble with the multicode indicator nibble) only occurs for IDs in [0x0, 0xF] u (0xFF, 0xFFF], but not for (0xFFFF, 0xFFFFF].

Is it worth extending the optimization to (0xFFFF, 0xFFFFF] Ids or do Ids not reach those values?

@noahfalk
Copy link
Member

Is it worth extending the optimization to (0xFFFF, 0xFFFFF] Ids or do Ids not reach those values?

I wouldn't worry about extending it further. I don't recall ever seeing a complaint related to it and if we did extend it that would break compat with PerfView's decoding of the current scheme.

@mdh1418 mdh1418 merged commit 0c9fc16 into dotnet:main Oct 23, 2024
142 of 146 checks passed
@mdh1418 mdh1418 deleted the fix_activity_info_path_guid_encoding branch October 23, 2024 13:47
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants