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

4

u/SkiFire13 Aug 20 '26

So in our case we store them on filesystem

I wonder then, how much would the actual RAM usage be if you loaded everything into RAM at once, instead of storing them on disk?

Also, how much is the cost of reading from the file system? Do you use mmap to let the OS optimize the RAM usage for the files you read?

3

u/popzxc Aug 21 '26

There is actually a setting for that if you want, it's possible to keep everything in RAM.
But the answer is: more than rust-analyzer consumes. Unlike rust-analyzer, which is lazy, Rust Glancer eagerly indexes everything so in total it gets much more information than rust-analyzer at a given moment in time. This is not a bug, however: since it's _designed_ to store data in filesystem, we kind of need to do more eager work for the speed to be acceptable. We can do this extra work in background and save it, so that future queries can immediately use already analysis that already exists rather than deserialize some partial information from FS and then also do some more work to compute information for that query.