Rewrite, Optimize, Repeat
summary
Ports a battle‑tested C TrieMap into Rust, establishes a simple baseline implementation with exhaustive tests and microbenchmarks (Criterion), then rewrites for performance using a single-heap allocation non‑packed layout, custom DST handling and 128 unsafe blocks with 21 unsafe private methods audited via Miri and Clippy lints. Benchmarks match or beat the C version and memory stays acceptable; code ships in Redis 8.8 and the public API exposes no unsafe.
AI-written summary · about
chapters (12)
- 0:00Introduction to Rust migration
- 1:23Redis query engine overview
- 2:45Migration strategy
- 3:50Incremental rewriting process
- 6:24TrieMap data structure
- 10:54Memory layout analysis
- 13:16Unsafe Rust feasibility
- 14:15Establishing a baseline
- 18:51Implementing the Rust layout
- 24:08Managing unsafe code
- 28:55Defensive abstractions
- 31:05Conclusion and results
related talks
30mRewrite, optimize, repeat: Our journey porting a triemap from C to Rust
40mRust’s approach of getting things right
17mRust In Rhymes
27mWhoops! I Rewrote It in Rust
34mWhoops! I Rewrote it in Rust
30mOptimising stable sort in Rust and mostly failing
31mBenchmarking and Optimization of Rust Libraries
01h 02mRewriting of a small component from C to Rust
