Rust Glancer: Rust LSP using 100x less RAM

I want to present a project that I’ve been working on for the past 4 months: an alternative Rust LSP implementation that is built with a focus on low memory usage.

Note: throughout this video, the used RAM remained under 100mb

These features make Rust Glancer suitable for the older computers: I have tested it on my old MacBook Pro M1 2020 with 8GB RAM, and it was pretty good.

As you can imagine, 4 months is not a lot of time for a project as big as a Rust LSP. Rust Glancer is not a complete LSP yet, it has a lot of missing functionality, it has some known bugs, and it has a lot of things I want to improve.

At the same time, it is already pretty capable: it has a full indexing pipeline with type inference and a trait solver (chalk), most of the “normal” Rust syntax is supported, and most of the “normal” LSP actions do work as well: goto definition, hover, inlay hints, completions, you name it.

If you are interested, you can already try it out: just install the VS Code extensionhere, or, if you prefer, build and install the vsix from therepository.

The rest of the post contains the history of the project: motivation, LLM use, plans and roadmap. If you’re not interested, you might want to check out theproject documentationinstead.

There are several reasons why rust-analyzer consumes a lot of memory:

(1) is something we have to live with (though there are a few optimizations we can do there which Rust Glancer does), but (2) and (3) are the consequences of the rust-analyzer architecture. rust-analyzer chose them to make the LSP faster, and it does work for that purpose.

The idea I had when I started the project: what if wedon’ttry to make an incremental LSP? What if all we have is a frozen analysis result that gets invalidated on save? It obviously will not be as fast as rust-analyzer, but it will give us the properties we seek:

This is the core idea of Rust Glancer.

It indexes the workspace once and preserves results in the filesystem, and then whenever queries need something, they can load the required information for the duration of the query.