-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental generator shouldn't include symbols in the pipeline #833
Comments
Thanks for the tip @Youssef1313!
Could you give an example what this looks like, or, even better, open a PR? I'm admittedly not a Source Generator expert and don't fully grasp your recommendations. But I'm excited to learn more! |
And will this be a performance improvement,a memory improvement or a syntax/code/best practices improvement? |
@brminnick The discussion in dotnet/roslyn-analyzers#6352 is quite detailed. From dotnet/roslyn-analyzers#6352 (comment):
There also should be a performance improvement. |
I would like to see a benchmark before changing this. I tested it before moving forward and the SG keeps its incremental behavior. It's true that having symbols will break the Incremental behavior, but just if it gets inside the |
See dotnet/roslyn-analyzers#6352 (comment)
|
@Youssef1313 Could you provide the data/charts/benchmark etc. that demonstrates that we have broken incrementallity in our Source Generator? I'd like to better understand the performance impact of our current implementation versus your recommended improvement. I also agree with @pictos that the next PR that changes/improves our source generator should implement this same benchmark. We'll run + verify this benchmark our CI/CD pipeline to ensure we never accidentally degrade performance in our Source Generators going forward. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 2 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. |
Not really stale. This needs an action. |
@Youssef1313 We asked you to provide info that our source generator doesn't work as expected. The last PR that I did fixed the issue and it's working better now. If you don't provide the repro we will close this |
There is really no repro needed. All explanations are in dotnet/roslyn-analyzers#6352. The compiler team clearly states that incremental generator pipeline shouldn't include symbols. This is also being followed properly in generators in CommunityToolkit/dotnet. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Thanks for confirming @Sergio0694.
Yeah, I have taken this exercise too in one of the generators in Uno Platform, and while it was a very small generator, and took me quite a bit to write it properly. |
@Youssef1313 Would you like to create a PR with the fix? |
It will be hard currently. Maybe I can take a look in a month. |
This comment was marked as outdated.
This comment was marked as outdated.
I'm sure Youssef will be able to say that, but I can guarantee you he didn't mean that to come across that way (language barrier maybe?). He's a super active member of the community that's always extremely helpful and willing to help folks out, and with lots of community contributions in Roslyn and other repos (eg. he helped in the Toolkit before as well). I read that as "let's establish that this needs an action and it's not an incorrect issue to dismiss", rather than "you have to fix this now" as a demand 🙂
This is where the confusion might be coming from. The issue we're trying to point out is that, due to how the pipeline is currently setup, you think you're generating those classes just once, when in fact the generator is doing the entire work and generating every single file again for every single keystroke currently, all the time, because the pipeline is always invalidated 😅 |
@Sergio0694, before the merge I checked if the SG was behaving as incremental... I recorded two videos in order to prove it when I was working on it. In both videos take a look on the This one is before the fix, as you will see the file is generating every time: SG_bug_for_MCT.mp4The next one is after the fix SG_Fixed.mp4 |
Sorry my bad, I was missing the last couple lines in the selector. You're correct, it will not generate all files every time as the last two steps are cached. It will still, however, re-run all previous steps for every single edit up until that point (unnecessarily), and also root compilation objects, causing them to remain in memory for longer than necessary and increase memory usage. I agree this is less critical than if it was really regenerating all files for every edit, sure. Still worth a fix, given time though 🙂 |
@Sergio0694 no need to be sorry (: , SG has a lot of details to pay attention to. |
Is there an existing issue for this?
Current Behavior
TextColorToGenerator
includes symbols inuserGeneratedClassesProvider
andmauiControlsAssemblySymbolProvider
, then filtered out ininputs
.Maui/src/CommunityToolkit.Maui.SourceGenerators/Generators/TextColorToGenerator.cs
Lines 28 to 84 in 9925e10
Expected Behavior
It's a better idea to not include symbols in the pipeline, ie, filter everything early.
Steps To Reproduce
N/A
Link to public reproduction project repository
N/A
Environment
N/A
Anything else?
dotnet/roslyn-analyzers#6352
The text was updated successfully, but these errors were encountered: