A journey to performance: using Rust in Mercurial
summary
Mercurial replaces its flat dirstate with a compact, mmap-backed, append-only tree and rewrites hot paths in Rust, using Rayon and crossbeam for parallel directory traversal plus mtime caching to skip work; on large repos status moves from ~1.1s to ~0.04s (×25) in one reported case and earlier Rust rewrites give up to ×4 speedups versus the Python+C mix. The new dirstate format is vacuumable and safe for concurrent readers and already lands real-world wins on Mozilla-sized repositories. ×25 faster on Mozilla: 1.1s → 0.04s append-only mmap-backed dirstate with mtime caching
AI-written summary · about
chapters (25)
- 0:00Introduction
- 1:46About Raphal
- 3:33Maintainability
- 6:37Attack from both sides
- 9:13Status command
- 10:15Multithreading
- 13:29Unrealistic target
- 14:50Performance comparison
- 15:52dirstate
- 16:55filesystem
- 18:16costs
- 19:52tree
- 21:55data
- 23:47appendonly storage
- 24:32dependonly storage
- 25:45docket
- 27:35memory usage
- 28:47tree optimization
- 30:38recursive implementation
- 34:14not reliable
- 35:47mtime caching
- 36:54durstate
- 37:08update
- 38:03file systems
- 41:17red deer
related talks
27mOxidizing Mercurial: The good and the less good
24mRust performance debugging with TUIs and LLMs
29mPerformance: We're In This Together
23m"The Current State and Future of Rust Compiler Performance"
53mRust: Reach Further!
33mRust at Sentry: 7 Years Later
36mPumping up Python modules using Rust
44mBending the Curve: How Rust Helped Us Write Better Ruby
