Open mthjones opened 3 years ago
There is some indication that switching to IOperation
-based analyzers may significantly improve performance: https://github.com/dotnet/roslyn/pull/46349
At least some of the perf issues may stem from the reason this diagnostic exists. We use Compilation.GetSemanticModel
in the two slowest analyzers in D2L.CodeStyle.Analyzers and the slowest one in D2L.CodeStyle.TestAnalyzers.
May be worth investigating if these can be replaced with one of the suggestions provided.
Including these analyzers in the build causes a significant performance hit. In one solution, the performance hit is a ~50% increase in build time (a ~100% increase in csc.exe time).
Breakdown of time spent in analyzers from this package (from building with
ReportAnalyzer=true
):D2L.CodeStyle.Analyzers
``` 1:06.961 D2L.CodeStyle.Analyzers, Version=0.157.0.0, Culture=neutral, PublicKeyToken=null D2L.CodeStyle.Analyzers.Immutability.ImmutabilityAnalyzer = 13.889 s D2L.CodeStyle.Analyzers.ApiUsage.ServiceLocator.OldAndBrokenServiceLocatorAnalyzer = 11.500 s D2L.CodeStyle.Analyzers.ApiUsage.DangerousMemberUsages.DangerousMemberUsagesAnalyzer = 10.690 s D2L.CodeStyle.Analyzers.Immutability.ReadOnlyParameterAnalyzer = 6.052 s D2L.CodeStyle.Analyzers.ApiUsage.ConstantAttributeAnalyzer = 5.727 s D2L.CodeStyle.Analyzers.ApiUsage.Events.EventPublisherEventTypesAnalyzer = 3.483 s D2L.CodeStyle.Analyzers.ApiUsage.Events.EventHandlerLoaderTypesAnalyzer = 3.042 s D2L.CodeStyle.Analyzers.ApiUsage.Configs.ConfigViewerAnalyzer = 2.804 s D2L.CodeStyle.Analyzers.Language.DefaultValueConsistencyAnalyzer = 1.951 s D2L.CodeStyle.Analyzers.Language.RequireNamedArgumentsAnalyzer = 1.816 s D2L.CodeStyle.Analyzers.Immutability.StatelessFuncAnalyzer = 1.017 s D2L.CodeStyle.Analyzers.ApiUsage.Events.EventHandlersDisallowedListAnalyzer = 931 ms D2L.CodeStyle.Analyzers.ApiUsage.ServiceLocator.SingletonLocatorAnalyzer = 710 ms D2L.CodeStyle.Analyzers.ApiUsage.DependencyInjection.DependencyRegistrationsAnalyzer = 706 ms D2L.CodeStyle.Analyzers.ApiUsage.LaunchDarkly.FeatureDefinitionAnalyzer = 644 ms D2L.CodeStyle.Analyzers.ApiUsage.Logging.LoggingExecutionContextScopeBuilderAnalyzer = 590 ms D2L.CodeStyle.Analyzers.ApiUsage.Events.EventTypesAnalyzer = 576 ms D2L.CodeStyle.Analyzers.ApiUsage.Serialization.SerializerAttributeAnalyzer = 511 ms D2L.CodeStyle.Analyzers.ApiUsage.SystemCollectionsImmutable.ImmutableCollectionsAnalyzer = 164 ms D2L.CodeStyle.Analyzers.Contract.NotNullAnalyzer = 54 ms D2L.CodeStyle.Analyzers.ApiUsage.JsonParamBinderAttribute.JsonParamBinderAnalyzer = 24 ms D2L.CodeStyle.Analyzers.Language.StructShouldBeReadonlyAnalyzer = 7 ms D2L.CodeStyle.Analyzers.Language.AwaitedTasksAnalyzer = 5 ms D2L.CodeStyle.Analyzers.Build.MandatoryReferencesAnalyzer = 2 ms D2L.CodeStyle.Analyzers.ApiUsage.ContentPhysicalPaths.ILegacyLpContentDirectoryFullNameAnalyzer = 0 ms D2L.CodeStyle.Analyzers.ApiUsage.ContentPhysicalPaths.ILegacyLpContentFilePhysicalPathAnalyzer = 0 ms D2L.CodeStyle.Analyzers.ApiUsage.ContentPhysicalPaths.ILpContentFilePhysicalPathAnalyzer = 0 ms D2L.CodeStyle.Analyzers.ApiUsage.RpcAnalyzer = 0 ms D2L.CodeStyle.Analyzers.Language.ClassShouldBeSealedAnalyzer = 0 ms ```D2L.CodeStyle.TestAnalyzers
``` 8.914 s D2L.CodeStyle.TestAnalyzers, Version=0.25.0.0, Culture=neutral, PublicKeyToken=null D2L.CodeStyle.TestAnalyzers.ServiceLocator.CustomTestServiceLocatorAnalyzer = 3.176 s D2L.CodeStyle.TestAnalyzers.NUnit.ConfigTestSetupStringsAnalyzer = 2.433 s D2L.CodeStyle.TestAnalyzers.NUnit.TestAttributeAnalyzer = 1.036 s D2L.CodeStyle.TestAnalyzers.NUnit.TestCaseSourceStringsAnalyzer = 913 ms D2L.CodeStyle.TestAnalyzers.NUnit.CategoryAnalyzer = 905 ms D2L.CodeStyle.TestAnalyzers.NUnit.ValueSourceStringsAnalyzer = 436 ms ```