Reuse a captured page for the rest of its uniform words #315

Closed
SkippySteve wants to merge 1 commit from fix/submitted-page into main
SkippySteve commented 2026-11-07 20:22:50 +00:00 (Migrated from github.com)

Summary

  • After the first submit-time capture, memory_read_as_submitted took the pool lock on every word of guest memory the replay reads (uniform and storage descriptors). It then checked whether that 4 KB page was in a capture. The next words of the same buffer are the same page.
  • The replay thread keeps that page's answer: either the capture's 4 KB copy, or the fact that guest memory stands. The next read of the page copies from the kept bytes, or skips the lock, until cap_view_gen changes. A page stamp, the written-page collection, and taking a capture all bump that generation, so a newer write is not served from the old copy.

Test plan

  • python -I -B tests/test_submitted_page.py passes: a page is reused only when the page, its write generation, and the capture generation all match, and memory_read_as_submitted checks that before pools_mu
  • A stamp, the written-page collection, and taking a capture each call cap_view_bump. Removing the stamp's bump fails the test
  • CI: "Check a captured page is read once"
## Summary - After the first submit-time capture, `memory_read_as_submitted` took the pool lock on every word of guest memory the replay reads (uniform and storage descriptors). It then checked whether that 4 KB page was in a capture. The next words of the same buffer are the same page. - The replay thread keeps that page's answer: either the capture's 4 KB copy, or the fact that guest memory stands. The next read of the page copies from the kept bytes, or skips the lock, until `cap_view_gen` changes. A page stamp, the written-page collection, and taking a capture all bump that generation, so a newer write is not served from the old copy. ## Test plan - [x] `python -I -B tests/test_submitted_page.py` passes: a page is reused only when the page, its write generation, and the capture generation all match, and `memory_read_as_submitted` checks that before `pools_mu` - [x] A stamp, the written-page collection, and taking a capture each call `cap_view_bump`. Removing the stamp's bump fails the test - [ ] CI: "Check a captured page is read once"
NotRexed commented 2026-11-07 20:59:25 +00:00 (Migrated from github.com)

Thanks! Measured together with the other replay PRs (replay 27 -> 24-25 ms a frame, fps 23 -> 26 in Kokiri) and applied by hand (conflicts only in the CI workflow; #310 and #315 needed one declaration moved), pushed in 40c3f85.

Thanks! Measured together with the other replay PRs (replay 27 -> 24-25 ms a frame, fps 23 -> 26 in Kokiri) and applied by hand (conflicts only in the CI workflow; #310 and #315 needed one declaration moved), pushed in 40c3f85.
Commenting is not possible because the repository is archived.
No description provided.