-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Reduce allocations in the C# lexer ctor #76544
base: main
Are you sure you want to change the base?
Conversation
The lexer ctor shows as about 0.5% of all allocations over the lifetime of the RoslynCodeAnalysisProcess in the csharp editing speedometer tests. There was already the concept of the LexerCache which had some pooling usage in it. This PR moves a couple other members to it to allow for their pooling. This PR is going to be marked as a draft PR until I can get some data from a test insertion indicating whether these changes improve allocations in the speedometer tests.
Test insertion: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/599798 |
Speedometer results look promising, going to promote out of draft mode. Allocations under Lexer.*ctor in IncPaths: |
@dotnet/roslyn-compiler -- ptal |
src/Compilers/Core/Portable/Syntax/InternalSyntax/SyntaxListBuilder.cs
Outdated
Show resolved
Hide resolved
Done with review pass (commit 1) |
@AlekseyTs -- changes made based on your commit 1 pass suggestions |
Done with review pass (commit 2) |
This has changed enough since the first commit where I ran a test insertion that I will run one again (once Aleksey has signed off) just to make sure the numbers still look good. |
Done with review pass (commit 3) |
…ng something out in this area and forgot to revert that change)
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 (commit 4)
Test insertion for speedometer results of commit 4: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/600635 |
Allocations under the lexer still look improved with latest test insertion. @dotnet/roslyn-compiler for 2nd review. Thanks! |
The lexer ctor shows as about 0.6% of all allocations over the lifetime of the RoslynCodeAnalysisProcess in the csharp editing speedometer tests.
There was already the concept of the LexerCache which had some pooling usage in it. This PR moves a couple other members to it to allow for their pooling.
Speedometer results look quite promising:
Allocations under Lexer.ctor in IncPaths reduced from 60 MB to 1.5 MB
Allocations under Lexer in IncPaths reduced from 1.57 GB to 1.36 GB