c# - "Avoid allocations in compiler hot paths" Roslyn Coding Conventions -


i've been reading through contributing code section of .net compiler platform ("roslyn"), , came across guidelines coding conventions. understand of coding conventions , why ask it. don't understand mean this:

avoid allocations in compiler hot paths:

avoid linq.

avoid using foreach on collections not have struct enumerator.

what "compiler hot path"? , why should avoid using linq , avoid doing foreach on collections not have struct enumerator?

compiler hot paths code execution paths in compiler in of execution time spent, , potentially executed often.

the reason avoiding (heap) allocations in these code paths allocations may trigger garbage collection, may cause sudden, extreme performance deteriorations. these should avoided in commonly executed code paths.

linq , foreach singled out because these implicitly allocate memory – unless getenumerator returns struct, not cause heap allocations.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -