xcrdapi: cancel reads already taken off the queue, and say why a read failed #365

Merged
NickStallman merged 1 commit from upstream-pr/365 into main 2026-11-28 09:22:22 +00:00
NickStallman commented 2026-11-28 04:00:18 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T04:00:18Z.


Fault. CancelRequestsWithTag only marked requests still waiting in the queue. The storage worker takes up to 256 consecutive reads off the queue at a time, so cancelling a read that was already running had no effect. If its destination was then freed, it failed and reported the failure. The GDK says "A cancelled request is not counted as a failure."

Change

  • Cancellation also reaches reads that are already running. A cancelled read skips its write and completes without an error.
  • Per-failure reason lines, always on. They give the stage (staging, buffer, read, decode or pages), the HRESULT and the reason, the options, sizes, page count, page offset and first page tokens, and "cancelled, not reported" where that applies. The first 64 are logged, then every 1,024th.
  • With TUXBOX_XCRD_LOG=1, the per-option counters also count cancelled reads.

Why now. The first ProjectScarlett run with TUXBOX_XCRD_LOG=1 (RTX 5090, after #345) showed most failures in one burst:

  • zlib into physical pages: 164 of 209 requests failed;
  • BCPack BC1 into physical pages: 27 of 32;
  • plain zlib (9,880 requests), raw reads, and BC5/BC7 into pages: none failed.

Those requests were small (about 12–13 KB each). Our decoders inflate all 73,828 small zlib chunks from the title's texture pools to their listed size, and the request layout matches the GDK. So whether this cancellation bug explains the burst isn't shown yet. The new reason lines will settle it in the next run.

Tests

  • A new storage-guest case cancels a running 64 MiB inflate that ends in a bad Adler-32 and expects success. It fails 3 of 3 times on main ("a read cancelled while running is not a failure") and passes 5 of 5 with the change. The receipt is now cancellation=2.
  • python tuxbox.py check --no-gpu: passed.
  • python tuxbox.py verify --only xcrdapi: passed on an AMD Raphael iGPU (1002:13c0, RADV) and an RTX 5090 (10de:2b85, 620.70.10), GE-Proton11-14. xcrdapi has no GPU code, so no other suite is affected.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5536461515 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/365). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-28T04:00:18Z. --- **Fault.** `CancelRequestsWithTag` only marked requests still waiting in the queue. The storage worker takes up to 256 consecutive reads off the queue at a time, so cancelling a read that was already running had no effect. If its destination was then freed, it failed and reported the failure. The GDK says "A cancelled request is not counted as a failure." **Change** - Cancellation also reaches reads that are already running. A cancelled read skips its write and completes without an error. - **Per-failure reason lines, always on.** They give the stage (staging, buffer, read, decode or pages), the HRESULT and the reason, the options, sizes, page count, page offset and first page tokens, and "cancelled, not reported" where that applies. The first 64 are logged, then every 1,024th. - With `TUXBOX_XCRD_LOG=1`, the per-option counters also count cancelled reads. **Why now.** The first ProjectScarlett run with `TUXBOX_XCRD_LOG=1` (RTX 5090, after #345) showed most failures in one burst: - zlib into physical pages: 164 of 209 requests failed; - BCPack BC1 into physical pages: 27 of 32; - plain zlib (9,880 requests), raw reads, and BC5/BC7 into pages: none failed. Those requests were small (about 12–13 KB each). Our decoders inflate all 73,828 small zlib chunks from the title's texture pools to their listed size, and the request layout matches the GDK. So whether this cancellation bug explains the burst isn't shown yet. The new reason lines will settle it in the next run. **Tests** - A new storage-guest case cancels a running 64 MiB inflate that ends in a bad Adler-32 and expects success. It fails 3 of 3 times on `main` ("a read cancelled while running is not a failure") and passes 5 of 5 with the change. The receipt is now `cancellation=2`. - `python tuxbox.py check --no-gpu`: passed. - `python tuxbox.py verify --only xcrdapi`: passed on an AMD Raphael iGPU (1002:13c0, RADV) and an RTX 5090 (10de:2b85, 620.70.10), GE-Proton11-14. xcrdapi has no GPU code, so no other suite is affected. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!365
No description provided.