warm-up: VICTORY_WARM_SECONDS stops the translation but not the reading, so the run goes on after it says it stopped #293

Open
opened 2026-11-26 19:22:35 +00:00 by github-bot · 0 comments
Owner

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

What happens

VICTORY_WARM_SECONDS=<n> is documented at apps/victory/src/translate.rs:176-177 as "stop taking new shaders after n seconds (what is done stays in the cache; the next warm-up goes on from there)", and it is honoured inside the per-file worker:

// apps/victory/src/translate.rs:199-207, inside the thread closure
while let Some(job) = jobs.get(next.fetch_add(1, Ordering::Relaxed)) {
    ...
    if limit.is_some_and(|n| began.elapsed().as_secs() >= n) {
        counts[3].fetch_add(1, Ordering::Relaxed);
        break;                       // this thread stops
    }

break ends that worker's loop, and nothing above it looks at the limit again. The enclosing walk keeps going for every remaining file of every root:

// :187
for entry in walkdir::WalkDir::new(root).into_iter().filter_map(Result::ok) {
    ...
    let Ok(data) = std::fs::read(entry.path()) else { continue };   // :191
    let jobs = sources(&data);                                       // scan the whole file
    std::thread::scope(|s| {
        for _ in 0..threads.min(jobs.len()) {                        // :197
            host_wave::spawn(s, wave, || { ... });
        }
    });
}

So after the limit the process still reads every remaining file whole (up to MAX_FILE = 2 GiB each, apps/victory/src/shader.rs:15), scans each buffer for containers, and starts a thread per file that immediately breaks. Only when the walk is finished does it print the summary, with "(stopped at the time limit)" (:229).

Why it matters

The point of the limit is to bound the work in a warm-up that can run for tens of minutes over a game install. A limit set for, say, a 5-minute slot still leaves the tool reading every remaining gigabyte of the package before it exits — on a large install that is minutes of disk I/O after it did its last translation, with nothing printed in between, and counts[3] (the "stopped" flag) grows once per file rather than once per stop.

Suggested fix

Check the limit at the top of the outer loop (or with an AtomicBool the workers set, tested before fs::read), and leave the walk as soon as it has passed — the summary then follows the last translation instead of the last file.

AI use

Found by reading apps/victory/src/translate.rs (warm) and apps/victory/src/shader.rs for MAX_FILE. Nothing was built or run.

**@⁠itsonewi** on GitHub · 2026-11-26 19:16 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/293) ## What happens `VICTORY_WARM_SECONDS=<n>` is documented at `apps/victory/src/translate.rs:176-177` as "stop taking new shaders after n seconds (what is done stays in the cache; the next warm-up goes on from there)", and it is honoured inside the per-file worker: ```rust // apps/victory/src/translate.rs:199-207, inside the thread closure while let Some(job) = jobs.get(next.fetch_add(1, Ordering::Relaxed)) { ... if limit.is_some_and(|n| began.elapsed().as_secs() >= n) { counts[3].fetch_add(1, Ordering::Relaxed); break; // this thread stops } ``` `break` ends that worker's loop, and nothing above it looks at the limit again. The enclosing walk keeps going for every remaining file of every root: ```rust // :187 for entry in walkdir::WalkDir::new(root).into_iter().filter_map(Result::ok) { ... let Ok(data) = std::fs::read(entry.path()) else { continue }; // :191 let jobs = sources(&data); // scan the whole file std::thread::scope(|s| { for _ in 0..threads.min(jobs.len()) { // :197 host_wave::spawn(s, wave, || { ... }); } }); } ``` So after the limit the process still reads every remaining file whole (up to `MAX_FILE` = 2 GiB each, `apps/victory/src/shader.rs:15`), scans each buffer for containers, and starts a thread per file that immediately breaks. Only when the walk is finished does it print the summary, with "(stopped at the time limit)" (`:229`). ## Why it matters The point of the limit is to bound the work in a warm-up that can run for tens of minutes over a game install. A limit set for, say, a 5-minute slot still leaves the tool reading every remaining gigabyte of the package before it exits — on a large install that is minutes of disk I/O after it did its last translation, with nothing printed in between, and `counts[3]` (the "stopped" flag) grows once per file rather than once per stop. ## Suggested fix Check the limit at the top of the outer loop (or with an `AtomicBool` the workers set, tested before `fs::read`), and leave the walk as soon as it has passed — the summary then follows the last translation instead of the last file. ## AI use Found by reading `apps/victory/src/translate.rs` (`warm`) and `apps/victory/src/shader.rs` for `MAX_FILE`. Nothing was built or run.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:22:35 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.