Repository navigation
Conversation
|
Independent timing of this change on another platform: Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, release build (
Benchmark (local only)#[cfg(test)]
mod zz_copy_bench {
use windows_sys::Win32::System::Memory::*;
fn alloc(len: usize, commit: bool) -> *mut u8 {
unsafe { VirtualAlloc(std::ptr::null(), len, MEM_RESERVE | if commit { MEM_COMMIT } else { 0 }, PAGE_READWRITE) as *mut u8 }
}
fn time(label: &str, reps: usize, mut f: impl FnMut()) {
f();
let t = std::time::Instant::now();
for _ in 0..reps { f(); }
let ms = t.elapsed().as_secs_f64() * 1000.0 / reps as f64;
eprintln!("BENCH {label}: {ms:.2} ms");
}
#[test]
#[ignore]
fn copy_paths() {
// 1. fully mapped 256 MB
let n = 256 << 20;
let src = alloc(n, true);
let dst = alloc(n, true);
unsafe { std::ptr::write_bytes(src, 7, n); std::ptr::write_bytes(dst, 0, n); }
time("memcpy 256 MB mapped", 5, || unsafe { std::ptr::copy_nonoverlapping(src, dst, n) });
time("copy_mapped 256 MB mapped", 5, || super::copy_mapped(dst, src, n, false));
// 2. 32 MiB reserved with 32 committed 64 KiB islands (every 1 MiB)
let m = 32 << 20;
let s2 = alloc(m, false);
for k in 0..32 {
let p = unsafe { VirtualAlloc(s2.add(k << 20) as _, 64 << 10, MEM_COMMIT, PAGE_READWRITE) } as *mut u8;
unsafe { std::ptr::write_bytes(p, 9, 64 << 10) };
}
let d2 = alloc(m, true);
time("copy_mapped 32 MiB, 32 x 64 KiB islands", 10, || super::copy_mapped(d2, s2, m, false));
}
}Not tested: in a title, on Windows 10, on other CPUs. AI use: Claude Code (Claude Opus 5.5) wrote the benchmark, ran it on the machine above and drafted this comment. |
|
I ran this under Wine/Proton on Linux using only the synthetic Setup
Test results (3 runs each,
All three builds fail the same 3 tests, so the PR adds no failures. Those failures are already known on Wine:
The PR leaves #128 unchanged. That bug is on the Timing under Wine (an ignored ad-hoc test I added locally, not part of the PR). It copies 32 MiB with 32 committed 64 KiB islands, spaced 1 MiB apart, using
That is about 5–7× faster. You measured about 22× on Windows (27.36 → 1.23 ms). On Wine the Not tested: release builds, AMD/RADV, and any in-game load. |
|
Independent Wine test of head I also tried the same code in a world run alongside other local changes; it remained black and the runs are not controlled enough to attribute the timing difference to this PR. No game data attached. AI-assisted. |
|
Independent Windows 11 timing on a Ryzen 9 9950X3D, comparing
In a separate RTX 4080 intro run, one sample on the previous build spent 299.8 ms copying 172.9 MB. A sample with this PR and four other changes spent 76.6 ms copying 172.6 MB. Only the synthetic comparison isolates this PR. The cutscene and memory results are in the RTX 4080 run report. AI-assisted testing (Codex). |
…to host memory Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mercuryVM
left a comment
There was a problem hiding this comment.
Tested dcf6664 on Windows 11, RTX 5070, MSVC: the workspace passes (196 outside victory-shader, which has its own known parallel-GPU hang and I ran separately), including sparse_copies_preserve_islands_and_observe_remaps. I could not compare in-game copy times.
- The fast path is unchanged. Only a failed bulk read of at least 64 KiB into host memory (
!title_dst) takes the new route. VirtualQueryper region turns the 64K/4K probe storm over large holes into one zero-fill per hole. A committed region whose read still fails, because a mapping changed between query and read, falls back toread_pieces, so a race can't lose bytes. The test covers that remap case.- Not caching queries across copies is right, since titles remap.
- Committed-but-
PAGE_NOACCESSis zero-filled like a hole, which matches whatread_piecesproduced for those pages before.
No issues found.
AI-assisted (Claude Code).
…iled bulk read into host memory Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows check of I forced one 4 KiB page inside a committed 128 KiB region to be decommitted immediately after I also compared the existing piece retries and the region scan in one binary. Both timings include the initial failed bulk read. These are medians of three fresh-process medians. Each process alternated the two routes, used seven timed samples per route after warm-up, and compared every output byte.
The speedup on this setup depended on how much of the address range was unmapped. The query/read regression exercises the host-destination read path, and the timing is a synthetic copy benchmark. AI-assisted; run on Windows using process-owned test memory. |
…ad into host memory
…ad into host memory
…ad into host memory
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
dcf6664 to
2ea6961
Compare
|
Rebased onto current Validation on Windows 10:
GitHub now reports the PR as mergeable. AI-assisted (Codex). Hosted validation: CI passed for commit 2ea6961, including both Clippy configurations and the full workspace test suite. |
2ea6961 to
356b10d
Compare
|
Rebased again onto current The conflict was with the new fallback timer. It remains in Both workspace Clippy configurations, the sparse-copy regression with default and all features, and the asset-policy check pass locally. Hosted CI passed, including the full workspace tests. GitHub reports the PR as mergeable again. AI-assisted (Codex). |
|
@ifBars I compared exact
Each figure is the median of three process medians, with 15 copies per process and interleaved revisions. The fully committed and one-hole ranges overlap across processes, so I would treat those as inconclusive. The alternating-page case was faster in all three PR processes, about 2.7× at the median. Your existing remap regression passed too. The opt-in benchmark is test-only and directly on your head. Run the emitted GPU test executable with |
During first-story rendering on Windows 10, about 650 bulk reads per frame fell back to 64 KiB and 4 KiB retries in one sample. Those reads encountered roughly 136 MB of unmapped memory. This patch keeps the successful bulk read unchanged. After a failed read of at least 64 KiB into host memory, it uses VirtualQuery to skip contiguous holes and reads committed regions through the kernel. If the mapping changes before the read completes, the existing page retries recover the readable bytes. It queries again on every copy.
Validation
AI-assisted. No game assets or derived shader data are included.