Skip to content

Remove the AnalyzerManager singleton to prevent storing analyzer exec…#20109

Merged
mavasani merged 6 commits intodotnet:dev15.6from
mavasani:AnalyzerContext
Jun 16, 2017
Merged

Remove the AnalyzerManager singleton to prevent storing analyzer exec…#20109
mavasani merged 6 commits intodotnet:dev15.6from
mavasani:AnalyzerContext

Conversation

@mavasani
Copy link
Contributor

@mavasani mavasani commented Jun 8, 2017

…ution state across compilations

Now we throw away all the analyzer execution state once the CompilationWithAnalyzers goes out of scope.

…ution state across compilations

Now we throw away all the analyzer execution state once the CompilationWithAnalyzers goes out of scope.
@mavasani mavasani added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jun 8, 2017
@mavasani mavasani requested a review from heejaechang June 8, 2017 18:29
@mavasani mavasani requested a review from jinujoseph June 8, 2017 18:30
// This map stores the tasks to compute HostCompilationStartAnalysisScope for per-compilation analyzer actions, i.e. AnalyzerActions registered by analyzer's CompilationStartActions.
// Compilation start actions will get executed once per-each AnalyzerAndOptions as user might want to return different set of custom actions for each compilation/analyzer options.
private Dictionary<AnalyzerOptions, ConditionalWeakTable<Compilation, Task<HostCompilationStartAnalysisScope>>> _lazyCompilationScopeMap;
private readonly Dictionary<AnalyzerOptions, Task<HostCompilationStartAnalysisScope>> _compilationScopeMap;
Copy link
Contributor

@heejaechang heejaechang Jun 8, 2017

Choose a reason for hiding this comment

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

I believe AnalyzerManager is per compilationWithAnalyzer now which is for one compilation meaning AnalyzerOption will be same for all? we might not need this map anymore? #Resolved

Copy link
Contributor Author

@mavasani mavasani Jun 8, 2017

Choose a reason for hiding this comment

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

Hmm given that each CompilationWithAnalyzers instance will create a new cloned compilation with a new event queue, your claim seems to be correct. Let me cleanup a bit more. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// This cache stores the analyzer execution context per-analyzer (i.e. registered actions, supported descriptors, etc.).
private readonly ConditionalWeakTable<DiagnosticAnalyzer, AnalyzerExecutionContext> _analyzerExecutionContextMap =
new ConditionalWeakTable<DiagnosticAnalyzer, AnalyzerExecutionContext>();
private readonly Dictionary<DiagnosticAnalyzer, AnalyzerExecutionContext> _analyzerExecutionContextMap =
Copy link
Contributor

@heejaechang heejaechang Jun 8, 2017

Choose a reason for hiding this comment

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

concurrent dictionary and remove the lock? or just create whole map in immutable map at once might better? since this seems get called many times? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mavasani
Copy link
Contributor Author

mavasani commented Jun 9, 2017

Test failure: https://ci.dot.net/job/dotnet_roslyn/job/dev15.6/job/windows_debug_unit32_prtest/176/

xunit produced no error output but had exit code 1

@mavasani
Copy link
Contributor Author

mavasani commented Jun 9, 2017

@dotnet-bot retest windows_debug_unit32_prtest please

@mavasani mavasani added Area-Analyzers Area-Compilers and removed PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. labels Jun 9, 2017
@mavasani
Copy link
Contributor Author

mavasani commented Jun 9, 2017

Tagging @dotnet/roslyn-analysis @dotnet/roslyn-compiler for review. This change is a follow up cleanup change to #20096

/// Gets the default instance of the AnalyzerManager for the lifetime of the analyzer host process.
/// </summary>
public static readonly AnalyzerManager Instance = new AnalyzerManager();
private readonly object _gate = new object();
Copy link
Member

@jcouv jcouv Jun 12, 2017

Choose a reason for hiding this comment

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

Is this used? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, not after the refactoring in the last commit. Thanks, will remove.

@jcouv
Copy link
Member

jcouv commented Jun 12, 2017

public class TestDiagnosticAnalyzerDriver : IDisposable

Should we remove IDisposable, since Dispose does nothing? #Resolved


Refers to: src/EditorFeatures/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs:17 in 67ad810. [](commit_id = 67ad810, deletion_comment = False)

/// It clears the cached internal state (supported descriptors, registered actions, exception handlers, etc.) for analyzers.
/// </summary>
/// <param name="analyzers">Analyzers whose state needs to be cleared.</param>
[Obsolete("This API is no longer required to be invoked. Analyzer state is automatically cleaned up when CompilationWithAnalyzers instance is released.")]
Copy link
Member

Choose a reason for hiding this comment

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

FYI @jaredpar @gafter for public API change (marking as obsolete).

_analyzerExecutionContextMap = CreateAnalyzerExecutionContextMap(SpecializedCollections.SingletonEnumerable(analyzer));
}

private ImmutableDictionary<DiagnosticAnalyzer, AnalyzerExecutionContext> CreateAnalyzerExecutionContextMap(IEnumerable<DiagnosticAnalyzer> analyzers)
Copy link
Member

@jcouv jcouv Jun 12, 2017

Choose a reason for hiding this comment

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

ImmutableArray instead of IEnumerable for analyzers?
Can this method be made static? #ByDesign

Copy link
Member

Choose a reason for hiding this comment

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

Hum, the singleton case may fit better with IEnumerable (than ImmutableArray). Ignore that comment.


In reply to: 121486170 [](ancestors = 121486170)

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jun 12, 2017

Done with review pass. #Closed

@mavasani
Copy link
Contributor Author

public class TestDiagnosticAnalyzerDriver : IDisposable

Done.


In reply to: 307869813 [](ancestors = 307869813)


Refers to: src/EditorFeatures/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs:17 in 67ad810. [](commit_id = 67ad810, deletion_comment = False)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM

namespace Microsoft.CodeAnalysis.UnitTests.Diagnostics
{
public class TestDiagnosticAnalyzerDriver : IDisposable
public class TestDiagnosticAnalyzerDriver
Copy link
Contributor

Choose a reason for hiding this comment

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

public class TestDiagnosticAnalyzerDriver [](start = 4, length = 41)

Isn't removal of the interface a breaking change? The class is public, some clients could implicitly convert it to IDisposable, which is going to be an error now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a test only type though. If we want to preserve API for test types, I can revert it. @jcouv @gafter?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I don't think test types are part of our public/supported API.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a test only type though

Sorry, missed this part.

@AlekseyTs
Copy link
Contributor

Done with review pass.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM

@mavasani
Copy link
Contributor Author

@dotnet/roslyn-infrastructure I thought the VS integration tests are currently failing, and hence we are allowed to merge without requiring them to pass. However, merging the pull request still seems to be blocked on these tests.

@jaredpar
Copy link
Member

@mavasani the underlying problem with the VS integration tests was fixed yesterday afternoon. Hence the tests are required again.

@jaredpar
Copy link
Member

retest windows_debug_vs-integration_prtest please

@jaredpar
Copy link
Member

retest windows_release_vs-integration_prtest please

@mavasani
Copy link
Contributor Author

Thanks @jaredpar. The Debug integration test failed with following output:

System.Management.Automation.RuntimeException: Command failed to execute: C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\15.0\Bin\msbuild.exe /warnaserror /nologo /m /nodeReuse:false /consoleloggerparameters:Verbosity=minimal /filelogger /fileloggerparameters:Verbosity=normal /p:BootstrapBuildPath=D:\j\workspace\windows_debug---1522b458\Binaries\Bootstrap BuildAndTest.proj /p:Configuration=Debug /p:Test64=false /p:TestVsi=true /p:TestDesktop=False /p:TestCoreClr=False /p:TestVsiNetCore=false /p:PathMap=D:\j\workspace\windows_debug---1522b458=q:\roslyn /p:Feature=pdb-path-determinism /fileloggerparameters:LogFile=D:\j\workspace\windows_debug---1522b458\Binaries\Build.log;verbosity=diagnostic /p:DeployExtension=false /p:RoslynRuntimeIdentifier=win7-x64 /p:DeployExtensionViaBuild=False /p:TreatWarningsAsErrors=true /p:ProcDumpDir=c:\SysInternals

@mavasani
Copy link
Contributor Author

retest windows_debug_vs-integration_prtest please

@jasonmalinowski
Copy link
Member

Actually, I only disabled the requirement in master, but didn't do it here. 😦

@mavasani
Copy link
Contributor Author

@jasonmalinowski @jaredpar - The debug integration test job is consistently failing with the same error as above on branches other then master. See https://ci.dot.net/job/dotnet_roslyn/job/dev15.6/job/windows_debug_vs-integration_prtest/260/ for this PR (dev15.6 branch) and also the failure for #20177 (features/ioperation branch)

@ivanbasov
Copy link
Contributor

Please ignore integration tests for a while.

@mavasani
Copy link
Contributor Author

mavasani commented Jun 14, 2017

@ivanbasov - Merge pull request is still disabled for dev15.6 branch, can we remove this requirement?

@ivanbasov
Copy link
Contributor

I think, yes: we should disable integration tests in 15.6 too for a while. @jaredpar, @jasonmalinowski to confirm.

If yes, will it be enough to cherry-pick #20216, once it will be merged to master?

@jasonmalinowski
Copy link
Member

And to your second question: yes. I'd just have @jimmy9988 do the merge as he'll be doing that flow anyways.

@mavasani
Copy link
Contributor Author

@ivanbasov I am still blocked on VSI failures for this PR. Please advise how to get this through.

@ivanbasov
Copy link
Contributor

@jimmy9988 could you please help with the merge? We have integration tests optional in master. We even have them passed in master.

@enshuoh
Copy link

enshuoh commented Jun 15, 2017

I already merged the fix #20216 to dev15.6 in #20234.

@mavasani
Copy link
Contributor Author

@dotnet retest windows_debug_vs-integration_prtest please

@mavasani
Copy link
Contributor Author

@dotnet-bot retest windows_release_vs-integration_prtest please

@mavasani
Copy link
Contributor Author

retest this please

@mavasani
Copy link
Contributor Author

@dotnet-bot retest windows_debug_vs-integration_prtest please

@mavasani
Copy link
Contributor Author

@dotnet-bot retest windows_release_vs-integration_prtest please

@mavasani
Copy link
Contributor Author

@dotnet/roslyn-infrastructure Seems like dev15.6 is in broken state:

Type of conditional expression cannot be determined because there is no implicit conversion between 'UserOperationBooster' and '' [D:\j\workspace\windows_build---d2995bb3\src\Workspaces\Remote\ServiceHub\ServiceHub.csproj]

Are we fixing this soon? Is there any commit I can cherry-pick from master to fix it?

@enshuoh
Copy link

enshuoh commented Jun 16, 2017

@mavasani Yes. Cyrus changed a type to struct in master which is used in 15.6. This change brought from master breaks 15.6. @heejaechang is working on this.

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.

9 participants