Skip to content

Instantly share code, notes, and snippets.

@skycoop
Created February 7, 2024 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skycoop/de3da0be5f54495b1b1cb9e2e1e22092 to your computer and use it in GitHub Desktop.
Save skycoop/de3da0be5f54495b1b1cb9e2e1e22092 to your computer and use it in GitHub Desktop.
Wrapping rustc in nice

I'm working with rust on a fairly low end system and was experiencing issues where the system would lock up when running large builds with Cargo. I've solved similar issues in the past with nice but didn't really want to use an alias because it would mess with my build scripts and cargo-watch. Instead of using an alias, this workaround uses a wrapped nice as a wrapper for rustc. nice needed a wrapper because you can't configure a rustc wrapper with arguments, so I wrote envnice to pull the adjustment from an environment variable.

Seems to work pretty well as a solution until rust-lang/cargo#9250 or similar is addressed.

[env]
ENVNICE_ADJ = "1"
[build]
rustc-wrapper = "envnice"
#!/bin/bash
exec nice -n "$ENVNICE_ADJ" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment