The switches the documents name are the ones the code reads, with their defaults; xtask checks every VICTORY_* name in the Markdown is read

Checked every VICTORY_* name in the Markdown files against the source.
One was dead: VICTORY_MERGE_RACE (its counter was taken out after
8dd30ab); the line keeps the finding and drops the switch.
VICTORY_LATE_WAIT (host.rs late_stage: 1, 2, 3) and VICTORY_WIDE_REFRESH
(host.rs wide_refresh: 0, 1, else on at four or more CPUs) are read, as
documented; VICTORY_LATE_WAITS in frame.rs is a different switch.

What the docs had wrong, by the code:
- VICTORY_RELAY (stage 2), VICTORY_LATE_WAIT (stage 3 with the relay)
  and VICTORY_WIDE_BACK are on by default, not off; the frame-rate line
  says these are now the defaults (#34 copied it and saw no change).
- VICTORY_CARD_ROOM_FOR_BUFFERS is on by default (=0 as before).
- VICTORY_PAGE_WRITES opens the guards by default (=0 counts only).
- VICTORY_CARD_BUFFERS_MIN_KB, when above 0, wins over _MIN_MB: said
  in both places that name them.

xtask: a test that every VICTORY_* name in a tracked Markdown file is
quoted in at least one Rust file outside xtask, as every switch is read.

Fixes #49

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sharan104
2026-11-26 08:16:52 +05:30
parent e2a28ec706
commit d792ebd45d
5 changed files with 137 additions and 17 deletions

View File

@ -45,7 +45,7 @@ Tested on one machine: Windows 11, Intel i7-14700KF, NVIDIA RTX 4070 12 GB,
| Saves | the game autosaves a checkpoint and loads it again |
| First gameplay scene (the prologue) | renders: characters, textures, sky, sunlit exterior; HUD, pause menu and pad input work |
| Light in shadow | missing: the game's ray-traced bounce light and ray-traced lamp and sun shadows do not run yet, so anything the sun does not hit directly is black |
| Frame rate in the world | 2-4 fps: 420-450 ms per frame by default, 240-350 ms with the newer switches (`VICTORY_RELAY=2`, or `VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`); it started at 3-6 seconds per frame |
| Frame rate in the world | 2-4 fps: 420-450 ms per frame by default, 240-350 ms with the newer switches (`VICTORY_RELAY=2`, or `VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`; all but the two card-buffer sizes are the defaults now, see below); it started at 3-6 seconds per frame |
| Stability | no driver hang or device loss in normal runs (a hang introduced by the wave64 update was found and fixed: its barrier form for 64-lane programs is now off unless `VICTORY_WAVE_WIDE=1`) |
### Newest (2026-11-25, later the same day)
@ -90,8 +90,9 @@ Memory sync between the title's memory and the copies on the card:
guarded again in between no longer fails the read.
- Writes of the storage layer into physical pages are counted where the title
has those pages mapped (10,000 to 50,000 guarded blocks of copies lay under
them in every run) and can open the guards there:
`VICTORY_PAGE_WRITES=guards` (off by default; `1`, `slots`, `all` do more).
them in every run) and the guards there are opened (by default, as
`VICTORY_PAGE_WRITES=guards`; `0` counts them only; `1`, `slots`, `all` do
more or other things).
- Failed page-destination reads are retried (`VICTORY_DSTORAGE_RETRIES=0` = as before).
Card memory (the test card is full from the first frame of the world: 85 to
@ -104,18 +105,19 @@ use):
runs on the software adapter; it has not run on a card yet.
- Refused texture slots are held back for a few seconds so that a pass
reaches the slots behind them (`VICTORY_FULL_CARD_PASS=0` = as before);
room can be kept for the card copies of title buffers
(`VICTORY_CARD_ROOM_FOR_BUFFERS=1`, off).
room is kept for the card copies of title buffers
(`VICTORY_CARD_ROOM_FOR_BUFFERS=0` = as before).
Tools and diagnostics:
- `victory translate <shader file> --warm all --jobs N` translates every
shader ahead of a run, on the processor only (about 4.5 to 6.5 minutes
here); the shader cache is keyed on the translator's source, so a new
build that does not touch the translator starts warm.
- Counters, all off or diagnostics-only: `VICTORY_MERGE_RACE=1` (title bytes
a copy-back is about to put back to older values: none found in 138,000
copy-backs), `VICTORY_WALLS_TRACE`, `VICTORY_CARD_ACCOUNTING`, and a census
of the copies the texture sweep never lets go.
- Counters, all off or diagnostics-only: `VICTORY_WALLS_TRACE`,
`VICTORY_CARD_ACCOUNTING`, and a census of the copies the texture sweep
never lets go. (A counter of title bytes a copy-back was about to put back
to older values found none in 138,000 copy-backs; it has been taken out
since.)
### What this fork changed (summary)
@ -140,12 +142,23 @@ Speed and memory:
- Translated shaders get clean-up passes over the finished module (dead code, constant folding, reuse of values, branch facts); the pack's host instruction count falls by about 43 %, worth about 20 ms of GPU time per frame on the test machine (`VICTORY_SHADER_OPT=0` turns them off).
Most of the newer speed changes sit behind environment switches that are off
by default (`VICTORY_LATE_WAIT`, `VICTORY_RELAY`, `VICTORY_WIDE_BACK`,
`VICTORY_CARD_BUFFERS_MIN_MB`, `VICTORY_INPLACE`, `VICTORY_BVH_BUILDER`, ...).
Independent host-copy refreshes are the exception: they use parallel workers
automatically on systems with at least four logical CPUs. Each switch is
described in a comment where it is read.
Most of the newer speed changes sit behind environment switches. Some are
on by default here:
- `VICTORY_RELAY`: stage 2 (`=1` the first stage; any other value turns it
off);
- `VICTORY_LATE_WAIT`: stage 3 while the relay is on, else off (`=1`, `=2`,
`=3` pick a stage; any other value turns it off, and so does
`VICTORY_GPU_TIMING` set to anything);
- `VICTORY_WIDE_BACK` (`=0` turns it off);
- independent host-copy refreshes, on systems with at least four logical
CPUs (`VICTORY_WIDE_REFRESH`, above).
Others are off by default (`VICTORY_INPLACE`, `VICTORY_BVH_BUILDER`, ...).
`VICTORY_CARD_BUFFERS_MIN_MB` and `VICTORY_CARD_BUFFERS_MB` are sizes, not
switches: their defaults follow the card's memory budget.
`VICTORY_CARD_BUFFERS_MIN_KB`, when set above 0, wins over
`VICTORY_CARD_BUFFERS_MIN_MB`. Each switch is described in a comment where it
is read.
### Known problems

View File

@ -85,7 +85,8 @@ in that order of size:
for the next submission while this one is sent; view the card's own buffers where fills
copy them now.
2. The card: small buffers' copies in its own memory (`VICTORY_CARD_BUFFERS_MIN_KB=64`,
after fxceless c36971b2; not measured here yet), and the passes that run for nothing
after fxceless c36971b2, wins over `VICTORY_CARD_BUFFERS_MIN_MB`; not measured here
yet), and the passes that run for nothing
without rays.
3. Stalls: 270-660 s of a session were full of frames over 200 ms, almost all while new
pipelines were made. `victory warm`, and a quarter of the workers for the slow ones.

View File

@ -1,6 +1,8 @@
//! Repository maintenance. Run with `cargo xtask <command>`.
mod policy;
#[cfg(test)]
mod switches;
use std::path::{Path, PathBuf};
use std::process::Command;

View File

@ -89,7 +89,7 @@ pub fn run(root: &Path, staged: bool) -> Result<()> {
)
}
fn list_files(root: &Path, staged: bool) -> Result<Vec<String>> {
pub(crate) fn list_files(root: &Path, staged: bool) -> Result<Vec<String>> {
let git = |args: &[&str]| -> Result<Option<Vec<String>>> {
let out = Command::new("git")
.args(args)

104
xtask/src/switches.rs Normal file
View File

@ -0,0 +1,104 @@
//! Every `VICTORY_*` switch the documents name is read by the code (#49).
//!
//! A switch is read through a string literal of its whole name
//! (`std::env::var("VICTORY_X")`, `crate::switch::on("VICTORY_X")`,
//! `crate::ab::pick("VICTORY_X")`), so a name the Markdown files give must
//! appear quoted in at least one Rust file. xtask's own files are left out
//! of the search: this module's tests name switches of their own.
use std::collections::BTreeSet;
/// The `VICTORY_*` names in `text`, without trailing underscores (a prefix
/// such as `VICTORY_` alone or `VICTORY_...` is not a name).
fn names(text: &str) -> BTreeSet<String> {
const PREFIX: &str = "VICTORY_";
let mut found = BTreeSet::new();
let mut rest = text;
while let Some(at) = rest.find(PREFIX) {
let tail = &rest[at + PREFIX.len()..];
let len = tail
.bytes()
.take_while(|b| b.is_ascii_uppercase() || b.is_ascii_digit() || *b == b'_')
.count();
let suffix = tail[..len].trim_end_matches('_');
if !suffix.is_empty() {
found.insert(format!("{PREFIX}{suffix}"));
}
rest = &tail[len..];
}
found
}
/// The names of `documented` that no text of `sources` holds in quotes.
fn unread<'a>(documented: &'a BTreeSet<String>, sources: &[String]) -> Vec<&'a str> {
documented
.iter()
.filter(|name| {
let quoted = format!("\"{name}\"");
!sources.iter().any(|s| s.contains(&quoted))
})
.map(String::as_str)
.collect()
}
#[test]
fn documented_switches_are_read() {
let root = crate::workspace_root();
let files = crate::policy::list_files(&root, false).unwrap();
let read = |path: &String| std::fs::read_to_string(root.join(path)).ok();
let mut documented = BTreeSet::new();
let mut doc_of = Vec::new();
for path in files.iter().filter(|p| p.ends_with(".md")) {
for name in names(&read(path).unwrap_or_default()) {
doc_of.push((name.clone(), path.clone()));
documented.insert(name);
}
}
let sources: Vec<String> = files
.iter()
.filter(|p| p.ends_with(".rs") && !p.starts_with("xtask/"))
.filter_map(read)
.collect();
assert!(
!documented.is_empty(),
"no VICTORY_* names found in the Markdown files"
);
let dead = unread(&documented, &sources);
let report: Vec<String> = dead
.iter()
.map(|name| {
let docs: Vec<&str> = doc_of
.iter()
.filter(|(n, _)| n == name)
.map(|(_, p)| p.as_str())
.collect();
format!("{name} (named in {})", docs.join(", "))
})
.collect();
assert!(
dead.is_empty(),
"switches the documents name but no Rust source reads: {}",
report.join("; ")
);
}
#[test]
fn finds_whole_names_only() {
let text =
"`VICTORY_LATE_WAIT=3`, VICTORY_LATE_WAITS, `VICTORY_...`, VICTORY_ alone, VICTORY_X_ end";
let found: Vec<String> = names(text).into_iter().collect();
assert_eq!(
found,
["VICTORY_LATE_WAIT", "VICTORY_LATE_WAITS", "VICTORY_X"]
);
}
#[test]
fn a_longer_name_does_not_read_a_shorter_one() {
let documented = names("VICTORY_LATE_WAIT and VICTORY_WIDE_BACK");
let sources = [
"std::env::var_os(\"VICTORY_LATE_WAITS\")".to_owned(),
"on(\"VICTORY_WIDE_BACK\")".to_owned(),
];
assert_eq!(unread(&documented, &sources), ["VICTORY_LATE_WAIT"]);
}