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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -