-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Change SyntaxEquivalence.AreEquivalent to use a more appropriate pooling mechanism for the stack it uses to walk trees. #74610
Conversation
…ing mechanism for the stack it uses to walk trees. The scrolling speedometer test indicates this method's pooling mechanism isn't working great for large files. Specifically, ArrayBuilder instances aren't returned to their pool once their length exceeds 128 items. For even relatively large files, I'm seeing this exceeded in this context. Instead, I've switched this code to just use a pooled Stack. This was accounting for about 1.1% of allocations in the typing scenario for the scrolling speedometer test.
tests failing, need to investigate |
…ance that it won't be empty
Duh. There's a code path where the stack isn't null when hitting the finally, so it needs to be cleared before being placed back in the pool. In reply to: 2259388249 |
@@ -117,7 +121,8 @@ private static bool AreEquivalentRecursive(GreenNode? before, GreenNode? after, | |||
} | |||
finally | |||
{ | |||
stack.Free(); | |||
stack.Clear(); | |||
s_equivalenceCheckStack.Free(stack); |
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.
is there not FreeAndClear/ClearAndFree?
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.
That's defined at the workspace level
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.
well that's silly :)
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.
I would be fine to move that down if you wanted.
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.
Though I will point out that those helpers stop returning pooled objects after they get to 512 items. That might not work well here either.
@dotnet/roslyn-compiler -- ready for review |
@dotnet/roslyn-compiler for 2nd review |
The scrolling speedometer test indicates this method's pooling mechanism isn't working great for large files. Specifically, ArrayBuilder instances aren't returned to their pool once their length exceeds 128 items. For even relatively large files, I'm seeing this exceeded in this context.
Instead, I've switched this code to just use a pooled Stack. This was accounting for about 1.1% of allocations in the typing scenario for the scrolling speedometer test.
*** relevant allocations from the typing scenario in the scrolling speedometer test ***