Texture pass: tell its "rest" apart (5-second line), waits for its locks
The pass over textures picked by index logged 846 of 1,408 ms (cutscene, coolfox-20261126-223059) as "the rest". A second line now splits it: telling the queue what came of each slot, reading the slots' records, fingerprints after uploads and same-looks, handing first uploads to the copy queue ahead, slots shown after their upload / flipped / made at once, asking whether a staged texture's memory is all there, other checks; the waits for the queue's and the views table's locks (by the pass and by other threads, counted only when the lock was held: try_lock first); the work before the loops (not in "all"); passes by kind (frame, early, bake) with their time and how many stopped at their time or bytes; and the slots taken by outcome. The existing parts are summed in nanoseconds now: in microseconds each short call lost what it took below the next whole one. The pass reads the slot's view once for its placed and object checks (it read it twice). pass_costs (ignored test, a measurement): on this PC asking whether 1/4/16 MB of resident memory is all there takes 18/23/111 us, 0.9-15 ms when the pages were trimmed from the working set; a fingerprint 3-7 us. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
2f81d0c85b
commit
0b651fa9a8
5 files changed
+323
-80
No files matched your search
@@ -2229,6 +2229,51 @@ mod allocation_costs {
|
||||
}
|
||||
}
|
||||
|
||||
/// What the pass over textures picked by index pays per slot outside its
|
||||
/// timed parts (2026-11-26): asking whether a staged texture's memory is
|
||||
/// all there (`staged(_, true)`, a question per 256 pages), and the
|
||||
/// fingerprint of 48 KiB made after each upload and each texture found
|
||||
/// the same. For `cargo test -p victory-gpu --release --lib pass_costs --
|
||||
/// --ignored --nocapture`.
|
||||
#[test]
|
||||
#[ignore = "a measurement, not a check"]
|
||||
fn pass_costs() {
|
||||
use windows_sys::Win32::System::Memory::{MEM_COMMIT, MEM_RESERVE, PAGE_READWRITE, VirtualAlloc};
|
||||
use windows_sys::Win32::System::ProcessStatus::K32EmptyWorkingSet;
|
||||
use windows_sys::Win32::System::Threading::GetCurrentProcess;
|
||||
for mb in [1usize, 4, 16] {
|
||||
let len = mb << 20;
|
||||
// SAFETY: memory of our own, committed and touched.
|
||||
let at = unsafe {
|
||||
let at = VirtualAlloc(std::ptr::null(), len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
||||
std::ptr::write_bytes(at.cast::<u8>(), 1, len);
|
||||
at as usize
|
||||
};
|
||||
const N: u32 = 200;
|
||||
let began = std::time::Instant::now();
|
||||
for _ in 0..N {
|
||||
assert!(super::committed(at as *const u8, len));
|
||||
}
|
||||
println!("{mb} MB, all in the working set: whether it is all there, {:.1} us", began.elapsed().as_secs_f64() * 1e6 / f64::from(N));
|
||||
// Pages out of the working set (trimmed, as Windows does to a
|
||||
// process under pressure) are asked again by a read of a byte.
|
||||
let mut worst = 0f64;
|
||||
for _ in 0..5 {
|
||||
// SAFETY: our own process.
|
||||
unsafe { K32EmptyWorkingSet(GetCurrentProcess()) };
|
||||
let began = std::time::Instant::now();
|
||||
assert!(super::committed(at as *const u8, len));
|
||||
worst = worst.max(began.elapsed().as_secs_f64() * 1e6);
|
||||
}
|
||||
println!("{mb} MB, just trimmed from the working set: {worst:.1} us");
|
||||
let began = std::time::Instant::now();
|
||||
for _ in 0..N {
|
||||
std::hint::black_box(super::fingerprint(at as u64, len as u64));
|
||||
}
|
||||
println!("{mb} MB: a fingerprint, {:.1} us", began.elapsed().as_secs_f64() * 1e6 / f64::from(N));
|
||||
}
|
||||
}
|
||||
|
||||
/// The digest tells every length and every changed byte apart, zeros
|
||||
/// among them.
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user