Repository navigation
feat(host-tools): add variables that are a share of the host's CPUs - #193
Merged
Merged
Conversation
Mearman
force-pushed
the
feat/host-tools-cpu-share
branch
from
November 3, 2026 13:41
deb1bcb to
5d7fd27
Compare
…for the shell and for mise A worker count has to follow the size of the host, and tools such as vitest read their variable as an integer, so a percentage would be read as a count. The fleet cannot state the count either: it has hosts of several sizes and the play gathers no facts. github_runner_host_tools_shell_env_cpu_share and github_runner_host_tools_mise_env_cpu_share map a variable name to an integer divisor of at least 1. The value is the logical CPU count divided by it, rounded down and never below 1, worked out when the shell or mise reads the file. The shell runs getconf _NPROCESSORS_ONLN in a subshell that leaves no variable behind, and mise evaluates a template over its num_cpus(). The template divides the count less its remainder, because Tera's int filter refuses a float that is not whole, and floors with an if, because Tera has no max filter. Both forms share the divisor check and the check that a variable is given once across the plain, home-relative and CPU-share mappings. The tests read the shell line back through real sh, bash and zsh with a stand-in getconf, and the template through a real mise with a stand-in count, for counts and divisors including a single CPU, and check that the two agree.
Mearman
force-pushed
the
feat/host-tools-cpu-share
branch
from
November 3, 2026 13:58
5d7fd27 to
50ba88b
Compare
Mearman
marked this pull request as ready for review
November 3, 2026 15:05
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins. |
|
🎉 This PR is included in version 2.27.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
VITEST_MAX_WORKERShas to be half the host's logical CPUs, and vitest reads it withNumber.parseInt, so a percentage would be read as a count. The play gathers no facts, so the count cannot come from the inventory either.Two mappings of variable name to an integer divisor (at least 1):
github_runner_host_tools_shell_env_cpu_shareandgithub_runner_host_tools_mise_env_cpu_share. The value is the logical CPU count divided by the divisor, rounded down and never below 1, worked out when the shell or mise reads the file.Shell:
export V="$(n=$(getconf _NPROCESSORS_ONLN); n=$((n / 2)); echo $((n > 0 ? n : 1)))", same in sh, bash and zsh, no variable left in the user's shell. mise: a template overnum_cpus(). The first form I tried,(num_cpus() | int / 8) | int, fails in mise for a count that does not divide evenly (Tera'sintfilter refuses a non-whole float), so the template divides the count less its remainder, and the floor is anifsince Tera has nomaxfilter.The tests read the shell line back through real sh, bash and zsh with a stand-in
getconf, and the template through a realmise envwith a stand-in count, for 1 to 64 CPUs and divisors from 1 to 100, and check the two agree. Removing either floor fails them.Both forms share the divisor check, and the check that a variable is given once across the plain, home-relative and CPU-share mappings (the wording of that error changed for the two earlier mappings).