just: lowprio, to run a recipe at idle CPU weight
A full-width cargo build of the workspace makes the desktop it runs on sluggish. `just lowprio <recipe>` runs the recipe in its own systemd user scope with CPUWeight=idle and a soft MemoryHigh cap, so it still uses every free core but yields to anything interactive; it falls back to nice -n19 where there is no systemd user session. AGENTS.md tells agents to prefix long builds with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
14d60fa515
commit
5938e8cd9c
2 files changed
+34
No files matched your search
@@ -159,6 +159,14 @@ developers build.
|
||||
build-native-release`.
|
||||
- GUI (rust/gui-app, the gpui desktop app): see `rust/gui-app/CLAUDE.md` — iterate with `just check-gui-nix`, use `just build-gui-nix` for final verification, and why `rust-analyzer.json` sets `checkOnSave: false`.
|
||||
- Run tests: see the justfile "test" group recipes; for example `just unit-tests-rust`.
|
||||
- **Prefix a build, test or lint run with `just lowprio`** — `just lowprio
|
||||
unit-tests-rust`, `just lowprio check-gui-nix` — whenever it compiles more
|
||||
than a crate or two. The developer is usually working on the same desktop
|
||||
while it runs, and a full-width cargo build makes that desktop sluggish;
|
||||
`lowprio` runs the recipe at idle CPU weight, so it still uses every free
|
||||
core but yields to anything interactive. It falls back to `nice` where there
|
||||
is no systemd user session, so it is safe on CI VMs and sandboxes too. It
|
||||
does not reach `nix build` recipes, which build under nix-daemon.
|
||||
- Lint: `just lint-rust` (clippy, whole workspace) and `just lint-kotlin`
|
||||
(detekt — no baseline, any finding fails the build; see "Two Kotlin lint
|
||||
recipes" in `android/CLAUDE.md` for the two variants). `lint-rust` covers
|
||||
|
||||
@@ -495,6 +495,32 @@ uninstall-desktop:
|
||||
rm -f ~/.local/share/applications/synchronicity.desktop
|
||||
rm -f ~/.local/share/icons/hicolor/256x256/apps/synchronicity.png
|
||||
|
||||
# Run another recipe so that it can't make the desktop sluggish: in its own
|
||||
# cgroup at idle CPU weight (it gets every core nothing else wants and yields to
|
||||
# anything that does — much stronger than `nice`, which only balances within a
|
||||
# cgroup, and the desktop session lives in a different one) with a soft memory
|
||||
# cap that throttles past the limit instead of killing. LOWPRIO_MEMORY_HIGH
|
||||
# overrides the cap (`24G`, `40%`). Without a systemd user session (macOS, a
|
||||
# bare container) it falls back to `nice -n19`.
|
||||
#
|
||||
# It covers whatever the recipe runs in this process tree, including the
|
||||
# `nix develop -c cargo …` recipes. It does not cover `nix build`
|
||||
# (`build-gui-nix`, `build-android-nix`), whose builders run under nix-daemon —
|
||||
# give that service `CPUWeight=idle` in a `systemctl edit nix-daemon` drop-in.
|
||||
[doc: "Run a recipe at idle CPU priority so it leaves the desktop responsive — `just lowprio build-native`"]
|
||||
[group: "dev"]
|
||||
[positional-arguments]
|
||||
lowprio +recipe:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if command -v systemd-run >/dev/null && systemd-run --user --scope --quiet true 2>/dev/null; then
|
||||
exec systemd-run --user --scope --quiet \
|
||||
-p CPUWeight=idle -p MemoryHigh="${LOWPRIO_MEMORY_HIGH:-50%}" \
|
||||
-- nice -n19 {{just_executable()}} "$@"
|
||||
fi
|
||||
echo "lowprio: no systemd user session; falling back to nice -n19 only" >&2
|
||||
exec nice -n19 {{just_executable()}} "$@"
|
||||
|
||||
# A throwaway store whose node is the only member of an ensemble generated just
|
||||
# for it, for looking at the GUI or TUI past first-run setup without touching the
|
||||
# default store or joining an ensemble anyone uses. The keyphrase is generated
|
||||
|
||||
Reference in new issue
Block a user