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

Use PooledArrayBuilder<SyntaxToken> throughout parsers and tokenizer #10095

Merged
merged 6 commits into from Mar 22, 2024

Conversation

DustinCampbell
Copy link
Member

@ToddGrun shared a couple PerfView stacks with me where the Razor compiler was allocating List<SyntaxToken> instances in the tokenizer. To remove those allocation, this change replaces List<SyntaxToken>s throughout the parsers and tokenizer, and uses PooledArrayBuilder<SyntaxToken> instead. In addition, I removed a couple of Concat calls and replaced them with pooled StringBuilders.

This change avoids allocating List<T>'s throughout the parsers and
tokenizer, and usese pooled lists instead.
@DustinCampbell DustinCampbell requested review from a team as code owners March 13, 2024 21:45
@ryzngard
Copy link
Contributor

@ToddGrun shared a couple PerfView stacks with me where the Razor compiler was allocating List<SyntaxToken> instances in the tokenizer. To remove those allocation, this change replaces List<SyntaxToken>s throughout the parsers and tokenizer, and uses PooledArrayBuilder<SyntaxToken> instead. In addition, I removed a couple of Concat calls and replaced them with pooled StringBuilders.

❓is yardstick still a thing? does it capture these?

@ToddGrun
Copy link
Contributor

Found in the completion speedometer test

image

image

@DustinCampbell
Copy link
Member Author

❓is yardstick still a thing? does it capture these?

Yardstick is still a thing. What it really does is run PerfView with a set of good defaults for Visual Studio, does a bunch of analysis over the results, and produces a text report. In particular, I've found the CaptureMeasurements.bat included with it to be particularly useful. It launches PerfView with a bunch of event trace sources enabled for VS, like StreamJsonRpc and MSBuild.

@ryzngard
Copy link
Contributor

❓is yardstick still a thing? does it capture these?

Yardstick is still a thing. What it really does is run PerfView with a set of good defaults for Visual Studio, does a bunch of analysis over the results, and produces a text report. In particular, I've found the CaptureMeasurements.bat included with it to be particularly useful. It launches PerfView with a bunch of event trace sources enabled for VS, like StreamJsonRpc and MSBuild.

Oh yea, I just meant I generally enjoy the amount of warnings/errors it gave on finding things that are probably bad. I was hoping if you ran it on this speedometer etl it would just be like "Hey, don't do that please"

@DustinCampbell
Copy link
Member Author

Oh yea, I just meant I generally enjoy the amount of warnings/errors it gave on finding things that are probably bad. I was hoping if you ran it on this speedometer etl it would just be like "Hey, don't do that please"

@ToddGrun is my yard stick. 😄

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally seems fine to me, but it does seem like ref readonly would be better in a few places than in here.

@DustinCampbell DustinCampbell merged commit d4a6aaa into dotnet:main Mar 22, 2024
12 checks passed
@DustinCampbell DustinCampbell deleted the fix-list-alloc branch March 22, 2024 15:53
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Mar 22, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.10 P3 Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants