xmem: 64-page aligned fault-ahead batch commit (XMEM-FAULT-BATCH-COMMIT) #1707

Open
github-bot wants to merge 1 commit from github-bot/gh-1707 into main AGit
Owner

@⁠Tortoche on GitHub · 2026-11-25 08:56 UTC · original
Tortoche:fix/xmem-fault-batch-commit → main · +94 −3 · 2 files · 1 commits · open

Claim: XMEM-FAULT-BATCH-COMMIT (#1608)

AI-assisted: yes

Summary

  • Implement 64-page-aligned (4 MiB) fault-ahead batch commit in commit_mapped_page (runtime/shims/xmem.cpp), clamped to [0, view.count).
  • Preserve the existing VirtualQuery + info.State == MEM_COMMIT guard so access_allowed continues to enforce PAGE_READONLY and PAGE_GUARD faults.
  • Fall back to single-page VirtualAlloc if a multi-page batch VirtualAlloc fails.
  • Notify leonida::geometry_writes::notify for the committed range and leonida::title_memory_map::changed().
  • Add test_fault_batch_commit in runtime/test/xmem_test.cpp covering 64-page aligned batch commit, view-boundary clamping (< 64 pages), and PAGE_READONLY protection preservation across a committed batch.

Testing

  • python3 -I scripts/check_no_game_data.py runtime/shims/xmem.cpp runtime/test/xmem_test.cpp -> PASS
  • python3 -I tests/test_text_write_line_endings.py -> PASS (Ran 3 tests in 20.988s, OK)
  • Windows (cmake --build runtime/build --config RelWithDebInfo --target xmem_test gta6rt + ctest --test-dir runtime/build -C RelWithDebInfo -R "^xmem" --output-on-failure):
    • 1/3 Test #48: xmem ............................. Passed 3.23 sec
    • 2/3 Test #49: xmem_no_write_watch .............. Passed 3.21 sec
    • 3/3 Test #50: xmem_write_watch ................. Passed 3.21 sec
    • 100% tests passed out of 3 (9.68 sec)
**@⁠Tortoche** on GitHub · 2026-11-25 08:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1707) `Tortoche:fix/xmem-fault-batch-commit` → `main` · +94 −3 · 2 files · 1 commits · open Claim: `XMEM-FAULT-BATCH-COMMIT` (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) AI-assisted: yes ## Summary - Implement 64-page-aligned (4 MiB) fault-ahead batch commit in `commit_mapped_page` (`runtime/shims/xmem.cpp`), clamped to `[0, view.count)`. - Preserve the existing `VirtualQuery` + `info.State == MEM_COMMIT` guard so `access_allowed` continues to enforce `PAGE_READONLY` and `PAGE_GUARD` faults. - Fall back to single-page `VirtualAlloc` if a multi-page batch `VirtualAlloc` fails. - Notify `leonida::geometry_writes::notify` for the committed range and `leonida::title_memory_map::changed()`. - Add `test_fault_batch_commit` in `runtime/test/xmem_test.cpp` covering 64-page aligned batch commit, view-boundary clamping (`< 64` pages), and `PAGE_READONLY` protection preservation across a committed batch. ## Testing - `python3 -I scripts/check_no_game_data.py runtime/shims/xmem.cpp runtime/test/xmem_test.cpp` -> PASS - `python3 -I tests/test_text_write_line_endings.py` -> PASS (Ran 3 tests in 20.988s, OK) - Windows (`cmake --build runtime/build --config RelWithDebInfo --target xmem_test gta6rt` + `ctest --test-dir runtime/build -C RelWithDebInfo -R "^xmem" --output-on-failure`): - `1/3 Test #48: xmem ............................. Passed 3.23 sec` - `2/3 Test #49: xmem_no_write_watch .............. Passed 3.21 sec` - `3/3 Test #50: xmem_write_watch ................. Passed 3.21 sec` - `100% tests passed out of 3` (9.68 sec)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:01:45 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 17:44 UTC · original

Reviewed a4d8625: xmem_test is Windows/MSVC-only so it was not executed here. cmake+ninja host_cpu_test builds clean on both trees, and a g++ model of the exact batch arithmetic swept ~90k decisions on both trees with 0 violations and the asserted batches as written. Found: git merge-tree reports conflicts against current main in both changed files, and the rebase is not mechanical (sections_committed(), the plant/promote flow, and the ranged changed(from,to), which should receive the batch range). Not verified (no Windows/Wine here): the new test asserts MEM_COMMIT states ungated, whereas this file gates such checks on Wine (touched_view_reported_reserved), so the report-only Wine run may flag it after a rebase.

AI-assisted review.

Recommendation: Fix first

**@⁠PierreEbele** on GitHub · 2026-11-25 17:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1707#issuecomment-7169927202) Reviewed a4d8625: xmem_test is Windows/MSVC-only so it was not executed here. cmake+ninja host_cpu_test builds clean on both trees, and a g++ model of the exact batch arithmetic swept ~90k decisions on both trees with 0 violations and the asserted batches as written. Found: `git merge-tree` reports conflicts against current main in both changed files, and the rebase is not mechanical (sections_committed(), the plant/promote flow, and the ranged changed(from,to), which should receive the batch range). Not verified (no Windows/Wine here): the new test asserts MEM_COMMIT states ungated, whereas this file gates such checks on Wine (touched_view_reported_reserved), so the report-only Wine run may flag it after a rebase. AI-assisted review. **Recommendation:** Fix first
This pull request has changes conflicting with the target branch.
  • runtime/shims/xmem.cpp
  • runtime/test/xmem_test.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1707/head:github-bot/gh-1707'
git switch 'github-bot/gh-1707'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1707'
git switch 'github-bot/gh-1707'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1707'
git switch 'github-bot/gh-1707'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1707'
git switch 'main'
git merge --squash 'github-bot/gh-1707'
git switch 'main'
git merge --ff-only 'github-bot/gh-1707'
git switch 'main'
git merge 'github-bot/gh-1707'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.