feat: add incremental caching#113
Conversation
b75af46 to
dcd7285
Compare
|
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? |
martinothamar
left a comment
There was a problem hiding this comment.
Thanks for your patience, sorry about the delay here!
A couple of comments, otherwise this looks awesome 🥇
I must admit I don't understand all these Roslyn APIs related to incremental compilation, but you bring benchmarks (which I ran) and tests so LGTM 😄
BenchmarkDotNet=v0.13.1, OS=pop 22.04
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
.NET SDK=6.0.417
[Host] : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT
Job=InProcess Toolchain=InProcessEmitToolchain
| Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Allocated |
|---|---|---|---|---|---|---|
| Cached | 13.69 ms | 0.053 ms | 0.047 ms | 265.6250 | 78.1250 | 22 MB |
| Compile | 14.89 ms | 0.056 ms | 0.049 ms | 265.6250 | 265.6250 | 23 MB |
| LargeCached | 87.59 ms | 0.327 ms | 0.290 ms | 333.3333 | 166.6667 | 38 MB |
| LargeCompile | 154.20 ms | 0.807 ms | 0.755 ms | 750.0000 | 250.0000 | 77 MB |
src/Mediator.SourceGenerator.Implementation/Analysis/CompilationAnalyzer.cs
Show resolved
Hide resolved
src/Mediator.SourceGenerator.Implementation/Analysis/RequestMessageHandlerWrapper.cs
Show resolved
Hide resolved
src/Mediator.SourceGenerator.Implementation/Models/RequestMessageHandlerWrapperModel.cs
Outdated
Show resolved
Hide resolved
|
Thanks for the review, I'll resolve the issues when I have more time over the weekend 👍
TLDR, each step in a incremental generator ( In roslyn equivalent syntax (ie In our case I created a parse step that produces a cacheable object, this lets us skip the output stage. |
|
Thanks! Makes sense |
9f14cdd to
8cf8e4c
Compare
133af6e to
00561b7
Compare
00561b7 to
5577b6e
Compare
|
Happy new years and thanks for the review, I think I've made all the relevant changes 👍
Edit: just ran the benchmarks and got drastically different results to yours. Moving
|
martinothamar
left a comment
There was a problem hiding this comment.
finally merging this, thanks for the great work! 😄
Modify
CompilationAnalyzerto return an equatable model, skipping the final build and emit stage, improving performance and making the IDE more responsive.CompilationAnalyzer.CompilationModelconverting types into equivalent structurally equatable types.CompilationModeland skip the emit stage in the future if nothing changes.Note that I had to add
Mediator.SourceGenerator.Roslyn41to useWithTrackingNamefor the tests. This is pretty fragile as changes toMediator.SourceGenerator.Roslyn40will not be detected by the tests. This could be solved with compile constant preproccessor sections, although I'm not confident I can add this.