Skip to content
← All tracks

Performance and Data Layout

Rust

Performance becomes graded: a ratio band gates the solve. Allocation budgets, capacity, layout, cache behaviour and the measurements that separate a real win from noise.

This track is written for Rust, which isn't the mode you're browsing in.

0 / 17 solved · 3 articles
  1. 1. Benchmark methodology: why your microbenchmark is lying to you Read
  2. 2. Profiling Rust: finding the hot spot before you optimise it Read
  3. 3. Not solved yet. Where the allocations are: the counting allocator
  4. 4. Not solved yet. Type sizes, enum layout and niche optimisation
  5. 5. Not solved yet. repr(Rust) reorders your fields — and that's the point
  6. 6. Not solved yet. repr(C): computing struct layout by hand
  7. 7. Not solved yet. The other reprs: transparent, packed, align, integer enums
  8. 8. Not solved yet. Memory layout and cache behaviour: flat arrays, AoS vs SoA
  9. 9. Not solved yet. Capacity and pre-sizing, graded
  10. 10. Not solved yet. Needless clone: the most common review comment in Rust
  11. 11. Not solved yet. Sorting: sort vs sort_unstable vs sort_by_cached_key
  12. 12. Not solved yet. Bounds checks: when they cost, and five safe ways to remove them
  13. 13. Not solved yet. Auto-vectorisation and why floating-point addition blocks it
  14. 14. SIMD in Rust: what is stable, what is not Read
  15. 15. Not solved yet. #[inline], #[inline(always)], #[cold] and the codegen-unit trap
  16. 16. Not solved yet. Custom hashing: beating SipHash on integer keys
  17. 17. Not solved yet. String and text performance, graded
  18. 18. Not solved yet. Iterator performance: where the abstraction leaks
  19. 19. Not solved yet. Const generics: moving a size from runtime to compile time
  20. 20. Not solved yet. const fn and compile-time evaluation

Check yourself

4 questions · one attempt each

These do not count toward finishing the track. They are here to catch the things that are easy to read past.

0 / 4

Pushing 1000 elements into a Vec, how many reallocations does each version do?

let mut a: Vec<u32> = Vec::new();
let mut b: Vec<u32> = Vec::with_capacity(1000);
// 1000 pushes into each
Question 1 of 4