Analyzer driver perf optimization#38793
Conversation
src/Compilers/CSharp/Test/Semantic/Diagnostics/DiagnosticAnalyzerTests.cs
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
Outdated
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
Outdated
Show resolved
Hide resolved
|
Have you performed any perf analysis on this change? |
I have verified that build time improves in presence of top level suppression entries (at repo root) for some expensive DFA analyzers. Previously, we executed all callbacks for these analyzers, but now we just do the initialization. |
Have you measured if there is an effect on the compile time when no analyzers are suppressed? |
I did not measure that. I can do it today. |
|
@mavasani I just completed some perf tests for analyzer testing. I can run them for you on this PR if you want |
Great, that would be very helpful! Thanks. |
|
Got the perf numbers. The timing doesn't seem particularly different, within noise thresholds on my machine, but the allocation numbers are a little worrying. Without this change we allocate 1.48 GB, with it we allocate 1.54 GB. I think this is worth looking at traces to see what's causing such a big jump. |
|
@agocke Thanks. Would you be able to share both the before and after traces? |
|
The benchmark by default doesn't gather traces, so I don't have any at the moment. You should be able to generate them yourself though by following the instructions at https://github.com/dotnet/roslyn/wiki/Measuring-Compiler-Performance and passing an extra |
|
@agocke I repeated your perf testing and confirmed the allocation jump with the commits in this PR - thanks, the benchmarks are really handy. I have pushed an additional commit that brings down the allocations back to original for my local testing. Perf numbers from my 3 test runs:
|
agocke
left a comment
There was a problem hiding this comment.
Great! I'm glad the benchmarks were helpful. New numbers LGTM
|
@agocke Is there plan to make these benchmarks run by default on all PRs, or atleast the ones that touch the compiler code? |
|
@mavasani Unfortunately VMs are way too flaky and we don't have physical machines. Maybe Helix will change this in the future. |
This change optimizes the analyzer driver to avoid redundant analyzer callbacks in presence of source file based suppressions to improve the overall performance for analyzer execution. Current editorconfig design allows user to configure diagnostic severities for specific source file(s). If user has suppressed all diagnostics that an analyzer can report on a specific file then executing the analyzer on such a file is redundant and can be avoided by the driver, except for the below cases: