You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suspect that the advice will be to switch to using Operation analyzers (at least for the memberaccess and objectcreationexpression).
That should let you re-use some already bound info instead of your GetSymbolInfo calls causing the compiler to do a bunch of extra work to re-bind them.
Also look into whether we can/should exclude migration files.
@agocke suggested that the overloads taking lambdas are causing a lot of the time. Not sure how much moving to IOperation would help if the underlying binding is already taking a long time. @mavasani - any ideas?
We have had some internal teams recently move from SyntaxNode/GetSymbolInfo based analyzer implementation to IOperation based implementation and they saw 4x-5x improvement in analyzer performance. I think it would be a good change to make regardless of whether or not it completely addresses the underlying performance concern of the analysis scenario.
If the perf is still poor after skipping generated code, then consider also skipping migrations themselves. (It is possible these will be edited to use internal code, but that's not going to be common.)
So, modifying the analyzer could be useful, but the performance is still not great, even just building the code, because of the pattern of generated code.
The key thing on the analyzer side is that we're somehow avoiding re-using symbols from binding, effectively causing us to bind twice. Obviously this slows things down even more, but the underlying binding is still unfortunate. Overall on the analyzer side I'd say:
I agree they probably shouldn't be running on generated code. Something I can debug.
An analyzer model that re-uses results from binding would be helpful. I don't know offhand what the best architecture to get this result is
Looking at this comment thread 5 years later and we're facing the same problem built time on our Asp.net core 8 wep API app takes almost 2 hours. We have approximately 80 migrations.
@larrytamnjong we are not aware of any specific pending performance issues. How big are your migrations? Does everything run fast when you disable analyzers (see above)? If not, can you see which analyzers are taking how much time?
the project builds in just a few seconds. However, with migrations included, the build process becomes extremely slow—it can sometimes take over an hour and even freezes the computer. Disabling the analyzers hasn’t helped either.
We have migration files that are over 4 Mb I don't know if that's normal.
@roji is there anything else you need me to provide to be able to remedy the situation or to improve the build time of out solution with the migrations.
@larrytamnjong migration files over 4MB are generally not a good thing, and are very likely to cause pretty bad performance problems even regardless of any specific analyzer. What's the cumulative size of all of your migrations? What's the reason they're so big?
@roji I have 88 migrations, which are exactly 498 Mb in size. I don't know why they're so big. Each designer file contains migrations from all the previous migrations I don't know if that's what's causing the huge size. The migration files themselves are small a few kb but the designer files are very heavy some are reaching 6Mb
@larrytamnjong then I suggest you take a look inside and understand what it is that's causing the size; for example, you may be using HasData() to seed huge data, which is very much discouraged. Having such huge migration source files is definitely not normal, and will likely affect your project in negative ways regardless of analyzers.
Thanks @roji we are actually using HasData to seed huge data I didn't figure this could be causing the issue. I'm confused about how to fix this considering the fact we already have migrations in production. Do you have any recommendations?
FWIW the problems around using HasData with huge data is called out in the docs. Going forward, the simplest would probably be to reset your migrations, starting again from scratch without HasData. Otherwise, you can manually modify the migration files to remove all HasData.
Activity
Pilchie commentedon Oct 28, 2019
@agocke suggested that the overloads taking lambdas are causing a lot of the time. Not sure how much moving to IOperation would help if the underlying binding is already taking a long time. @mavasani - any ideas?
mavasani commentedon Oct 28, 2019
We have had some internal teams recently move from SyntaxNode/GetSymbolInfo based analyzer implementation to IOperation based implementation and they saw 4x-5x improvement in analyzer performance. I think it would be a good change to make regardless of whether or not it completely addresses the underlying performance concern of the analysis scenario.
ajcvickers commentedon Oct 28, 2019
Notes from triage:
bricelam commentedon Oct 28, 2019
Confirmed that we generate already generate this in the snapshot and code behind:
// <auto-generated />Maybe Roslyn doesn't handle self-closing tags? (or attributes for that matter)
roji commentedon Oct 28, 2019
Will investigate what's going on tomorrow.
Pilchie commentedon Oct 28, 2019
The roslyn code just looks at the start of the string, but the comment has to be the first thing in the file.
Pilchie commentedon Oct 28, 2019
It also excludes some files by file name patterns, so it might be working already
agocke commentedon Oct 28, 2019
So, modifying the analyzer could be useful, but the performance is still not great, even just building the code, because of the pattern of generated code.
The key thing on the analyzer side is that we're somehow avoiding re-using symbols from binding, effectively causing us to bind twice. Obviously this slows things down even more, but the underlying binding is still unfortunate. Overall on the analyzer side I'd say:
mavasani commentedon Oct 28, 2019
RE: Generated code analysis
Please ensure that analyzer explicitly configures generated code analysis mode by invoking AnalysisContext.ConfigureGeneratedCodeAnalysis in the
Initializecallback.28 remaining items
larrytamnjong commentedon Oct 25, 2024
Looking at this comment thread 5 years later and we're facing the same problem built time on our Asp.net core 8 wep API app takes almost 2 hours. We have approximately 80 migrations.
roji commentedon Oct 25, 2024
@larrytamnjong we are not aware of any specific pending performance issues. How big are your migrations? Does everything run fast when you disable analyzers (see above)? If not, can you see which analyzers are taking how much time?
larrytamnjong commentedon Oct 25, 2024
Thanks, @roji . We have 88 migrations in total. When I exclude them using the following configuration:
the project builds in just a few seconds. However, with migrations included, the build process becomes extremely slow—it can sometimes take over an hour and even freezes the computer. Disabling the analyzers hasn’t helped either.
We have migration files that are over 4 Mb I don't know if that's normal.
larrytamnjong commentedon Oct 26, 2024
@roji is there anything else you need me to provide to be able to remedy the situation or to improve the build time of out solution with the migrations.
roji commentedon Oct 26, 2024
@larrytamnjong migration files over 4MB are generally not a good thing, and are very likely to cause pretty bad performance problems even regardless of any specific analyzer. What's the cumulative size of all of your migrations? What's the reason they're so big?
larrytamnjong commentedon Oct 26, 2024
@roji I have 88 migrations, which are exactly 498 Mb in size. I don't know why they're so big. Each designer file contains migrations from all the previous migrations I don't know if that's what's causing the huge size. The migration files themselves are small a few kb but the designer files are very heavy some are reaching 6Mb
roji commentedon Oct 27, 2024
@larrytamnjong then I suggest you take a look inside and understand what it is that's causing the size; for example, you may be using HasData() to seed huge data, which is very much discouraged. Having such huge migration source files is definitely not normal, and will likely affect your project in negative ways regardless of analyzers.
larrytamnjong commentedon Oct 27, 2024
Thanks @roji we are actually using HasData to seed huge data I didn't figure this could be causing the issue. I'm confused about how to fix this considering the fact we already have migrations in production. Do you have any recommendations?
roji commentedon Oct 27, 2024
FWIW the problems around using HasData with huge data is called out in the docs. Going forward, the simplest would probably be to reset your migrations, starting again from scratch without HasData. Otherwise, you can manually modify the migration files to remove all HasData.
larrytamnjong commentedon Oct 27, 2024