Rust analyzer and compilation are very slow. My system is heating up, running out of ram and disk space. I have 8 GB ram.
I use helix editor.
edit: thank you for all your suggestions. I am breaking up the project into smaller crates to see if that makes a difference.
I got the biggest improvements from zram and sccache. With zram my memory usage stays at 90% instead of fully running out when rust-analyzer starts.
15 Comments
Supercrunchy@programming.dev · 12 pts · 168d
8GB is not a lot to work with. It mostly depends on what crates you work with (unfortunately by default rust statically links all code in a single final step and that can be consuming a lot of RAM) Modern editors consume a lot of RAM, and if you have rust-analyzer running it's going to use a lot more in addition to the editor.
Tips:
cargo tree,cargo depgraphand thecargo build --timings). Instead of enabling all features on crates, enable only what you need.cargo checkvery often and read up method names on docs.rs a lot more.BB_C@programming.dev · 1 pts · 168d
is considered harmful.
^I^ ^don't^ ^know^ ^if^ ^someone^ ^wrote^ ^that^ ^blogpost^ ^for^ ^me^
brian@programming.dev · 1 pts · 165d
you may consider it harmful, but if they're not using the features, why would it be? or if they're only using a tiny chunk of a giant dep, maybe there's something else more appropriate for their use
BB_C@programming.dev · 1 pts · 165d
--no-default-features --features=foo,baris fine. The harmful part is replacing established crates with smaller ones solely because of ze size.And the whole dance doesn't even do what many people think it does, as covered in some comments in that linked old thread.
Note that I made that jerk thread when min-dependency-ing was sort of trending. A trend that was often (not always) as stupid and counter-productive as the other related(-ish) trend min-binary-sizing.
Also note that the harmfulness of that trend went beyond bad ecosystem dynamics and dependants ending up with less quality/reliability. That semi-obsession also encouraged bad coding practices like pervasive use of
dynwhere it's not needed. Compromising idiomaticity, and removing zero-cost abstractions to win a faster compiling dependency prize!I will stop here, because I really don't want to write that blog post.
BB_C@programming.dev · 8 pts · 168d
zramso swapping doesn't immediately slow things to a crawl.cargo check, often. You don't need to always compile.release-devprofile that inheritsrelease, use cranelift for codegen in it, and turn offlto.Otherwise, it would be useful to know what kind of system you're running, and how is the system load without any rust dev involvement. It would also be helpful to provide specifics. Your descriptions are very generic and could be entirely constructed from rust memes.
sga@piefed.social · 7 pts · 168d
mina86@lemmy.wtf · 6 pts · 168d
breadsmasher@lemmy.world · 5 pts · 168d
what are you compiling?
infinitevalence@discuss.online · 3 pts · 168d
Ahhh, Write != Compile....
maybe get a 2nd low end computer like cast off corporate PC and have that do all your compiling while you keep working on your main PC.
vas@lemmy.ml · 2 pts · 161d
A small note on that. If you could live with the compilation speed but it's annoying to have the CPU fans working all the time, you could address it by moving the CPU to a more power-efficient mode. Though that will only slow things down for you, and you're saying it's already slow and you're running out of RAM, so maybe heat/fans are not your biggest concern.
Personally, I currently use intel CPUs. Old ones I could undervolt AND limit in watts, making them silent and reducing power usage by a third at the cost of ~5% performance. My current one doesn't support undervolting sadly, and the options for wattage limits are also almost fully gone. What I use now is:
/etc/tmpfiles.d/cpu-prefer-powersafe.conf
Replacing "powersave" with "power" cuts the energy usage by half and makes the CPU fully silent at ~50 degrees... at the cost of 30% performance on this new CPU :(( Or keeping it as above, energy usage goes down somewhat (haven't measured precisely), CPU mostly silent at 50-60 degrees, performance down by 15%.
OK probably I wrote waay too much 😅
Paragone@lemmy.world · 0 pts · 168d
If you have the ability to recompile your system ( Gentoo, changing the optimization from -O2 to -Os, optimizing for size ), that may significantly free your system's resources for stuff.
Also, if you CAN'T add RAM, can you speed your storage?
Going from spinning-platter to SATA-SSD, or from SATA-SSD to NVMe, or from normal-NVMe to FAST-NVMe, would massively help your system's speed.
_ /\ _
dashdsrdash@awful.systems · -4 pts · 168d
This will work if you use emacs or vim. The problem is helix.
silly_goose@lemmy.today · 10 pts · 168d
Are you sure? I have tried using vim and it was pretty much the same.
I have also confirmed the cause using task manager to be rust analyzer.
coreray00@discuss.online · 5 pts · 168d
The only thing “heavy” about helix is it will download all the tree sitter grammars by default you can limit this, but it’s a disk usage thing.
https://docs.helix-editor.com/languages.html?highlight=Use-Grammars#choosing-grammars
capuccino@lemmy.world · 2 pts · 168d
do you use zellij or something like that?
silly_goose@lemmy.today · 2 pts · 168d
I don't use zellij. Just normal tabs inside kitty terminal.
trevor@lemmy.blahaj.zone · 7 pts · 168d
What are you talking about??? Helix doesn't even need a plugin for the LSP to work. It just uses
rust-analyzer. If anything, Helix has the least overhead of them all.