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.

  • Supercrunchy@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    17 days ago

    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.
      • brian@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        14 days ago

        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