Persistent incremental computations in Rust: how Rust Glancer approaches them
The article explains incremental computations: when inputs change, a result computed earlier can be reused, so only the affected parts need recomputing. The approach works best when there are many inputs and they change independently. The best-known example is incremental compilation[1], which speeds up repeated builds during development but does not necessarily speed up cold builds[2]. The same idea suits editor tooling, because code is changed far more often than it is compiled.
The rust-analyzer architecture is built on Salsa[3], a library that makes incremental computations convenient and efficient, but Salsa is designed mainly to work in memory. Rust Glancer, a project that tries to keep memory usage as low as possible, long avoided incremental computations and used a complex system of persistent caches instead. The author argues that this approach scales poorly, because the more efficiency it needed, the more complex its custom cache format became.
So the project needed persistent incremental computations, and the article looks at how such computations can work in memory and how to combine that approach with persistence. It walks through a small word-count example, first as a naive implementation and then with Salsa.
Read the original rust-glancer.github.ioDiscussion
Discussion
Commenters mostly praise the post and look forward to the next Rust Glancer release. A rust-analyzer maintainer says the team had rejected a disk-only backend for Salsa and rust-analyzer, expecting a large performance loss and high complexity, and expects to save several gigabytes per project with the upcoming rowan rewrite. Other commenters ask how the on-disk cache removes outdated results and whether failed external operations can be left out of the cache.
Links from the post and discussion
Sources
-
rust-glancer.github.io
Persistent incrementality in Rust


