Repository navigation
refactor(priority): unify low-priority spawning in priority module - #2140
Merged
Merged
Conversation
Collapses the two priority-lowering helpers (`copy::lower_process_priority` and `commands::process::low_priority_command`) into a single `worktrunk::priority` module with a spec doc-comment, two entry points (`lower_current_process` and `command`), and a shared `HAS_IONICE` `LazyLock` probe via `which`. On Linux the child-wrapping path now does best-effort `ionice -c 3 -- nice -n 19 --`, matching the I/O-throttle story `taskpolicy -b` already gave us on macOS. `ionice` ships in util-linux on every mainstream distro and is enabled in Alpine's busybox, so the `nice`-only fallback is only hit on stripped-down environments. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 12, 2026
Collaborator
|
codecov/patch fails at 91.42% (target 96.13%) with 3 missed lines in
Confirmed by querying main-branch coverage for the same byte ranges: So no net coverage regression — just patch-vs-file accounting. Deferring to you on whether this is acceptable to merge. |
Covers the cfg-gated branches of `command()` that integration tests don't exercise directly (macOS taskpolicy wrap, Linux ionice/nice wrap, non-unix no-op, and `lower=false` passthrough), plus a smoke test of `lower_current_process()`. Addresses `codecov/patch` gap on #2140. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 13, 2026
The Linux CI runner has `ionice` installed, so the `HAS_IONICE=false` arm of `command()` was never hit under coverage. Pull the branching into a small `linux_low_priority_command(program, has_ionice)` helper and test both values directly. Closes the remaining codecov/patch gap on #2140. Co-Authored-By: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Collapses the two priority-lowering helpers (
copy::lower_process_priorityandcommands::process::low_priority_command) into a singleworktrunk::prioritymodule. The module-level doc-comment now documents the policy (macOStaskpolicy -bvs Linuxionice+nice), theforbid(unsafe_code)rationale for shelling out, and the two forms in which we apply it.Follow-up to #2133. Two small behaviour notes:
ionice -c 3 -- nice -n 19 --(was justnice -n 19), matching whattaskpolicy -balready covers on macOS.ioniceavailability is probed once per process viawhich.ioniceships inutil-linuxon every mainstream distro and is enabled in Alpine's busybox, so thenice-only fallback is only hit on stripped-down environments (distroless, minimal busybox, etc.).copy.rs's self-lowering path now also gatesionicebehind the samewhichprobe, so we don't unconditionally forkioniceon hosts without it.The
command()function delegates Linux branching to a smalllinux_low_priority_command(program, has_ionice)helper so bothhas_ionicearms are unit-testable regardless of whether the CI runner hasioniceinstalled. Tests cover the macOStaskpolicywrap, both Linux arms, the non-unix no-op, andlower=falsepassthrough.One canonical policy in one place.