VICTORY_MAP_THREADS=auto is asked for, not the default: 16 threads map no more pages than one in the dorm, and a frame takes longer

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 13:31:25 -06:00
1 parent a98966866c
commit 4e99544683
1 file changed
+13 -4
+13 -4
View File
@@ -1260,9 +1260,15 @@ fn scatter(wanted: &[(usize, usize)]) -> bool {
const GROUP: usize = 64;
/// How many threads map a group of pages side by side (`VICTORY_MAP_THREADS`;
/// 1: the caller alone, a page after the other, as before; `auto`, which it
/// is unless set: 1 while mapping takes little of the time, [`WIDE`] while the
/// title streams as fast as its pages are mapped, [`Busy`]).
/// 8 unless set; 1: the caller alone, a page after the other; `auto`: 1 while
/// mapping takes little of the time, [`WIDE`] while the title streams as fast
/// as its pages are mapped, [`Busy`]).
///
/// shortcut: `auto` is not the default. The intro's diner was there in time
/// with it (one run, textures-d3), but in the dorm, where each call takes 0.3
/// ms of something that only one at a time gets (until a step of the mission,
/// after which it takes 0.01), 16 threads map no more pages than one, and the
/// groups hold the mapping lock: 260 ms a frame against 125 (textures-d4, -d2).
///
/// Mapping and unmapping a view wait for a lock that every protection change
/// of a view takes too, and our guards make 100,000 of those a second, from
@@ -1289,7 +1295,10 @@ const WIDE: usize = 16;
/// `VICTORY_MAP_THREADS` as a number; `None`: by how much there is to map.
fn asked_threads() -> Option<usize> {
static ASKED: LazyLock<Option<usize>> = LazyLock::new(|| {
std::env::var("VICTORY_MAP_THREADS").ok().and_then(|v| v.trim().parse().ok()).map(|n: usize| n.clamp(1, 32))
match std::env::var("VICTORY_MAP_THREADS") {
Ok(v) if v.trim() == "auto" => None,
v => Some(v.ok().and_then(|v| v.trim().parse().ok()).unwrap_or(8).clamp(1, 32)),
}
});
*ASKED
}