Closed TimothyMakkison closed 9 months ago
Awesome work! In my experimental branch I think I removed the Roslyn38 project, was trying to simplify. Do you know what version of the SDK is needed for 4.1?
Thanks for the review, I'll resolve the issues when I have more time over the weekend 👍
I must admit I don't understand all these Roslyn APIs related to incremental compilation
TLDR, each step in a incremental generator (Select
, Where
, SelectMany
), caches the input and output of the previous runs step. By using a custom comparer or object implementing IEquality
we can use this behaviour to skip a section of the pipeline if the input object is the same as the last run.
In roslyn equivalent syntax (ie SyntaxNode
, InvocationExpressionSyntax
) is the same between runs whereas each compilation object will always be different between runs (ITypeSymbol
, ISymbol
, Compilation
) and should not be cached for both performance and logic reasons.
In our case I created a parse step that produces a cacheable object, this lets us skip the output stage.
Thanks! Makes sense
Happy new years and thanks for the review, I think I've made all the relevant changes 👍
TryParseConfiguration
to before the array declarationRequestMessageHandlerWrapper
is still a little janky. My ide doesn't show linting if the file is in the Models
folder, but will lint and show references when moved out. Still no idea why this is happening. It still occurs on a different computer with a fresh install 😩SnapshotTests
. Should I add them in this pr or a different one? This pr is getting a little bloated.~ See #135Edit: just ran the benchmarks and got drastically different results to yours. Moving TryParseConfiguration doesn't cause this as I get the same results when they are moved back. |
Method | Mean | Error | StdDev | Median | Gen 0 | Gen 1 | Allocated |
---|---|---|---|---|---|---|---|---|
Cached | 5.296 ms | 0.0548 ms | 0.0512 ms | 5.299 ms | 507.8125 | 156.2500 | 5 MB | |
Compile | 7.333 ms | 0.3460 ms | 0.9982 ms | 6.686 ms | 593.7500 | 203.1250 | 6 MB | |
LargeCached | 70.923 ms | 0.4671 ms | 0.4141 ms | 70.743 ms | 3875.0000 | 1500.0000 | 36 MB | |
LargeCompile | 134.006 ms | 0.8707 ms | 0.8144 ms | 134.052 ms | 7500.0000 | 2500.0000 | 83 MB |
Modify
CompilationAnalyzer
to return an equatable model, skipping the final build and emit stage, improving performance and making the IDE more responsive.CompilationAnalyzer
.CompilationModel
converting types into equivalent structurally equatable types.CompilationModel
and skip the emit stage in the future if nothing changes.Note that I had to add
Mediator.SourceGenerator.Roslyn41
to useWithTrackingName
for the tests. This is pretty fragile as changes toMediator.SourceGenerator.Roslyn40
will not be detected by the tests. This could be solved with compile constant preproccessor sections, although I'm not confident I can add this.