-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Don't generate a nearly empty file #76835
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
Don't generate a nearly empty file #76835
Conversation
|
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsWhen generators are running in the Visual Studio IDE, there's some overhead to having to manage a project that actually has generated output. It requires us to maintain two Roslyn Compilation objects, each which have their own symbol information. These interop generators are producing a file that's effectively empty (just an comment on the top), and since they're installed in all .NET 7.0 applications, they are the reason we'll be having to manage more memory than before. Since the fix is simple enough to only generate the output if necessary, we should do so. This also will help with telemetry, since we have telemetry that lets us tracking in the wild which generators are producing how many files; if we're always producing exactly one file we won't know how many sessions out there are actually using this generator in a meaningful way.
|
AaronRobinsonMSFT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
@pavelsavara I think we might also need a fix in the JavaScript interop source generator, right? |
|
@AaronRobinsonMSFT: as far as I can tell, this is a common helper used for everything, but unless there's another copy somewhere else I don't know about? |
|
Marking as draft since I presume this broke some tests, but I don't know where they are yet. |
jkoritzinsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I believe the JS generator uses the same extension methods to build out the generated sources, so this should cover the JS generators as well.
|
@jkoritzinsky @AaronRobinsonMSFT I assumed this would have broken a test somewhere but I guess there's no negative test asserting no files are produced if nothing is needed. Where should one be added? |
Likely not. I think the most appropriate place would be after the following tests or integrated into them. These are confirming we compile even though Lines 644 to 671 in 6556178
|
|
I think integrating with the one Aaron pointed at makes sense. I would:
|
When generators are running in the Visual Studio IDE, there's some overhead to having to manage a project that actually has generated output. It requires us to maintain two Roslyn Compilation objects, each which have their own symbol information. These interop generators are producing a file that's effectively empty (just an <auto-generated> comment on the top), and since they're installed in all .NET 7.0 applications, they are the reason we'll be having to manage more memory than before. Since the fix is simple enough to only generate the output if necessary, we should do so. This also will help with telemetry, since we have telemetry that lets us tracking in the wild which generators are producing how many files; if we're always producing exactly one file we won't know how many sessions out there are actually using this generator in a meaningful way.
9ec995c to
7518228
Compare
|
@jkoritzinsky @AaronRobinsonMSFT @elinor-fung Test added, so this would need a small re-review. Otherwise I think it's ready to go? |
|
/backport to release/7.0 |
|
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3277608142 |
When generators are running in the Visual Studio IDE, there's some overhead to having to manage a project that actually has generated output. It requires us to maintain two Roslyn Compilation objects, each which have their own symbol information. These interop generators are producing a file that's effectively empty (just an comment on the top), and since they're installed in all .NET 7.0 applications, they are the reason we'll be having to manage more memory than before. Since the fix is simple enough to only generate the output if necessary, we should do so.
This also will help with telemetry, since we have telemetry that lets us tracking in the wild which generators are producing how many files; if we're always producing exactly one file we won't know how many sessions out there are actually using this generator in a meaningful way.
Fixes #76298