Merge fork main 8dd30ab: writes through one view of a page are seen at its other views

The fork's guard over every view of a physical page is kept on our own block
bits, known holes, kernel writes and changing blocks; what both had, ours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 00:38:57 -06:00
commit c45d109380
23 files changed
+4164 -221

No files matched your search

+11
View File
@@ -86,6 +86,13 @@ enum Command {
/// Worker threads (default: every logical core).
#[arg(long)]
jobs: Option<usize>,
/// Warm the run's shader cache: a file of shader hashes (the 16
/// hex digits a run's log names a shader by, anywhere in a line);
/// the containers with those hashes are translated into the
/// cache and nothing else is done. Set `VICTORY_HOST_WAVE` and
/// `VICTORY_VIEW_LIMIT` to what the run's log says of the host.
#[arg(long)]
warm: Option<PathBuf>,
},
/// Translate every shader found (as `translate` finds them) into the
/// shader cache, so that no run has to: a few minutes, once per change
@@ -167,6 +174,7 @@ fn main() -> Result<()> {
pipelines,
list,
jobs,
warm,
} => {
// `VICTORY_VIEW_LIMIT=<null slot>`: translate as on a host whose view heap is capped
if let Some(n) = std::env::var("VICTORY_VIEW_LIMIT").ok().and_then(|v| v.parse().ok()) {
@@ -176,6 +184,9 @@ fn main() -> Result<()> {
if let Some(n) = std::env::var("VICTORY_HOST_WAVE").ok().and_then(|v| v.parse().ok()) {
victory_shader::emit::set_host_max_wave(n);
}
if let Some(file) = warm {
return translate::warm(paths, &file, jobs);
}
translate::run(paths, validate, pipelines, list, jobs)
}
Command::Shaders { paths, jobs } => translate::precompile(paths, jobs),
+81
View File
@@ -152,6 +152,87 @@ struct Checks {
host: Option<(Host, emit::HostShader)>,
}
/// `translate --warm <file>`: the containers whose hash the file names are
/// translated into the run's shader cache, on `jobs` threads; nothing is
/// made on the GPU. A run of the title then finds them there instead of
/// translating each at its first use.
pub fn warm(paths: Vec<PathBuf>, file: &Path, jobs: Option<usize>) -> Result<()> {
// `--warm all`: every container found, whatever its hash.
let all = file.as_os_str() == "all";
let mut wanted: HashSet<String> = HashSet::new();
if !all {
let text = std::fs::read_to_string(file)?;
for line in text.lines() {
for word in line.split(|c: char| !c.is_ascii_hexdigit()) {
if word.len() == 16 {
wanted.insert(word.to_ascii_lowercase());
}
}
}
anyhow::ensure!(!wanted.is_empty(), "no 16-digit shader hash in {}", file.display());
}
// `VICTORY_WARM_SECONDS=<n>`: stop taking new shaders after n seconds
// (what is done stays in the cache; the next warm-up goes on from there).
let limit = std::env::var("VICTORY_WARM_SECONDS").ok().and_then(|v| v.trim().parse::<u64>().ok());
let cfg = victory_core::Config::load()?;
victory_hle::modules::d3d12x::use_shader_cache(cfg.cache_subdir("shaders")?);
let paths = crate::default_paths(paths)?;
let threads = jobs.unwrap_or(4).max(1);
let began = std::time::Instant::now();
let done = Mutex::new(HashSet::new());
let counts = [const { AtomicUsize::new(0) }; 5];
for root in &paths {
for entry in walkdir::WalkDir::new(root).into_iter().filter_map(Result::ok) {
if !entry.file_type().is_file() || entry.metadata().map_or(0, |m| m.len()) > MAX_FILE {
continue;
}
let Ok(data) = std::fs::read(entry.path()) else {
continue;
};
let jobs = sources(&data);
let next = AtomicUsize::new(0);
std::thread::scope(|s| {
for _ in 0..threads.min(jobs.len()) {
s.spawn(|| {
while let Some(job) = jobs.get(next.fetch_add(1, Ordering::Relaxed)) {
let Some(bytes) = job.bytes() else {
continue;
};
let hash = blake3::hash(&bytes).to_hex()[..16].to_owned();
if limit.is_some_and(|n| began.elapsed().as_secs() >= n) {
counts[3].fetch_add(1, Ordering::Relaxed);
break;
}
if (!all && !wanted.contains(&hash)) || !lock(&done).insert(hash) {
continue;
}
let n = counts[4].fetch_add(1, Ordering::Relaxed) + 1;
if n.is_multiple_of(1000) {
println!("warm-up {n} shaders so far, {:.0} s", began.elapsed().as_secs_f64());
}
let which = match victory_hle::modules::d3d12x::warm_shader(&bytes) {
Ok(true) => 0,
Ok(false) => 1,
Err(_) => 2,
};
counts[which].fetch_add(1, Ordering::Relaxed);
}
});
}
});
}
}
let [translated, there, failed] = [0, 1, 2].map(|i| counts[i].load(Ordering::Relaxed));
let asked = if all { "all".to_owned() } else { wanted.len().to_string() };
let stopped = if counts[3].load(Ordering::Relaxed) > 0 { " (stopped at the time limit)" } else { "" };
println!(
"warm-up {asked} hashes asked, {} found: {translated} translated now, {there} in the cache already, {failed} do not translate; {:.1} s on {threads} threads{stopped}",
translated + there + failed,
began.elapsed().as_secs_f64()
);
Ok(())
}
pub fn run(
paths: Vec<PathBuf>,
validate: bool,