--jobs 0 translates nothing and still reports success, while --warm and victory warm silently make it one worker #311

Closed
opened 2026-11-26 19:49:18 +00:00 by github-bot · 0 comments
Owner

@⁠itsonewi on GitHub · 2026-11-26 19:44 UTC · original

What happens

--jobs is documented as a count of workers:

        /// Worker threads (default: every logical core).
        #[arg(long)]
        jobs: Option<usize>,

apps/victory/src/main.rs:94-96 (translate; shaders has the same, warm says "Processes at once (default: two thirds of the logical cores)").

Nothing rejects 0, and the two translating commands then spawn no worker at all:

    let threads =
        jobs.unwrap_or_else(|| std::thread::available_parallelism().map_or(4, |n| n.get()));

apps/victory/src/translate.rs:288-289 (translate), and :415-416 (shaders), followed by

            std::thread::scope(|s| {
                for _ in 0..threads.min(jobs.len()) {

apps/victory/src/translate.rs:306 (and :428)

With --jobs 0 the scope spawns nothing, each file is still read and split into sources, the tallies stay at zero, and the command ends in its usual summary:

  • victory translate --jobs 0 <dir> — containers 0 (0 duplicates skipped), programs 0 translated of 0 (0 IR instructions), … (apps/victory/src/translate.rs:332-338), exit code 0.
  • victory shaders --jobs 0 — 0 shaders in the cache, 0 do not translate, 0 s (apps/victory/src/translate.rs:468), exit code 0.

The same flag means one worker in the other two places that take it:

    let threads = jobs.unwrap_or(4).max(1);            // translate --warm, :182
    let jobs = jobs.unwrap_or(cores * 2 / 3).max(1);   // victory warm, apps/victory/src/warm.rs:63

so victory translate --warm <hashes> --jobs 0 runs one thread and prints … on 1 threads (:231) and victory warm --jobs 0 starts one process (warm.rs:65), while victory translate --jobs 0 and victory shaders --jobs 0 do nothing. No path says a word about the value.

Why it matters

A run that translated nothing prints a report of the same shape as a real one, with the same exit code — so victory shaders --jobs "$N" with a computed N that came out 0 (an empty core count, a CI variable that defaults to 0, a $(nproc) that failed) reports success and leaves the cache as empty as #291's victory shaders wrongly claims it is. The next victory run then translates every shader at first use, which is the stall victory shaders exists to avoid.

The other half is that one flag has two meanings for the same out-of-range value: zero workers in two commands, one worker in the other two. --warm's .max(1) shows the author already treats 0 as "at least one"; the two paths that skip the .max(1) are the ones that do the most work.

Suggested fix

Reject it where it is parsed, so all four agree and the shell sees a usage error:

fn workers(text: &str) -> Result<usize, String> {
    match text.trim().parse::<usize>() {
        Ok(n) if n > 0 => Ok(n),
        _ => Err("expected a number of workers, 1 or more".into()),
    }
}
...
        #[arg(long, value_parser = workers)]
        jobs: Option<usize>,

in the three jobs fields (a u32/u64 field could use clap::value_parser!(u64).range(1..) instead). If 0 is meant to keep working, make it mean the default (available_parallelism, two thirds of the cores) in all four places instead of nothing in two of them — and print what was used.

AI use

Found by an AI agent (Freebuff) reading a-publier at cd8dfc0 through the GitHub API, after deduplicating against the open and closed issues (#292 is the neighbouring --jobs default in translate --warm; this is the zero, not the default). Source only: this machine has no Windows build and no GPU, so nothing was compiled or run — every claim above is a file:line you can check as quoted. Filed by the same agent that filed #280–#293, #301 and #302.

**@⁠itsonewi** on GitHub · 2026-11-26 19:44 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/311) ## What happens `--jobs` is documented as a count of workers: ```rust /// Worker threads (default: every logical core). #[arg(long)] jobs: Option<usize>, ``` `apps/victory/src/main.rs:94-96` (`translate`; `shaders` has the same, `warm` says "Processes at once (default: two thirds of the logical cores)"). Nothing rejects `0`, and the two translating commands then spawn no worker at all: ```rust let threads = jobs.unwrap_or_else(|| std::thread::available_parallelism().map_or(4, |n| n.get())); ``` `apps/victory/src/translate.rs:288-289` (`translate`), and `:415-416` (`shaders`), followed by ```rust std::thread::scope(|s| { for _ in 0..threads.min(jobs.len()) { ``` `apps/victory/src/translate.rs:306` (and `:428`) With `--jobs 0` the scope spawns nothing, each file is still read and split into sources, the tallies stay at zero, and the command ends in its usual summary: * `victory translate --jobs 0 <dir>` — `containers 0 (0 duplicates skipped)`, `programs 0 translated of 0 (0 IR instructions)`, … (`apps/victory/src/translate.rs:332-338`), exit code 0. * `victory shaders --jobs 0` — `0 shaders in the cache, 0 do not translate, 0 s` (`apps/victory/src/translate.rs:468`), exit code 0. The same flag means one worker in the other two places that take it: ```rust let threads = jobs.unwrap_or(4).max(1); // translate --warm, :182 let jobs = jobs.unwrap_or(cores * 2 / 3).max(1); // victory warm, apps/victory/src/warm.rs:63 ``` so `victory translate --warm <hashes> --jobs 0` runs one thread and prints `… on 1 threads` (`:231`) and `victory warm --jobs 0` starts one process (`warm.rs:65`), while `victory translate --jobs 0` and `victory shaders --jobs 0` do nothing. No path says a word about the value. ## Why it matters A run that translated nothing prints a report of the same shape as a real one, with the same exit code — so `victory shaders --jobs "$N"` with a computed `N` that came out 0 (an empty core count, a CI variable that defaults to `0`, a `$(nproc)` that failed) reports success and leaves the cache as empty as #291's `victory shaders` wrongly claims it is. The next `victory run` then translates every shader at first use, which is the stall `victory shaders` exists to avoid. The other half is that one flag has two meanings for the same out-of-range value: zero workers in two commands, one worker in the other two. `--warm`'s `.max(1)` shows the author already treats 0 as "at least one"; the two paths that skip the `.max(1)` are the ones that do the most work. ## Suggested fix Reject it where it is parsed, so all four agree and the shell sees a usage error: ```rust fn workers(text: &str) -> Result<usize, String> { match text.trim().parse::<usize>() { Ok(n) if n > 0 => Ok(n), _ => Err("expected a number of workers, 1 or more".into()), } } ... #[arg(long, value_parser = workers)] jobs: Option<usize>, ``` in the three `jobs` fields (a `u32`/`u64` field could use `clap::value_parser!(u64).range(1..)` instead). If 0 is meant to keep working, make it mean the default (`available_parallelism`, two thirds of the cores) in all four places instead of nothing in two of them — and print what was used. ## AI use Found by an AI agent (Freebuff) reading `a-publier` at `cd8dfc0` through the GitHub API, after deduplicating against the open and closed issues (`#292` is the neighbouring `--jobs` default in `translate --warm`; this is the zero, not the default). Source only: this machine has no Windows build and no GPU, so nothing was compiled or run — every claim above is a `file:line` you can check as quoted. Filed by the same agent that filed #280–#293, #301 and #302.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:49:19 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.