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

Expose metadata to mark analyzers for concurrent execution #6737

Closed
mavasani opened this issue Nov 12, 2015 · 4 comments
Closed

Expose metadata to mark analyzers for concurrent execution #6737

mavasani opened this issue Nov 12, 2015 · 4 comments
Assignees
Labels
Area-Analyzers Feature Request Tenet-Performance Regression in measured performance of the product from goals.
Milestone

Comments

@mavasani
Copy link
Contributor

[NOTE: Split from https://github.com//issues/1565, which now only tracks enabling incremental analysis for 3rd party analyzers in IDE]

This issue tracks exposing metadata from analyzers to mark them as thread-safe, such that analyzer driver will be free to make concurrent action callbacks into the analyzer instance.

@mavasani mavasani added Area-Analyzers Feature Request Tenet-Performance Regression in measured performance of the product from goals. labels Nov 12, 2015
@mavasani mavasani added this to the 1.2 milestone Nov 12, 2015
@mavasani
Copy link
Contributor Author

Possible design approaches:

  1. Expose attribute which can be applied on DiagnosticAnalyzer.
  2. Expose a property on DiagnosticDescriptor
  3. Expose an API on AnalysisContext passed into Initialize method.

@sharwell
Copy link
Member

This is a big deal for performance in large projects. 👍 I anticipate a majority of analyzers either supporting this from the start or only requiring minor updates to work with it.

@mavasani
Copy link
Contributor Author

mavasani commented Dec 2, 2015

Design team decided on approach 3.
A new API AnalysisContext.RegisterConcurrentExecution() will be added - analyzers which invoke this API might have their unrelated actions (basically all the non-start and non-end actions) invoked concurrently by the analyzer driver.

mavasani added a commit to mavasani/roslyn that referenced this issue Dec 2, 2015
…ts actions.

By default, analyzer driver never makes concurrent callbacks into a single analyzer instance. This change adds a new public API 'AnalysisContext.RegisterConcurrentExecution' to enable thread-safe analyzers to receive concurrent callbacks, which should theoretically improve performance of such analyzers for concurrent builds.

Fixes dotnet#6737
@menees
Copy link

menees commented Apr 6, 2016

The VS 2015 Update 2 announcement references this issue as "enabling Analyzer writers to mark their analyzers for concurrent execution". But it took me some digging to discover that the new API is not AnalysisContext.RegisterConcurrentExecution() as mentioned by mavasani on Dec 1 2015. The new API is actually AnalysisContext.EnableConcurrentExecution(). I wanted to point that out here to save other people some time. Currently, RegisterConcurrentExecution is only referenced in a cref comment link in roslyn-master\src\Test\Utilities\Desktop\CommonDiagnosticAnalyzers.cs, and that probably should be changed to EnableConcurrentExecution.

The Update 2 announcement also mentions "providing control over whether analyzers run in generated code". For lack of a better place to put it, here's an example of doing that: analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers Feature Request Tenet-Performance Regression in measured performance of the product from goals.
Projects
None yet
Development

No branches or pull requests

4 participants