Repository navigation
test(libkernel): measure the remapped direct memory charge in the test process - #9645
Conversation
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Reviewed; the metric switch checks out. Replacing the system-wide One nit: |
|
Thanks for the review. On the nit: It is needed, not scaffolding: a run demoted into the On an older Windows that doesn't fill the field it stays 0, which only weakens the check (it can't fail falsely); if it rejected the |
There was a problem hiding this comment.
The test change directly addresses the flake source: the previous system-wide commit total could move due to unrelated processes, while the new measurement is scoped to the test process. The PrivateUsage + SharedCommitUsage sum is also necessary for both private write-watch pages and commit in the shared direct-memory section; the author supplied Windows probe measurements for each. The reviewer question about the second field has been answered with the documented EX2 layout and supported OS range. I independently ran current-main conventions and git diff --check; both pass. Product CI jobs were skipped by path filters, and this Linux workspace cannot run the Windows-specific measurement. The PR reports substantial Windows A/B stress runs (6/100 baseline failures vs 0/100 with the test change, plus Debug and current-main comparisons). The test is generic and Unblocks: none.
I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
There was a problem hiding this comment.
The process-scoped measurement and the reported Windows A/B stress results address the original flake convincingly. One repository requirement remains: this PR currently targets base b27924d, while main is 8b3a6ba; CONTRIBUTING.md requires each PR to be based on current main. Please rebase/update the PR to current main and rerun the focused Windows guest_memory check on the resulting merge base. The path-filtered hosted product jobs are skipped, so their current green status does not cover this test-only change. I cannot run this Windows-specific test from the Linux workspace.
The current request is solely for the repository's current-main requirement and a test run against the rebased result.
I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
|
I’ve noticed that my earlier request to hold this PR based on #5239 was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. Please disregard that request. |
|
A Windows run that makes the failure deterministic, and the before/after. Windows 11 Pro 10.0.26300, Core Ultra 9 185H, 64 GB, WinLibs GCC 15.2.0 r7, Release. In the wild. One of six full On demand. A second process grows its own commit during the test: it commits 16 MiB with
Not covered: whether the process figure still catches a real double charge. Showing that would take a library change that charges the remap twice. AI-assisted: yes (Claude Code) |
…t process CheckRemappedDirectMemoryIsChargedOnce compared the system-wide commit total (K32GetPerformanceInfo) before and after mapping, unmapping and remapping 256 MiB of direct memory, and required the growth to stay under 384 MiB in one of three attempts. Every other process on the host changes that total, so guest_memory failed at GuestMemory.cpp:2164 whenever a parallel test or a compiler committed and freed more than 128 MiB during each attempt. Measure the private and shared commit of the test process instead (PrivateUsage and SharedCommitUsage of PROCESS_MEMORY_COUNTERS_EX2), which covers both the private resident run and the direct memory section. The remap grows it by 265 MiB on every run, so the attempts are dropped.
c43cb10 to
dc31bde
Compare
THEMANnt
left a comment
There was a problem hiding this comment.
Reviewed dc31bdea09e5ffe8f01ffc15b7a76abdf314e773 against f26434afa36e58778a9ff4b948aea52dff19eb0c. No actionable findings in this focused review.
Source review: Inspected the complete measurement change and surrounding allocation/remap/data-retention/cleanup checks. The test now measures the current process's private plus shared commit rather than machine-wide CommitTotal, removing unrelated processes from the comparison. The 1.5-allocation threshold, remapped bytes and release checks are retained; retries are removed with the global-noise source.
Validation: Head and baseline GuestMemory.cpp pass GCC 15.2 C++23 syntax checks with the two CMake-required module-path macros supplied as placeholder strings. Initial missing-macro errors were harness configuration, not PR defects. A separate Windows probe using the exact new counter lambda created, unmapped and remapped a 16 MiB section; its measured charge was 16,809,984 bytes, below the 1.5-times threshold, with retained data. That is a native counter/section probe, not the full guest direct-memory test. Conventions, whitespace and registration passed. Hosted native/relinker jobs were skipped.
Scope: Bounded measurement correction and local Windows API behavior; no full guest-memory suite, pinned library rebuild, other-Windows-version sweep or game execution.
Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.
|
Checked the diff against the description: the counter layout matches |
What
guest_memoryfails intermittently on Windows atCheckRemappedDirectMemoryIsChargedOnce(core/libs/tests/GuestMemory.cpp:2164,Require(once)):The check, added in #5596, maps 256 MiB of direct memory, writes it, unmaps it and maps it again. It then requires the commit charge to have grown by less than 384 MiB, so the resident run is charged once and not twice. It read that charge from
K32GetPerformanceInfo'sCommitTotal, the commit total of the whole system. Every other process changes that total. When a parallel test or a compiler commits and frees more than 128 MiB during each of the three attempts, the check fails although the library charged the memory once. It is a test bug: the library is unchanged and no title reaches it.The check now reads the commit of the test process itself,
PrivateUsage + SharedCommitUsagefromK32GetProcessMemoryInfowith aPROCESS_MEMORY_COUNTERS_EX2layout. MinGW'spsapi.hdoesn't declare that struct, so the test lays it out asPROCESS_MEMORY_COUNTERS_EXfollowed by the two added fields.PrivateUsagecovers the privateMEM_WRITE_WATCHresident run and the private reservation that keeps unmapped pages.SharedCommitUsagecovers commit in theSEC_RESERVEdirect memory section, where a demoted run goes. A standalone probe on this machine showed both:SEC_RESERVEsection raisesSharedCommitUsageby 256 MiB.MEM_WRITE_WATCHmemory raisesPrivateUsageby 256 MiB.In the test, the remap grows the process figure by 265 MiB on every run. A second charge would add at least another 256 MiB and still fail the check. Other processes can't move the figure, so the three-attempt loop that absorbed their noise is gone, and the check runs once. The resident-mapping requirement, the data checks and the threshold are unchanged.
Tested
Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Ninja,
BUILD_TESTING=ON, every AGC execution test built,SDL_AUDIODRIVER=dummy.ctest --repeat until-fail:20 --parallel 2 --timeout 300over the 742 native non-GPU tests onmain6ef5a1c4c(Release).guest_memorywas the only failure (1 time, on its second repeat, while a Debug build of the tree ran beside it).ctest --test-dir <build> -R "^guest_memory$" --timeout 300, each beside two processes. One commits and frees 512 MiB every 100 ms (50 ms held). The other commits and frees 512 MiB every 100 ms (70 ms held). The pages are committed but never touched, which mimics parallel tests or a compiler.main4a17c7175: 6/100 failed, all atGuestMemory.cpp:2164. With this change: 0/100.main6ef5a1c4c: 4/100 withmain's test, 0/100 with the change. With only the first churn process, 2/50 onmain. With no neighbour, 0/50.main6ef5a1c4c, 50 runs with the two churn processes: 3/50 withmain's test (all at line 2164), 0/50 with the change.ctest --output-on-failure --timeout 120 --parallel 2 -R "^guest_memory$|^guest_mmap_fixed_anonymous$|patched_libraries": 3/3 pass (367 patched libraries loaded, 0 failed).cmake --buildand--target libspass with no warnings in the touched file.check_test_registration.py:1170 test executable(s), 0 built and not run as recorded, none new.check_conventions.py --base origin/main: passed.pr_overlap.py: no overlap. None of the eight open PRs it could not compare (feat(libSceAgcDriver): import scattered direct memory as a dma-buf run list and probe its coherence #4449, feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021, test: organize library tests and label CTest suites #6044, perf(libc): start the guest allocation overlap queries at the range that touches the address #6321, fix(memory): honor low guest mapping hints #6469, feat(wasm): run relinked titles in the browser with WebGPU #6879, fix(libkernel): return EACCES for unknown ranges on direct-memory release paths #7105, feat(libkernel): direct memory mappings on macOS hosts #7631) changes these lines.SharedCommitUsageis filled from Windows 10/11 22H2 with the September 2023 update. Older Windows was not tested.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)