Rust Glancer: Rust LSP using 100x less RAM (rust-glancer.github.io)
tombert 4 hours ago
I couldn't find good TLA+ bindings for Neovim, so I got Claude to hack together an LSP server for it [1]. It works shockingly well, and it only took about an hour of arguing with Claude to do it.
I find it's not terribly good at actually writing TLA+ (with some very recent tests with Fable), so I'm not completely useless yet.
popzxc 4 hours ago
So all in all -- yeah, LLMs can be good _domain experts_ when you build an LSP, but a) I wouldn't trust them blindly, and b) the quality of code is still very much your responsibility.
tombert 4 hours ago
TLA+ is a relatively simple language so I think it's a good candidate for this kind of stuff; most of the stuff in the generated LSP also just proxies straight to the official command line tools. It's certainly a simpler language than Rust, so I think it's easier for Claude to keep a higher percentage of stuff in context, and at least using the TLA+ bindings seems to work pretty well.
I haven't done it since my laptop has lots of RAM, but I suspect that I will likely edit the generated code to eat less at some point.
jmalicki 3 hours ago
While it's certainly worse with LLMs, humans, especially teams of humans, have the same issue. This is where being good with software architecture is a superpower for working with LLMs, since good separation of concerns and modularity help this immensely. LLMs can even often do this themselves if you are very harsh and critical about this in design review stages, but it requires the skill to be able to recognize it and to have a "vision" for the software architecture.
popzxc 3 hours ago
I certainly enjoy working with humans much more than working with LLMs. Working with humans is usually "how can we get this done together", while working with LLMs is pretty much is "how can I make this model do what I need", which is something I don't like. An personal persistent thought I have now is not to transfer my relationship with LLMs to my relationship with human beings, and I don't really like it.
popzxc 16 hours ago
bip-bop-robot 16 hours ago
popzxc 16 hours ago
With things like trait solving I am not reinventing the wheel, and use official tooling (Chalk). Even though now the new solver is recommended, Chalk still does its job and lets me not to worry about potentially the most complex part of the machinery.
In places that seem to be underdocumented, it's always possible to: 1) look into sysroot implementation for clues 2) look into compiler sources 3) hijack stuff from rust-analyzer
I am lucky to not be the first guy who does a Rust LSP, so it's not that fundamental of a research, and much more of just an implementation :)
potamic 16 hours ago
Fantastic project btw, and it couldn't come at a better time. With the way prices are going I really hope people start paying attention to memory again.
popzxc 16 hours ago
Several things here: 1. We don't need all the information (project can have 1000+ dependencies, while query might only care about the current open file), so the amount of information we load is smaller. 2. Most of the time IDE does not actually do any queries, so if you switch to browser/Slack, you don't pay the tax. 3. Since data is loaded to the disk, after initial indexing restarting no longer consumes that much ram, and you get reindexing for free. 4. Besides offloading, I implement quite a bit of memory optimizations (some of which are covered in docs: https://rust-glancer.github.io/docs/development/MEMORY.html ), so it's a combination of factors.
meerita 13 hours ago
positron26 4 hours ago
legobmw99 2 hours ago
positron26 2 hours ago
legobmw99 an hour ago
tclancy 13 hours ago
medzernik 13 hours ago
popzxc 12 hours ago
dbdr 12 hours ago
mhluongo 11 hours ago
dbdr 13 hours ago
In the comparison table, you indicate indexing times. Could you also measure memory usage, since that's the stated goal of the project?
popzxc 12 hours ago
The difference, however, is that with Rust Glancer you don’t need full reindexing often, so it probably compensates for that to a degree.
dbdr 9 hours ago
avianlyric 9 hours ago
But importantly it’s not reindexing the entire project, which is the expensive operation. So you have higher peak RAM when opening a brand new project, but much lower RAM usage while working on the project.
popzxc 4 hours ago
And note that on dirty buffers Rust Glancer doesn't do reindexing at all: it reuses the last available analysis, plus it does syntax-based shallow overlay that is sufficient to be useful but doesn't necessarily detect semantic changes. It's a tradeoff, but this tradeoff makes Rust Glancer competitive in terms of latency with rust-analyzer without compromising RAM and while keeping your CPU cool.
> it completely reindexes the single file that’s saved
This is true, though I have to mention that change in the file might invalidate its reverse dependencies, which can make the partial analysis bigger than just one file/crate, but it's still very fast in practice.
popzxc 4 hours ago
This is when you do full reindexing.
> Is that only an incremental indexing with normally low RAM usage?
Yup, on save you only update the crates that were invalidated.
dkersten 11 hours ago
rdescartes 4 hours ago
hofiflo 12 hours ago
UltraSane 11 hours ago
Then what are they?
throwuxiytayq 11 hours ago
bpavuk 11 hours ago
IshKebab 9 hours ago
When the wheel was invented cavemen probably said "it's just a stone".
hofiflo 2 hours ago
boredumb 7 hours ago
Paria_Stark 13 hours ago
I honestly think it's the wrong philosophy. Once again I'm a nobody compared to maintainers, so take my opinion with a grain of salt
dijit 13 hours ago
And I agree that efforts to reduce this are noble and warranted, but I worry about what doesn’t happen because of those optimisations. The rust tooling is just so-so good (and a better argument for the language than memory safety imo), so I support more efforts to be ergonomic over memory optimisation.
Even though rust-analyzer is often the largest memory process on my machine. (and I only have 24GiB of RAM).
pr4wl 10 hours ago
nijave 9 hours ago
popzxc 8 hours ago
So I don't deny the idea, just stating that it's probably _significantly_ more complex to implement than it sounds.
Fluorescence 8 hours ago
They've been working on memory use and it dropped to ~7.5GB for a while but the last couple of releases have been nudging up again - currently 9.4GB without major change in the workspace.
It becomes an obstacle on a 64GB machine given I work with multiple workspaces open e.g. for the crates I am using, example projects, other branches etc. so I have to start/stop it when I just want basic type-info/navigation. Trialling a different editor alongside my current one becomes prohibitive when it's going to want another 10GB for it's own RA instance.
99% of the code isn't changing so disk caching does seem like a no-brainer like back in the 90s with intellisense .ncb files... just without the regular corruptions though!
trashface 5 hours ago
It compresses well though on average, if you have something like zram (I think windows/mac do something similar). When you get multiple projects open each with their own rust analyzer though, it starts to bite
matklad 12 hours ago
Historically, the decision to not use disk traces back to this comment https://github.com/rust-lang/rfcs/pull/1317#issuecomment-150..., which is perhaps the single GitHub comment that influenced my life most. Very high impact, thanks dgrunwald! Specifically,
>Don't store anything to disk. It's likely the oracle can be fast enough without doing this; and unnecessary complexity creates bugs. "Have you tried deleting the .ncb file?" (I remember having to do this a couple times per day when using VS, ca. 2005)
>Use lazy evaluation. The IDE is only interested in very specific bits of information, almost always restricted to a couple of lines around the cursor. Avoid calculating stuff that might never get used before it gets invalidated by the next code change.
>At least for C#, laziness saves so much time that incremental compilation is unnecessary for IDE purposes
The other part of historical context was that the motivation for creating rust-analyzer was that I didn't want to write a second Rust compiler (having been doing that for a couple of years at JetBrains). So it was explicitly an experimental project to prototype the right architecture for an IDE, to ultimately change how rustc works internally, so that, down the line, an IDE and a command-line compiler could use the same core. Given that rust-analyzer is now effectively a separate rust compiler, it's safe to say I am not good at achieving my life's goals!
In that context, I believe that avoiding disk was the _right_ decision:
* It's not really germane to the problem space, if all you need is literally a cache, it can always be added later.
* Disk is a can of worms of data consistency problems. They can be overcome with engineering effort to ultimately give better user experience, but user experience wasn't the primary goal. And using disk wouldn't actually illuminate the interesting aspects of the architecture, the intended primary goal.
* Finally, _not_ using disk would be a forcing function to keep analysis fast enough, to not make startup prohibitive.
The last one was a particularly big argument in my mind --- I didn't want to reach out for "easy" solutions prematurely, to avoid avoiding hard problems. And, again, my recollection is probably not 100% correct, but, until we added support for proc macros and build scripts, it was fine-ish from the perspective of startup time (RAM usage is a different story). The problem with proc_macros and build.rs is that they need to run the rust code, so they have to run the real rustc compiler, so all our usual IDE tricks ("information ... restricted to a couple of lines around the cursor") just don't apply.
The reason why we didn't add it later was that it seemed a relatively lower priority task than the work to share the parser between rust-analyzer and rustc. So that's what I was focusing on, though, I didn't deliver that. I still think we should do it! There's no _insurmountable_ technical reasons why the parsers can't be shared! It's just (a lot of) engineering work. And, while the parser is the boring part of compiler, it's the interesting part of an IDE.
Anyway, that explains how we ended up where we are.
That being said, I don't think that "just adding disk cache" is the right approach --- the salsa in-memory data structure is very sparse and pointy. Dumping that to disk would help somewhat, but wouldn't be a great long term solution. What is needed (I also explain this in https://matklad.github.io/2026/08/21/rust-glancer.html) is to design a compact, first class data format for representing analysis information about the crate, and than teaching rust-analyzer to be polymorphic in the source of data. For current workspace, you want to use a lazy incremental in-memory data structure (I do think we sadly need incrementally for Rust, given its compilation unit structure). For dependencies, you want to work off a compact on disk index. And, if the user "goes to definition" and mutates its file in place, we want to transparently switch between the two. The _pre requisite_ for that was to define a backend agnostic analysis API, and that work was always slowly progressing in the background (https://hackmd.io/ytd82QNiT_Ku2XFr1EAtiQ), but it generally took the backseat, while sharing the parser was the main focus.
pr4wl 9 hours ago
nialv7 an hour ago
Of course, since you describe RA as "explicitly an experimental project to prototype the right architecture for an IDE", all that doesn't matter and you can set the project's goal to be whatever you want. However, it just sucks for us, the users, because RA is the only thing we have. I'm just glad to see someone else is trying to do something different. And may the best project win.
junon 3 hours ago
aperi 12 hours ago
maxlin 6 hours ago
MeetingsBrowser 4 hours ago
Everything is a trade off.
mayli 19 hours ago
popzxc 16 hours ago
t_mahmood 15 hours ago
popzxc 14 hours ago
It can use storage when running build scripts/expanding proc macros, or when running flycheck diagnostics. In both cases, it’s because it runs cargo and it writes artifacts to the target dir. And if features do not align between “common” cargo commands and configuration rust analyzer has, it can lead to conflicts and even more increased storage size (because you end up having effectively 2 sets of artifacts).
But all of that does not apply to rust glances, since it does not build code for you (even cargo diagnostics are disabled by default).
Rust Glancer analysis artifacts are not that big (it’s basically stuff that would otherwise be loaded to memory), and Rust Glancer cleans garbage so that it does not accumulate over time, so it should be fine.
positron26 4 hours ago
But I can't wait for the moral panic driving us to all pussy-foot around LLMs to die with prejudice.
Virgins often at some point in their lives assume that not having sex means they have achieved some higher level of self-control, a privileged position upon a high precipice from which they can judge others. They gather, stew, and throw stones at individuals who are going to and fro, living their lives.
Any and every gathering can mob individuals. It is not inherently moral to find yourself in a troupe. You have not reached "consensus" except within a single Discord room, a subreddit, some cesspool of comments on HN. No amount of back-slapping idiocy and corrupt self-evaluation will make any mob any more than just that.
I often say that the difference between an engineer and a mechanic is that the engineer can make a rocket fly the first time (given enough time). Still, good engineers know that time is a trade-off, that exposing errors and motivating problems sooner is very, very worth it. They contain failures. They pull errors forward in time.
But along come those most enabled by LLMs, the idiotic brigades of co-enablers who know only the high quality software made by others. They are experts in what they must be provided in order to open their wallets, and they bring this expertise into the arena of those sharing ideas. Ideas are rough, and idiots are not fond of them.
Lo the brigades demand the engineer never to show them anything that is not perfect. The brigades complain endlessly of laziness while giving no effort themselves. The brigades expect engineers with twenty years of experience make the inefficient time tradeoff of coding everything by hand even before having any idea if what they're building will be wanted by the world.
The brigades want the perfect software, but not the ugly, filthy process from which it is forged. They want it to impress them the first time they see it. They want it to be easy, low-price, available at the push of a button. They want it yesterday and without bugs. Add "Don't use LLMs!" to the list of unreasonable and ignorant demands.
The brigades hate a world where you can't trust a project from its heft and good looking README alone. They hate that what they have never had any interest in reading at all can now no longer be blindly trusted. They hate these LLMs. They hate them, HATE THEM!!! They hate the laziness, the long-winded replies, the hallucinations...
At the culmination of their frustrations, the brigades turn to the engineer with precise instruction: "Give me only the answer. Make no mistakes." We owe these lazy shits nothing.
matklad a day ago
dang 21 hours ago
popzxc 16 hours ago
Some comments on the thoughts post
> I think that part can perhaps be made lazy (but not incremental!) with little overhead?
I am still thinking about making stuff lazy, since with non-incremental approach it can introduce more lags than would be perceived comfortable, but what I do right now is that I prioritize open buffers (so the stuff user needs gets processed faster), and everything else is indexed in background. I have some thoughts about lazy approach, but before I'll try them, I want to work on the quality of analysis first.
> Would be interesting to compare memory usage with Rust Rover. Net of the IDE GUI itself, I would expect RR to be more compact.
I've received a few comments about RR already, and, to be honest, I've never tried it (somehow I never got along with JetBrains IDEs) -- but will look into it.
> One potential approach here is to pull the Sorbet trick, where you don’t run meta programming at all, and instead have a plugin interface to “explain” the effects of what that would have done.
Funnily, that's exactly (well, mostly) the idea I have in mind and want to try out. Tentatively planned for Rust Glancer 0.3.0 (0.2.0 will be mostly about more complete indexing/functionality and editors support). In short, I don't want to have random code execution in the LSP itself (even diagnostics are disabled by default), but it's quite possible that we don't need that for proc macros.
> Try changing this option and see if it helps?
I have tried both editor and server watcher options, didn't really feel the difference, but can't say that I performed a high quality investigation. I certainly noticed that vs code is not very good at properly reporting external changes (it misses a lot of them), and the server watcher was tricky to get right (and yeah, it has quite a bit of platform-specific quirks; which is one of the reasons I don't feel comfortable providing a server for Windows yet -- I have no machine to test it).
> This still seems to me to be the lowest-hanging watermelon here — split the world into arcy-pointy incremental tip of the iceberg, and mostly read-only, on disk, compact, dark, moist breeding ground for supply chain attacks.
This would be awesome! And I'd be really happy to see that change making Rust Glancer redundant; while ability to experiment is cool, I think that unified tooling is ultimately better for the language.
skavi 21 hours ago
Does anyone have experience using that? Any tradeoffs?
762236 a day ago
francislavoie 21 hours ago
xixixao 21 hours ago
This is why Rust (it’s a systems programming language) and LSP (the language server protocol invented by VS Code) are not explained in the article.
I am hoping I don’t have to define the words I used, but if in doubt, Google or ChatGPT are your friends.
762236 21 hours ago
sfdlkj3jk342a 20 hours ago
It does up until a point. Would you say the same about "AI"? What about "LLM"?
On HN (Hacker News), I expect that most would find a definition for AI or LLM to be redundant today. LSP is borderline in my opinion, especially when the context of Rust is already given.
IshKebab 21 hours ago
762236 21 hours ago
polyaniline 20 hours ago
762236 20 hours ago
verandaguy 20 hours ago
This seems surprising to me given that Rust was one of the first languages to broadly advertise a toolchain and editor integrations which rely on the technology.
762237 19 hours ago
polyaniline 20 hours ago
762237 19 hours ago
verandaguy 19 hours ago
762237 7 hours ago
verandaguy 6 hours ago
nasso_dev 20 hours ago
wtetzner 20 hours ago
0x457 20 hours ago
yk_42 18 hours ago
IshKebab 4 hours ago
AdieuToLogic 19 hours ago
LSPs are orthogonal to both LLMs and VSCode. For example, see Metals[0].
bigstrat2003 3 hours ago
Fnoord 20 hours ago
tiagod 8 hours ago
762237 7 hours ago
juntz 14 hours ago
Forking it!
phplovesong 12 hours ago
juntz 8 hours ago
I'm new for the opensource project, if there any impolite for the "fork",I would like to apologize for everyone here
juntz 8 hours ago
Learning how to communicate here is the most important things right now for me. But I have no idea about how is the polite here. I want to express more just like all the others but I don't know how to do.
if you would like to help me, thanks a lot!
peterfirefly 12 hours ago
We live in a strange world.
Narishma 5 hours ago
Mawr an hour ago