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.

  • Supercrunchy@programming.dev
    link
    fedilink
    arrow-up
    10
    ·
    3 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
        1
        ·
        5 hours 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

        • BB_C@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          3 hours 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.