rust-glancer: An alternative LSP for Rust with focus on low memory usage
The source material details a project called "rust-glancer," an alternative implementation of the Rust Language Server (LSP) with a focus on low memory usage. The author has been working on this project for four months, and throughout the process, the RAM usage remained below 100MB even on an older MacBook Pro M1 2020 with 8GB of RAM.
However, rust-glancer is still an incomplete project, with many missing features, known bugs, and room for improvement. Despite its limitations, the author claims that rust-glancer is still capable, offering essential functionalities such as full indexing, type inference, trait solving, and common LSP actions like goto definition, hover, inlay hints, and completions.
The project was motivated by the high memory consumption of rust-analyzer, particularly due to its architecture, which prioritizes speed over memory efficiency. The author proposes a different approach: maintaining a frozen analysis result stored in the filesystem, which can be loaded and queried as needed. This approach, while slower than rust-analyzer's incremental analysis, allows for reduced memory usage.
Rust Glancer implements various optimizations to mitigate the slower indexing process, such as shallow analysis during typing and reusing previous complete indexes. Although this approach has some drawbacks, like delayed indexing and potential inaccuracy with agent-driven changes, the author believes it offers a viable alternative for users with lower-end machines or those willing to sacrifice some completeness for reduced RAM usage.
The author, with over seven years of professional Rust experience, initially considered building a simplified Rust LSP. However, he quickly realized the complexity of such a task and decided to proceed with rust-glancer instead. While the project is not intended to surpass rust-analyzer in terms of completeness and keystroke accuracy, it aims to cater to users with weaker machines or those seeking to reduce memory consumption.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.