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

Open
opened 2026-11-26 21:18:44 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1707
Author: @Tortoche
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/xmem-fault-batch-commit


📝 Commits (1)

  • a4d8625 xmem: commit 64-page aligned batches on physical page fault

📊 Changes

2 files changed (+94 additions, -3 deletions)

View changed files

📝 runtime/shims/xmem.cpp (+21 -3)
📝 runtime/test/xmem_test.cpp (+73 -0)

📄 Description

Claim: XMEM-FAULT-BATCH-COMMIT (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7157581316)

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1707 **Author:** [@Tortoche](https://github.com/Tortoche) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/xmem-fault-batch-commit` --- ### 📝 Commits (1) - [`a4d8625`](https://github.com/ubiquitarianism/leonida/commit/a4d86252ed992b8f3b1792d4c070dee40829af7f) xmem: commit 64-page aligned batches on physical page fault ### 📊 Changes **2 files changed** (+94 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/xmem.cpp` (+21 -3) 📝 `runtime/test/xmem_test.cpp` (+73 -0) </details> ### 📄 Description Claim: `XMEM-FAULT-BATCH-COMMIT` (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7157581316) 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1721
No description provided.