dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.25k stars 4.73k forks source link

Reduce memory consumption of the JIT by eliminating padding etc #6756

Open pkukol opened 8 years ago

pkukol commented 8 years ago

The "struct GenTree" family is the most obvious example of this, though other important JIT data structures should be checked as well - make sure there is no unnecessary padding (due to data member alignment), see if data members could be rearranged to reduce overall size, and specifically in the case of GenTree make sure the sizes of the "small" vs. "large" nodes (and which GenTree* flavors are marked as always having to be "large") are optimized.

category:throughput theme:jit-coding-style skill-level:intermediate cost:small impact:small

mikedn commented 8 years ago

though other important JIT data structures should be checked as well

One set of structures that may be worth a look is Referenceable, RegRecord, Interval and RefPosition. Referenceable (the base class) has 3 pointers and a bool so it wastes 7 bytes (on x64). Interval has an int placed before a pointer so it wastes another 4 bytes. RefPosition has some problems with the way VC++ allocates bit fields and seems to be 8 bytes larger than it could be.