Struct field order affects padding; enums size to their largest variant plus a discriminant. Box large rare variants to shrink hot types. Prefer contiguous Vec over pointer-chasing structures for cache locality, and measure with size_of and profilers.
← Rust theorytheory 0/50 · 0%
Systems · hard
48. Memory Layout and Optimisation
Sizes, alignment and cache behaviour.
Check your understanding
1. Enum size is driven by…
2. How can you shrink a big rare variant?