Skip to content

DirectStorage: count delivered bytes only upon successful completion (#2059) - #2094

Open
IAmTheSween wants to merge 1 commit into
xcl-dev:mainfrom
IAmTheSween:directstorage-delivered-bytes-counter
Open

IAmTheSween wants to merge 1 commit into
xcl-dev:mainfrom
IAmTheSween:directstorage-delivered-bytes-counter

Conversation

@IAmTheSween

@IAmTheSween IAmTheSween commented Nov 25, 2026 •

Copy link
Copy Markdown

Fixes #2059.

Previously, note_request() incremented dstorage::counters().1 (BYTES) upon request arrival, prior to read or decompression. Requests that failed (such as reads past EOF, invalid file handles, corrupted decompression streams, or access violations) delivered 0 bytes to the destination buffer but still inflated the delivered bytes counter.
Move delivered byte tracking to note_delivered(), called strictly upon successful transfer in serial execute() and parallel decompression retirement (retire_one()).
What is in it

  • Move BYTES.fetch_add out of note_request in crates/xcl/src/hle/dstorage.rs.
  • Call note_delivered(n) on the destination write success path in execute().
  • Call super::note_delivered(n) on successful retirement in crates/xcl/src/hle/dstorage/parallel.rs.
  • Add unit test failed_read_does_not_increase_delivered_bytes_counter in crates/xcl/src/hle/dstorage.rs.
    Tested
  • Windows 11 Build 26300, rustc 1.100.0 MSVC, DXC 1.8.2502.11, NVIDIA GeForce RTX 5070.
  • cargo test -p xcl --lib hle::dstorage: 31 passed, 0 failed.
  • .\scripts\test.ps1 --skip fuzz_validate_and_gpu: passed (1121 passed, 0 failed, 26 ignored).
    Regression run
    scripts/smoke.ps1 on main (cbc296a) and on this PR's head commit (1d1ff8c):
xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 953 (PresentX 953)
presents per 2 s (last 3): 59 60 60
device removals: 0
crashes: 0
peak commit: 15148 MB
xcl-smoke v1
commit: 1d1ff8c2dbd72ac7af02e178acf32574b2470c53
gpu: NVIDIA GeForce RTX 5070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1490 (PresentX 1490)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15430 MB

Not tested

  • Game titles other than GTA 6 (title 3c290c16).
    AI use
  • Antigravity with Gemini 3.8 Flash (High): analyzed issue DirectStorage byte counter includes failed reads #2059, relocated byte counting to success paths in dstorage.rs and dstorage/parallel.rs, authored regression test failed_read_does_not_increase_delivered_bytes_counter, ran test suite and smoke regression runs.

…cl-dev#2059)

Previously, note_request() incremented dstorage::counters().1 (BYTES) upon request arrival, prior to read or decompression. Requests that failed (e.g. read past EOF, invalid file handle, decompression corruption, or access violation) delivered 0 bytes to the destination buffer but still inflated the delivered bytes counter.

Move byte counting to note_delivered() called only upon successful transfer in serial execute() and parallel decompression retirement. Add a unit test asserting that failed requests do not increment counters().1.

Fixes xcl-dev#2059.

Assisted-by: Antigravity (Gemini 3.8 Flash)
@IAmTheSween IAmTheSween changed the title DirectStorage: count delivered bytes only upon successful completion … DirectStorage: count delivered bytes only upon successful completion (#2059) Nov 25, 2026
@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 1d1ff8c (on its base cbc296a).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1143 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: failed_read_does_not_increase_delivered_bytes_counter.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1154 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 6020a33 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@JoaoPauluu

Copy link
Copy Markdown

A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with main (1412 here; 1360 and 1374 on the two main runs). No DirectStorage read failed in this run as far as the log shows, so the changed counter path is not seen; this is a regression run only. The new test failed_read_does_not_increase_delivered_bytes_counter passes under Wine.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: 6020a33b16ba2de25b3aef5947552f2dc1831f09
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1360 (PresentX 1360)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 1d1ff8c2dbd72ac7af02e178acf32574b2470c53
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1412 (PresentX 1412)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The second main run: 1374 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the whole test suite on this head, a failed DirectStorage read, native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the tests and the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 1d1ff8c:

  • Moving only BYTES accounting into note_delivered(n) after successful writes in execute (dstorage.rs) and parallel.rs preserves REQUESTS vs FAILED parity and adds unit coverage (failed_read_does_not_increase_delivered_bytes_counter).
  • Note overlap with #2159 (8c19c0a), which also modifies BYTES/REQUESTS accounting in dstorage.rs + parallel.rs.

Remaining before merge: Fix PR description, ensure Build and test finishes green on 1d1ff8c, and dual-vendor verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DirectStorage byte counter includes failed reads

5 participants