Cap the amount of text copied into the stringbuilder in JsonRpcEventSource.Format#1187
Merged
AArnott merged 1 commit intomicrosoft:mainfrom May 7, 2025
Conversation
…ource.Format Speedometer test shows two LOH allocations occurring in this method when opening a large cs file, when the value passed into the method is a JsonDocument. 1) The ToString call on the document 2) pushing the results of the ToString call into the StringBuilder It would be non-trivial to get rid of the first allocation, however, the second can be removed by just calling the StringBuilder.AppendOverload that takes in a range from the given string to copy into the StringBuilder.
AArnott
approved these changes
May 7, 2025
Member
AArnott
left a comment
There was a problem hiding this comment.
Thanks.
I don't anticipate a runtime perf benefit because this code only runs when an ETW trace is collected that specifies the streamjsonrpc ETW provider explicitly. Still, it may make our perf runs a little faster and a little more 'true' to customer perception.
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Jan 22, 2026
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.
Speedometer test shows two LOH allocations occurring in this method when opening a large cs file, when the value passed into JsonRpcEventSource.Format is a JsonDocument.
It would be non-trivial to get rid of the first allocation, however, the second can be removed by just calling the StringBuilder.Append overload that takes in a range from the given string to copy into the StringBuilder.
Here's is the allocation from the speedometer test that this is attempting to improve: