-
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
Add a cache for AnalyzerConfigSets #46740
Add a cache for AnalyzerConfigSets #46740
Conversation
src/Workspaces/Core/Portable/Workspace/Solution/CachingAnalyzerConfigSet.cs
Outdated
Show resolved
Hide resolved
|
||
public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath) | ||
{ | ||
return _cache.GetOrAdd(sourcePath, _computeFunction); |
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.
hrmm.. why not have the cachign in teh ANalyzerConfigSet itself?
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.
The compiler also calls into AnalyerConfigSet and does it's own (different) caching atop it, so I didn't want to push that right away, at least not as something we'll be taking as a hotfix.
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.
And more generally: I'm not sure if we'll want smarter caching policies here to limit memory usage, so I think we're best off keeping caching managed by the caller.
The change to move .editorconfig off of syntax trees meant that we were recomputing a bunch of information again and again, since previously the cached syntax trees implicitly acted as a cache of this data. This adds a quick cache back to avoid some extra overhead. This cache is a bit more expensive than it probably needs to be, but it's not too bad as the underlying AnalyerConfigSet has some logic to avoid recreating duplicate arrays/dictionaries of the underlying data, so much of the data is ultimately shared in the end.
ec772f5
to
7480979
Compare
Hello @jasonmalinowski! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
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.
Auto-approval
The change to move .editorconfig off of syntax trees meant that we were recomputing a bunch of information again and again, since previously the cached syntax trees implicitly acted as a cache of this data. This adds a quick cache back to avoid some extra overhead.
Ask Mode
Who is impacted by this bug?
Anybody who tries using a solution with an .editorconfig that is big enough to have scale issues. (Roslyn is notably impacted.)
Bugs Fixed
We don't have a tracking bug -- we just wrote the PR as soon as we were aware of the issue.
What is the customer scenario and impact of the bug?
If you have solutions with .editorconfigs, a bunch of features will slow down. For example, making a change in Roslyn and waiting for squiggles to show for that change is slowed down from a few seconds to almost a minute.
What is the workaround?
None.
How was the bug found?
Dogfooding.
If this fix is for a regression - what had regressed, when was the regression introduced, and why was the regression originally missed?
Insufficient testing of #44331. The original change was a performance fix for one scenario, but this regressed the perf for a different change. RPS doesn't have any scenarios where we test a solution with an .editorconfig, so the path that regressed is never tested. We are working on making such a test solution long term.
Testing
Manually verified by two different developers. Long term, an automated test is being worked on to catch this.