Online / 6 & 7 February 2021


A journey to performance

Using Rust in Mercurial

Mercurial is a Distributed Version Control System mainly written in Python. While it is often the VCS of choice for monorepos for its great scalability, certain parts remain slower than they should be. Over the past two years, an effort to rewrite parts of the Mercurial core in Rust has seen multiple significant wins in performance, even compared to C implementations.

We will go over the different obstacles that Raphaël and his colleagues at Octobus faced during the rewrite of the ubiquitous hg status, and the solutions they came up with to make this command (and others) a lot faster. For example, running hg status in a Mozilla working copy moved from 1.1s to 0.04s, a ×25 improvement.

Themes covered include:

- Rust and Python interoperability
- Fast (and slow) Rust datastructures
- Fast directory traversal
- Version control internals
- Append-only binary formats
- Mtime caching
- Safe mmap usage in a concurrent context
- Multithreading
- Unix vs MacOS vs Windows issues


Raphaël Gomès