xmem: one view per page so partial unmaps do not lose writes #110
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!110
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-110"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@TheRifai on GitHub · 2026-12-01 14:52 UTC · original
TheRifai:xmem-per-page-views→main· +226 −131 · 8 files · 8 commits · merged 2026-12-01 15:29 UTCWhat
Fixes the lost write that the strict title-thread test from #109 catches.
xmem::unmapremoved the whole view covering a multi-page mapping and re-mapped the kept prefix/suffix viaUnmapViewOfFile2+MapViewOfFile3; that briefly unmaps the pages that should stay, and a title thread's concurrent write to one of them is lost.mapnow creates one view per page, so a partial unmap hides only the pages it was asked to unmap. The strictassert_eq!stays untouched; the test that asserted "the view is still the one view it was" now checks both pages keep their own views, preserving its intent (both still mapped, bytes intact).The reference
Console behaviour: a page the title was never given up keeps its contents while other pages of the view are remapped (the test's own doc). No new fallback: the single-view path remains for a one-page mapping or an owned placeholder.
Evidence
tools/build.shand a 120 s house-scene validation run under GE-Proton11-16: survived to timeout with only the four known VUIDs.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited (rule 29/31)unsafe(rule 36)@vktory6 on GitHub · 2026-12-01 14:55 UTC · original
Thanks for the new PR, and
ownis passed through now. 5/50 -> 0/50 on the strict test is a clear result.Holding the merge for the scale numbers from my #109 comment, because this changes every multi-page mapping the title makes, not just the test's: one view per 64 KiB page is 16,384 views per GiB. On the boat start, main against this branch:
physical().views.len()logged once, orwc -l /proc/<pid>/mapsof the title process.vk.log).VKB_LAT+greenfield/tools/frec/frames.py.Please also include
sysctl vm.max_map_countfrom your machine. Many distros default to 65,530, and a title that needs more views than that would fail to map on those systems, even where it works on ours (1,048,576 here).If the numbers are small, it goes in as it is. If the view count is large, the split-on-partial-unmap variant from my #109 comment keeps the common case at one view.
@TheRifai on GitHub · 2026-12-01 15:10 UTC · original
Scale numbers (house scene, GE-Proton11-16, VKB_LAT, A B B A): A-main vmas at world 151377/149037, world_at 34s/34s, frame mean 48.1/41.8 ms; B-per-page vmas 209831/210479/209802, world_at 55/36/36s, frame mean 47.4/47.6/45.9 ms. So ~+40% VMAs (150k -> 210k) but no clear frame-time regression; world entry is 34s vs 36s apart from one 55s outlier. vm.max_map_count here = 1048576 (both arms already exceed the common 65530 default). Logs: /tmp/opencode/capture/ab110/. The strict test is 0/50 with the change vs 5/50 on main. I'll leave the merge call to you: per-page views cost ~60k extra VMAs but remove the lost write without changing the strict test.
@vktory6 on GitHub · 2026-12-01 15:17 UTC · original
Thanks for the numbers, that settles it: main is already at ~150k mappings, so the extra ~60k doesn't change what a system has to allow, and there's no visible frame-time cost. I've added the map-limit requirement to the README. The house scene switches views on its own, so for future frame-time A/Bs the boat start is the more reliable scene.
One thing blocks the merge: CI's policy test fails because
crates/victory-hle/src/modules/xmem.rsgrows to 2,638 lines, past its listed 2,624 ingreenfield/tools/policy/oversize.txt. Rule 4 asks to split a listed file when it grows, not to raise its count.xmem.rshas clear pieces:mod poolor the view bookkeeping (map/map_view/unmap) could become their own file. Could you move one of those out in this PR, soxmem.rsends below 2,624, and lower its count to the new length? Then it's ready to merge.@TheRifai on GitHub · 2026-12-01 15:23 UTC · original
Done: moved the page-mapping worker pool to xmem/pool.rs and lowered the oversize.txt count to 2521 code lines, pushed to this same branch as a fast-forward commit (no reopen). xmem.rs is now below its listed count; policy test (6), native tests and build pass.
@vktory6 on GitHub · 2026-12-01 15:30 UTC · original
Merged as
90fd7fa, thank you! The lost write from #109 is fixed, the strict test passes, the scale is measured, andxmem.rsis smaller than before. Good work following it from a flaky test to the cause.