Driving fast: long frames come largely from lazy-page faults, long list calls and the submit sweep (timeline numbers, RX 7900 XTX) #365
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/lobomfz--VIctory-xmem#365
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@ramc1312 on GitHub · 2026-12-03 20:29 UTC · original
Summary. Driving fast through the world gives about four frames of 50 ms or more every second here, on an empty road and on repeat passes, while standing at a busy spot is fine. A
VICTORY_TIMELINEcapture during the drive says roughly half of the extra time in those frames is ours: page faults on lazily mapped title memory, long list calls, and the submit thread's sweep. Numbers below, in case they help decide where to look.Setup. RX 7900 XTX, Ryzen 7 7800X3D, 64 GB, Ubuntu 26.04, GE-Proton 11-14. Main at
45591b0with the Mesa patch of that commit, diagnostics build, Series X, 2560x1440 output, ray tracing off, everything else default.How it was measured. A small trainer mod records a drive (position, heading, velocity of the car) and plays it back by putting the same car on the recorded path about four times a second, with moving traffic off and the player and car invulnerable. So every run streams the world in the same order at the same speed. The route is 48 s, 1.57 km, 117 km/h on average, 224 km/h at most. Each game start plays it three times; long frames are counted from the
long framelines between the mod's start and end marks.How bad. Three passes (147 s) per run, defaults:
45591b0, run 145591b0, run 2842767a, run 1842767a, run 2Standing at a busy street corner the same builds give 36 to 39 fps with far fewer long frames. The second and third pass over the same road are no better than the first, so it is not first-time loading of an area.
Where a long frame goes.
VICTORY_TIMELINE=95+110+125+150+165+180,45,<file>during the passes: 270 frames, 27 of them 50 ms or more. The chain each present came out of, averaged per frame:The title's own code grows by about 4 ms; the rows that are ours grow by about 20 ms. The lazy pages line at the end of that run: 179,779 pages touched by the title, 78,958 beside those, 1,971,132 mappings and 1,770,786 unmappings; one instruction of the title accounts for about a fifth of the title's faults.
What did not help (same route, same counting):
842767aagainst45591b0(the streaming worker count among the changes): the same within the spread above.VICTORY_LATE_FENCE=1, adaptive paging at 16 MB (on842767a): 471 frames >= 50 ms against 503 to 561.Sleep(0): about 220,000 calls a second here (it imports noSwitchToThread), three system calls each under Wine. Answering a thread's 17th call in a row with a 100 or 300 µs sleep took the calls down to about 3,000 a second and left the long frames where they were (540 to 593).What helped a little.
VICTORY_PAGES=0: 462 to 499 frames >= 50 ms and 91 to 95 >= 80 ms, against 459 to 658 and 112 to 161.Caveats. One machine; one timeline run with 27 long frames, so the proportions are rough; run to run the counts differ by up to 40 %. With no traffic the test is lighter than real play.
I am trying a wider fault-ahead (the 16 blocks in
watch::touched) and will add what it gives. The timeline files and the playback mod's source are available if they are of use.@Fran-co-F on GitHub · 2026-12-04 03:22 UTC · original
Same pattern on an RX 9070 XT, from 114
VICTORY_TIMELINEwindows (6,840 frames), with a few things that may add to it.Setup. Ryzen 7 9800X3D, RX 9070 XT 16 GB, 31 GB RAM, CachyOS (kernel 7.3.5), GE-Proton11-14, Mesa 26.3.1 with the project's patch.
mainat1152b9c(plus #69's texback patch, its switch off), diagnostics build, Series X, 1706x960 rendered to 2560x1440 output, ray tracing on. Pipelines warmed for this build (0 madeduring play). The route: the prison opening (Lucia, the guard, the fight), then driving through the city.How it was measured.
VICTORY_TIMELINE=25+26+...+99,60,<file>: each window begins as soon as the one before is written, so recording runs back to back over the session (about 3 s recorded, 4 to 9 s writing). Two sessions, 57 windows each.Where frames of 50 to 130 ms go (677 frames, mean 66.4 ms, against 4,960 frames under 35 ms, mean 24.6 ms), ms per frame from the chain each present came out of:
The title's own code grows by about 13 ms and its sleeps by about 5.5 ms; the rows that are ours add up to about 22 ms, close to your proportions on the 7900 XTX. The page residency thread shows up in the chain (2.8 ms) where it was small in yours.
Long list calls. Symbolized from the diagnostics build, they are the translation of
list::state::dispatch,list::execute_indirect,list::state::dispatch_meshandlist::state::draw(vialist::thin::run_plain). The longest single one in an earlier session's recorded frames was 50 ms.Guard faults. A
VICTORY_FAULT_BOOKrun over the prison part (19 books of 40 frames, 25 to 63 s): 10,066 write faults. The wait for the guards' lock is 0 at the median and 0.02 ms at p99, but reaches 74 ms (15 to 35 ms for a handful more), and those waits cluster in three of the 19 books: 80, 155 and 108 ms of waiting in all, against under 16 ms in the others. Time with the lock held: p99 0.19 ms, max 19 ms.A caveat on the worst frames. Four of my six sessions reached the run's
MemoryMaxand used the 2 GiB of swaprun.shallows (zram,vm.swappiness=150, CachyOS's default). The 240 to 580 ms frames I recorded (one 225 ms fault with nothing under it, a list thread idle for 578 ms with no span or wait) are likely that, so I left frames over 130 ms out of the table. Both timeline sessions reached the swap limit too, so some of the 50 to 130 ms frames may have a share of it; the hitches I notice in play peak around 120 ms either way.Happy to run any switch or diagnostics build on this route. The timeline files and fault books are available.
AI assistance: Claude Code (Claude Opus 5.5) set up the runs, ran the analysis and wrote this report; I played every run.
@Benflex1 on GitHub · 2026-12-04 03:32 UTC · original
Data from a related workload that may help here: camera turns on foot, on a fixed input replay of the prologue route.
VICTORY_TIMELINEover 15 windows × 60 frames.97c995cplus a few open PRs. The code paths below are unchanged on current main.Where a spike frame (≥ 50 ms) goes
CopyPageMappingsmuch more often. Each call is aJob::Mapon the line:LockCommandQueue(thequeue_drainedbarrier). The remap itself is about 13%.Job::Mapalso falls into the_ =>arm ofJob::goand is labelled "the line: a wait that is met" in timelines, which hides it.What removing each wait did
queue_drainedbefore page mappings (local experiment): map-job time −82%, but no pacing gain. The wait reappeared in "the line: a submission".VICTORY_HW_RT=1(on its own base, off vs on, separate caches): the only change that removed work instead of moving it.A replay pitfall worth knowing: 4 of about 30 replays here silently diverged; the player got stuck near the start, which is a lighter scene. Those runs had the fewest hitches and would have flipped two conclusions. The draw-count correlation did not catch them, but comparing screenshot thumbnails against a reference run at the same timestamps did.
On this route the limit looks like GPU work per frame during turns combined with the serial line. HW RT helps most; removing single waits mostly moves the stall. Happy to run specific builds or switches on the same replay.
@ramc1312 on GitHub · 2026-12-04 11:31 UTC · original
Follow-up, with thanks for the two reports above: they line up with what I see, and the note about silently diverged replays is well taken.
The playback changed, the conclusions did not. The mod no longer places the car on the path (that reset its suspension several times a second). It now sets only heading and forward speed toward the point the recording reaches 0.7 s ahead, and the car needs putting back on the path 0 to 4 times in three passes. Everything was run again that way on
45591b0(and842767awhere named), same route, three passes (147 s) per run; frames >= 50 ms / >= 80 ms:45591b0842767aVICTORY_LOD_SCALE=0.35VICTORY_LOD_SCALE=0.5VICTORY_LOD_SCALE=0.35 VICTORY_PAGES=0VICTORY_PAGES=0VICTORY_FRAME_INTERVAL_MS=33.333VICTORY_PAGE_ADAPTIVE=1VICTORY_KEEP_HOST_BUFFERS=1VICTORY_PARTS_ONE_CALL=1VICTORY_LATE_FENCE=1VICTORY_PAGES_SEEN=1VICTORY_SMALL_CULL=5.0VICTORY_WORLD_DIST_SCALE=0.45VICTORY_TILE_HEAP_MB=3977So: the detail distance is the one setting that halves the long frames here (and takes the average from about 30 to 35 fps); paging off helps some on its own and adds nothing on top of it; the rest is within or near the spread of the defaults (436 to 508). One
VICTORY_LOD_SCALE=0.2run ended in its second pass; I have not looked into why.Corrections to what I said I would try.
watch::touchedmade a switch): 16, 64, 256 and 1024 blocks give 420 to 594 frames >= 50 ms and 132,000 to 157,000 title faults a run, no trend. The blocks opened beside a fault stay at about 78,000 whatever the number, so the run after a faulting block is rarely contiguous and pending. One run with 256 stopped at the hang watch ("no frame begun for 10 s"); once in about thirty runs, and I cannot say it was the change.Sleep(0)experiment again, same result: 440/103 and 491/134 with the 100 µs sleep against 453/112 counting only.A second timeline with this playback (225 frames, only 10 of them >= 50 ms, so rough): a fault looked at 0.3 ms in frames under 35 ms and 8.0 ms in the long ones; the card running submissions 0.8 and 5.6; XMemMapPhysicalPages 0.2 and 4.1; a long list call 0.2 and 4.0; title threads outside our spans 16.7 and 20.1.
Still to come from here: #354 on this route, and the runs at a fixed time of day (they were not until now, which adds to the spread).
@ramc1312 on GitHub · 2026-12-04 12:10 UTC · original
#354 on this route, as promised: main at
0fd7614with #354 merged, the same build with and withoutVICTORY_SWEEP_SETTLE=1, interleaved, three passes (147 s) a run, now at a fixed noon with the clock stopped and clear weather. Frames >= 50 / >= 80 / >= 150 ms, worst:VICTORY_SWEEP_SETTLE=1(the drain every 1.5 s)The frames of 50 ms or more do not move (they are the streaming ones here); those of 80 ms or more are fewer without the drain, 66 to 95 against 99 to 113 leaving the third run with the drain aside. That third run is an outlier I cannot explain (29 frames over 150 ms, one of 603), so I would not read more into it than "not better with the drain". No hang, and the car followed the route in all seven (one run lost the car once and remade it). I did not compare pictures.