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

Add a cache for AnalyzerConfigSets #46740

Merged
1 commit merged into from
Aug 14, 2020

Conversation

jasonmalinowski
Copy link
Member

@jasonmalinowski jasonmalinowski commented Aug 12, 2020

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.


public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath)
{
return _cache.GetOrAdd(sourcePath, _computeFunction);
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.
@jasonmalinowski jasonmalinowski marked this pull request as ready for review August 13, 2020 22:05
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner August 13, 2020 22:05
@jasonmalinowski jasonmalinowski self-assigned this Aug 14, 2020
@ghost
Copy link

ghost commented Aug 14, 2020

Hello @jasonmalinowski!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit c56c421 into dotnet:release/dev16.8 Aug 14, 2020
@jasonmalinowski jasonmalinowski deleted the add-editorconfig-cache branch August 14, 2020 04:22
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants