runtime: check the per-adapter GPU usage total in either order #1492
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1499"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T13:00:42Z.
Change
XMemGetWorkingSetStatisticspublishes this process's GPU memory as the total thatxmem_gpu_usage::total()combines from per-adapter readings (src/xmem_gpu_usage.{h,cpp}).docs/experiments.mdgives the rules with no dependence on adapter order:xmem_shim_working_set_aggregationalready feedstotal()synthetic readings. But each order-sensitive case lists the adapters in one order only, and no case sums to exactlyUINT64_MAX. So three single-point mutants of the header left the aggregation, working-set and working-set WARP tests passing:same_devicescomparing in one direction only (within(a, b));unknown_active |=written as=;>written as>=, which refuses a sum of exactlyUINT64_MAX.This adds three hand-worked cases to the existing
aggregation_checks()table:unidentified_first{gpu_a}with 64 MiBlinked_partial_overlap_second{gpu_a}then{gpu_a, gpu_b}, 64 MiB eachsum_fits_exactlyUINT64_MAX - 1on{gpu_a}plus 1 on{gpu_b}UINT64_MAXThe first two are the existing
unidentifiedandlinked_partial_overlapcases with the adapters swapped. Onlytests/xmem_shim_check.cppand one sentence in thexmem_shim_working_set_aggregationrow ofdocs/experiments.mdchange. There is no new CTest.Verification
Commit
3c6273ac(main) plus this change,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.The 10 non-hardware
xmem_shim_*tests passed after a clean rebuild.tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --checkpassed.Mutation probe
I applied each mutation to the header alone, rebuilt
xmem_shim_check, ran the three tests, then reverted. None of this is committed.!enumeration_completecheckqueriedflagsame_devicesone direction only→=`active > 1→active > 2>→>===key comparisoncontinuedomain_bytesreads only group 0nodes == 0returns 0.cpp:domain.queried = truealwaysThe last row is in
process_bytes(), which only real DXGI reaches. Covering it would need a seam insrc/, which this test-only change leaves out. There is no--mutatecontrol here either, because the faults are in the inline header and the test cannot inject them without asrc/hook.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:14:56Z.
Review: COMMENTED
Reviewed
53bbb4426ca3b8c27aaff8c4973c7803e4f83ae1(tests/xmem_shim_check.cppanddocs/experiments.md).Audit
unidentified_first({unidentified}, {gpu_a}->std::nullopt) exercisesunknown_active |= domain.devices.empty()insrc/xmem_gpu_usage.h,linked_partial_overlap_second({gpu_a}, {gpu_a, gpu_b}->std::nullopt) exercises both directions ofdetail::same_devices(a, b), andsum_fits_exactly(UINT64_MAX - 1+1->UINT64_MAX) exercises thebytes > UINT64_MAX - sumguard indetail::add.docs/experiments.mdaccurately documents the new cases and reproduction command; title-neutral, no UB, and no unrelated changes.Checks
tests/docs_links_check.py(16 Markdown files, 334 links),tests/bidi_controls_check.py(1223 tracked files), andgit diff --checkall passed.--preset dev): builtxmem_shim_check(4.14s);ctest --preset dev -R '^xmem_shim_(working_set_aggregation|working_set|working_set_warp)$' --no-tests=error— 3/3 passed (0.23s)./O2(--preset release): builtxmem_shim_check(2.17s);ctest --preset release -R '^xmem_shim_(working_set_aggregation|working_set|working_set_warp)$' --no-tests=error— 3/3 passed (0.23s).Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T13:04:04Z.
All three mutants are caught now — reproduced locally
Independent reviewer, not the author. Reviewed
53bbb442; nothing pushed to the branch. The mutations below were madelocally in
src/xmem_gpu_usage.h, rebuilt, reverted; working tree is clean.Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11.
Unmodified branch — 4 of 4 pass:
xmem_shim_working_set,_aggregation,_warpand_hardware.Mutant 1 —
same_devicescompares one directionMutant 2 —
unknown_activeassigned instead of or-edMutant 3 — overflow guard refuses an exact
UINT64_MAXsumFor mutants 2 and 3 I re-ran only the aggregation case; for mutant 1 I ran all four and the other three stayed green,
which matches your statement that the three mutants previously survived.
One observation, not a request
The other cases in the same binary keep printing
declined okon every run, including the failing ones, so the onlysignal in the output is the process exit code and the
xmem_shim_working_set_aggregation: FAILEDsummary. If youalready rely on that, fine — a per-case
name ok/name FAILEDline would make a mutant run readable without the exitcode. Your call; it does not block anything.
Verdict
Reviewed
53bbb442. +7/-1 on one test file plus the docs line, all four cases pass as-is, and each of the threesingle-point mutants you name now fails the aggregation case. No objection from me.