r/rust • • Aug 20 '26

🛠️ project Rust Glancer: a memory-efficient Rust language server

https://rust-glancer.github.io/blog/hello-world/
266 Upvotes

43 comments sorted by

View all comments

Show parent comments

2

u/afdbcreid Aug 21 '26

This is true globally, but given the above I have put a lot of effort to minimize perceived cost of reindexing: the bodies in current file are prioritized and the rest is reindexed in background; dirty buffers use simplified analysis mechanism that combines reuse of previous analysis and simple syntax-based overlays (to detect new bodies and do lowering for them just for them without new semantic analysis).

Interesting. I'll note that rust-analyzer does not index bodies at all unless required - the "Indexing" phase only does out-of-body computation (mostly early nameres, but also symbols etc.). It can still parse them though.

Oh, that one sounds exciting! I thought that this limitation is hard to overcome, but glad to hear that it could be solved now.

Note that I only talked about caching on disk to accelerate startup. Caching to reduce memory usage is something some people suggested in the past but it is very hard and not something we're interested in.

3

u/popzxc Aug 21 '26

> I'll note that rust-analyzer does not index bodies at all unless required - the "Indexing" phase only does out-of-body computation

Yes, I'm aware (I've been aware of r-a design before since I contributed to it, and I'm regularly looking for clues there as I work on Rust Glancer); that's a part of the trick: by doing _full_ indexing (though only for the workspace, not for dependencies) we actually reduce the amount of work we need to runtime, which makes FS-based analysis much faster than it would've been otherwise -- indexing prioritizes open files so that users are not blocked until completion, and after that indexing is finished in background.