Repository navigation
Page mappings: one call's batch holds title memory still once (VICTORY_REMAP_BATCH=1) - #1086
alexis27yt wants to merge 1 commit into
Conversation
…Y_REMAP_BATCH=1) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Heads-up from testing
Unit tests ( AI-assisted testing and report (Gemini 4 Neon). |
|
115 heavy frame summaries from a real mission: median 44.5 ms a frame waiting for title memory to hold still, 281 ms of one 302 ms texture sample, 1.27 s in the worst Not a test of this PR: our tree does not have it yet. A data point for why it matters. In a 103-minute run of the
The upload volume in those frames was small (16-36 MB); the heap's own texture pass took 24 ms in the second Setup: RTX 3070 8 GB (driver 621.24, 32-lane waves), Ryzen 5 3600, 32 GB, Windows 11, Series S mode (PR #188), 1920x1080, a diagnostics build of a tree at main 310c6eb with a number of open PRs picked and ports of fork main's copy queue re-fetch and submit thread. Switches unless the comment says otherwise: |
…xceless#1117, fxceless#1081 (zero-copy section windows, lock-free mirror, Thin LTO, streaming locks, standalone gather, Series S UI)
…Y_REMAP_BATCH=1) Port of fxceless PR fxceless#1086 (a0c1352): reentrant thread-local title_memory_remapping() guard so CopyPageMappingsBatchX holds watch::MAPPING once per batch while preserving watch::MAPPING -> xmem::PHYSICAL lock order.
CopyPageMappingsBatchXmaps page by page, and each page takes the remapping lock (watch::title_memory_remapping) on its own: ~850 takings a frame that streams, each one waiting until every read of title memory in place under way is done. Texture refreshes are such reads, and hold it for their hash and detile (see #1078). So the title's thread queues behind the texture threads once per page.With
VICTORY_REMAP_BATCH=1(off by default) the call takes the lock once, before its first page.title_memory_remappingnow counts its holds per thread, so each page (map_alias, unchanged) finds it held by its own thread and does not wait for itself. No thread ever took it twice before (the lock is not reentrant, so that would have hung), so nothing else changes. Lock order staysMAPPING, thenxmem's physical lock, as inXMemMapPhysicalPages. The frame log counts one wait (RemapWaitUs) and one hold (RemapUs) per batch. Readers wait for the whole batch instead; withVICTORY_TEXTURE_NO_WAIT=1they read through the kernel meanwhile.Measured with the new
batch_tests::what_a_batch_of_page_mappings_waits_for_beside_texture_refreshes(ignored by default) on an i5-12400F: one call of 850 one-page mappings (5 µs of work each, about one remap's kernel calls) while 2 threads refresh textures, holding the lock forhold, then letting go for 50 µs; median of 5:The page-by-page case lands at the order of the 246 ms of remapping the README measures in a streaming frame. That makes this queueing the likely bulk of it, though not yet measured in game:
RemapWaitUsfrom a streaming scene, with and without the switch, would confirm. The two changes compound: #1078 shortens each read, this pays the wait once per call.Tests: new
a_batch_maps_the_same_pages_held_once_or_page_by_pagechecks the four range kinds map the same pages in the same order both ways, that no read in place can begin mid-batch, and (a page-by-page run after a held one) that no hold is left counted. It passes in parallel withmapping_tests::reads_in_place_and_remappings_wait_for_each_other, and all 12xmemtests pass. Clippy: no new warnings, with and withoutdiagnostics.