Allocating Less: Really Thin Rust Cloud Apps
summary
Rust can cut allocations to make tiny cloud units: a Vec is three 8-byte fields (24 bytes), a slice is 16 bytes, and a HashMap entry can cost up to ~72 bytes of overhead per key/value. Use concrete tactics: change signatures to borrow or accept IntoIterator, prefer smallvec / smallstring / nested to coalesce allocations, replace Boxed trait objects with enum_dispatch, swap allocators and profile with dhat (one case shows ~90% of allocations from a single serde_json path).
AI-written summary · about
chapters (21)
- 0:00Start
- 3:28Why Thin Cloud Apps?
- 5:24Why Rust for Thin Cloud Apps?
- 7:57Rust Memory Model: Safety
- 8:20Details - Vec, String
- 9:33What about HashMaps?
- 11:15Where You're Allocating in your Apps
- 12:20Benchmarking Memory Usage
- 14:55Borrow, don't Move
- 16:55Flattening Data Structures
- 18:42Reducing clone with Async
- 21:08How slow is Arc, really?
- 21:56Avoiding Trait Objects with Enums
- 23:51(No) Serialization
- 26:56A JSON Processing Example
- 27:50JSON Processing - serde-json
- 28:58JeMalloc and MiMalloc
- 30:08Comparison using JSON benchmark
- 30:36Bump, Arena Allocators
- 31:28Minimizing Binary Size
- 32:04Thank You Very Much!
related talks
26mAllocating Less: Really Thin Rust Cloud Apps
43mLow-level optimization of algebraic and similar structures
19mRust Without Tears: A Guide to Avoiding Common Traps
28mRust and Scala, Sitting in a Tree….
31mGetting Something for Nothing
25mType System Tips for the Real World
08mThe Importance of Not Over-Optimizing in Rust
40mWhy Rust?
