-
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
Pool the simplifiers we use when simplifying code. #19424
Conversation
@@ -178,89 +178,92 @@ protected virtual SyntaxNode TransformReducedNode(SyntaxNode reducedNode, Syntax | |||
{ | |||
var nodeOrTokenToReduce = nodesAndTokensToReduce[i]; | |||
simplifyTasks[i] = Task.Run(async () => | |||
{ | |||
var nodeOrToken = nodeOrTokenToReduce.OriginalNodeOrToken; |
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.
All this code stays the same. it just got indented. I will point out what actually changed.
} | ||
using (var rewriter = reducer.GetOrCreateRewriter()) | ||
{ | ||
rewriter.Initialize(optionSet, cancellationToken); |
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.
these three lines are new. We now get a potentially pooled rewriter, and we initialize it with the current state.
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.
Everything else in this file is just indentation.
Tagging @MattGertz This lowered the amount of garbage i saw produced in a 'simplify all' scenario by several hundred MB on a large project. This was specifically where i marked the root of a document with the Simplification annotation and went and looked for all things that could be simplified. The saving comes in two forms:
|
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.Options; | ||
using Microsoft.CodeAnalysis.Simplification; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Simplification |
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.
❕ Namespace should be updated to reflect new location
This is a followup to #19419