runtime tests: race a reader thread only once it reads (RT-TESTS-READER-START) #2131

Closed
syfyra wants to merge 1 commit from upstream-pr/2131 into main
syfyra commented 2026-11-25 22:24:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-25T22:24:17Z.


Claimed in the coordination issue as: RT-TESTS-READER-START (claim comment to follow)

What and why

Two CPU tests start a reader thread and race it at once, then require that it read at least once:

  • runtime/test/xmem_test.cpp test_split_under_reader: 2,046 single-page unmaps, each splitting the view the reader reads from;
  • runtime/test/xs_proxy_mock_test.cpp, the kernel_writes tear check: 200,000 8-byte stores against a reader that looks for a torn value.

On a loaded host (ctest -j, a busy CI runner) the racing loop can finish before the reader is first scheduled. reads stays 0 and the check fails with nothing wrong in the runtime:

  • FAIL the reader of the views' last pages never faults or misreads
  • xs_proxy_mock line 4487: g_tear.torn == 0 && g_tear.reads > 0

When the reader gets a single read in first, the test passes having checked almost nothing. The remap race test above test_split_under_reader already waits for its four writers for this reason ("The remaps can finish before a writer is scheduled on a fast host"). Both tests now wait for the reader's first read the same way; xmem_test also prints its read count, as the remap race test prints its write count. Test-only change.

Tested

Windows 11, MSVC 14.44 (Build Tools), Ninja, RelWithDebInfo; the CPU tests (configured without Vulkan headers, with #2083's CMake fix applied locally so the configure succeeds):

  • xmem_test with LEONIDA_WRITE_WATCH=0 under 32 busy processes on 8 cores, 8 runs each:
    • main: 1 failure (0 reads), 5 passes with exactly 1 read, 2 with more;
    • this branch: 8 passes, 467 to 7,137 reads, 0 misread.
  • ctest -j 8 (162 tests): on main xs_proxy_mock failed in 3 of 3 runs (the tear check); with this branch 3 of 3 runs pass 162/162. (A fourth run failed only xmem_test's system-wide commit check, which #1316 addresses.)
  • scripts/check_no_game_data.py on both files.

GPUs tested: n/a (CPU tests)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5500215417 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2131). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-25T22:24:17Z. --- Claimed in the coordination issue as: RT-TESTS-READER-START (claim comment to follow) ### What and why Two CPU tests start a reader thread and race it at once, then require that it read at least once: - `runtime/test/xmem_test.cpp` `test_split_under_reader`: 2,046 single-page unmaps, each splitting the view the reader reads from; - `runtime/test/xs_proxy_mock_test.cpp`, the `kernel_writes` tear check: 200,000 8-byte stores against a reader that looks for a torn value. On a loaded host (`ctest -j`, a busy CI runner) the racing loop can finish before the reader is first scheduled. `reads` stays 0 and the check fails with nothing wrong in the runtime: - `FAIL the reader of the views' last pages never faults or misreads` - `xs_proxy_mock line 4487: g_tear.torn == 0 && g_tear.reads > 0` When the reader gets a single read in first, the test passes having checked almost nothing. The remap race test above `test_split_under_reader` already waits for its four writers for this reason ("The remaps can finish before a writer is scheduled on a fast host"). Both tests now wait for the reader's first read the same way; `xmem_test` also prints its read count, as the remap race test prints its write count. Test-only change. ### Tested Windows 11, MSVC 14.44 (Build Tools), Ninja, RelWithDebInfo; the CPU tests (configured without Vulkan headers, with #2083's CMake fix applied locally so the configure succeeds): - `xmem_test` with `LEONIDA_WRITE_WATCH=0` under 32 busy processes on 8 cores, 8 runs each: - `main`: 1 failure (0 reads), 5 passes with exactly 1 read, 2 with more; - this branch: 8 passes, 467 to 7,137 reads, 0 misread. - `ctest -j 8` (162 tests): on `main` `xs_proxy_mock` failed in 3 of 3 runs (the tear check); with this branch 3 of 3 runs pass 162/162. (A fourth run failed only `xmem_test`'s system-wide commit check, which #1316 addresses.) - `scripts/check_no_game_data.py` on both files. GPUs tested: n/a (CPU tests) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
aslan2142 commented 2026-12-01 12:21:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:21:51Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311024765 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2131#issuecomment-7311024765). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:21:51Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 16:42:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:42:25Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318073720 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2131#issuecomment-7318073720). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:42:25Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!2131
No description provided.