this post was submitted on 06 Mar 2026
27 points (100.0% liked)

Rust

8228 readers
3 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS
 

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.

all 26 comments
sorted by: hot top controversial new old
[–] Supercrunchy@programming.dev 12 points 5 months ago (1 children)

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:

  • trim down yout dependencies (check out cargo tree, cargo depgraph and the cargo build --timings ). Instead of enabling all features on crates, enable only what you need.
  • to free up disk space run cargo clean on the projects you are not currently working on, and regularly on your current project. If you change dependencies often it's going to use up a lot of GBs of disk space. You'll need to recompile all the dependencies every time you run it though, so don't do it too often.
  • fully close other programs if possible (browsers, chat apps, etc). Look at your task manager to see what's using up memory and kill as much as possible. Consider browsing from your phone instead, and using the PC browser just as needed.
  • emacs and vim have a very steep learning curve. I would suggest against that. If it's still too frustrating to code like this, you can disable the language server (rust-analyzer), but it's going to make coding harder. You'll loose edit suggestions and error highlighting. It's still possible to code without rust-analyzer but you'll need to run cargo check very often and read up method names on docs.rs a lot more.
[–] BB_C@programming.dev 1 points 5 months ago (1 children)

trimming down your dependencies

is considered harmful.

^I^ ^don't^ ^know^ ^if^ ^someone^ ^wrote^ ^that^ ^blogpost^ ^for^ ^me^

[–] brian@programming.dev 1 points 5 months ago (1 children)

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 points 5 months ago

--no-default-features --features=foo,bar is 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 dyn where 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 points 5 months ago
  • Use zram so swapping doesn't immediately slow things to a crawl.
  • Use cargo check, often. You don't need to always compile.
  • Add a release-dev profile that inherits release, use cranelift for codegen in it, and turn off lto.

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.

[–] breadsmasher@lemmy.world 5 points 5 months ago

what are you compiling?

[–] infinitevalence@discuss.online 3 points 5 months ago

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.

[–] TehPers@beehaw.org 2 points 5 months ago* (last edited 5 months ago) (2 children)

8GB RAM isn't a small amount (though by no means a lot). As far as RAM usage goes, the amount you need will scale with project+dependencies size, so for smaller projects, it shouldn't be a problem at all.

8GB RAM doesn't tell us about the rest of your system though. What CPU do you have? Is your storage slow? Performance is affected by a lot of factors. A slow CPU will naturally run programs slower, fewer hardware threads means less running in parallel, and slower storage means that reading incremental build data and writing it could be a bottleneck.

[–] silly_goose@lemmy.today 3 points 5 months ago (2 children)

My system has a midrange amd cpu with 6 cores. I have an ssd.

I think the issue has to do with procedural macros in maud. The project is about 1000 dependencies and 10k loc.

Combined with tailwind classes and a complex ui, the templates get bloated. I have to test this theory.

[–] INeedMana@piefed.zip 2 points 5 months ago

The project is about 1000 dependencies and 10k loc

To me that's a very big project. Have you tried using fewer compilation threads? Maybe you need to sacrifice some speed to make it fit in memory and disk?

[–] FizzyOrange@programming.dev 0 points 5 months ago (1 children)

8 GB is a really small amount. Even phones have had that much RAM for several years. The average desktop I built in 2012 had 16 GB of RAM.

Plenty of modern computers only come with a small amount of RAM, because most people only need a small amount, but 8 GB is still a small amount.

[–] TehPers@beehaw.org 1 points 5 months ago (1 children)

"Small amount" is relative here. Not everybody needs to play Battlefield 6.

For just programming, 8GB is way more than enough. Even my old work laptop had only 8GB and the issues didn't show up until I had multiple Office products + Teams + a browser open, not from any of my dev software.

[–] robinm@fosstodon.org 2 points 5 months ago

@TehPers @FizzyOrange "old laptop" RAM usage scale heavily with core count. Modern CPU have much more core, and thus RAM is much more useful for compiling nowadays

[–] vas@lemmy.ml 2 points 5 months ago

My system is heating up

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

# Possible values: default performance balance_performance balance_power power
w /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - - - - powersave

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 points 5 months ago

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 -3 points 5 months ago (2 children)

This will work if you use emacs or vim. The problem is helix.

[–] silly_goose@lemmy.today 10 points 5 months ago (2 children)

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 points 5 months ago

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 points 5 months ago (1 children)

do you use zellij or something like that?

[–] silly_goose@lemmy.today 2 points 5 months ago

I don't use zellij. Just normal tabs inside kitty terminal.

[–] trevor@lemmy.blahaj.zone 7 points 5 months ago

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.