Proposal: measure the CPU time a world frame's submissions take on the native host, and if it is large, encode them on several threads #461
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Hayyan612 on 2026-11-27T21:03:46Z.
On the Wine route, #47 measured a world frame as 121.8 ms preparing + 125.2 ms waiting on the GPU + 52.8 ms copying back, one after another on one thread. cool_fox (Windows) prepares submission parts on 8 threads and joins them in order (
VICTORY_ASYNC_SUBMIT,VICTORY_JOIN_PARTS).Step 1:
VICTORY_SUBMIT_TIMING=1(off by default), logging the CPU time fromExecuteCommandListsto commit per submission, split into translation, encoding and memory syncs, so the native path's share is known.Step 2, if it is large: encode a submission's parts into separate command buffers on worker threads (or one
MTLParallelRenderCommandEncoderper render pass) and commit them in the title's order. Apple Silicon has 8 to 14 cores, mostly idle while one thread encodes.Not claiming. Happy to write step 1.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T22:04:51Z.
/claim
Taking step 1 only: VICTORY_SUBMIT_TIMING=1, per-ExecuteCommandLists CPU time from entry to commit, split into prep (page following, per-command preparation: translation, descriptor remirror, memory syncs) and encode+commit. One PR.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T22:05:02Z.
Claimed by @AnastasisKon. Open a draft pull request with
Refs #461in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-28T05:57:23Z.
Step 1's numbers from a Mac that is not short of memory, in case they help decide step 2.
M4 Max, 128 GB, macOS 27.2.1, Apple's Metal Shader Converter 4.0 beta 3, Series S, windowed, shader and pipeline caches from earlier runs. Main
2f4d81e0plus #565 (the save does not load here without it) and the sound output silenced. A story save is loaded and left standing in the world; the figures are over the 214 s of world in one run withVICTORY_SUBMIT_TIMING=1 VICTORY_TRACE_TITLE_LOCK=1 VICTORY_TRACE_TEXTURE_SYNC=1. That run made 1.27 fps in the world (256 frames in 201 s, between the first and last frame-count lines of the world; single 64-frame intervals ran from 1.0 to 1.9), with about 7,000 draws a frame, 13% of them without a pipeline. The same setup without the three switches made 1.37.submit timing, by the number of commandsThe lines count every
executeof the host: 26 a second areExecuteCommandListscalls (glue::submit), and the 26.6 a second with no commands are the queues' fence signals and waits. About 11,800 commands a second: roughly 34 µs of prep and 3.5 µs of encode+commit per command on average (30 µs of prep in the big ones). The longest prep was 307 ms. The times are wall time, as the switch measures them.So on this Mac the time in submissions is the preparation, about ten to one, and encoding on several threads would work on at most 41 of about 440 ms a second.
The title lock in the same seconds
Held 902 ms of each second; the title's threads waited 4.4 s a second for it, summed. The sites that hold it most, by the line they have on that commit:
glue::submit, the lastwith_title(glue.rs:299): the submission itselfglue::submit, the firstwith_title(glue.rs:286): probes and jobs for the texture syncglue::mirror(glue.rs:1058)One caution about the 285:
keep_namedwas 131 ms a second of it. It runs only whennames_wantedis true (over budget, a texture given up, or the texture trace due). No budget was set here, but placed copies that another placement covered were given up in 97 of the 203 seconds, andkeep_named's time in a second was more than the longest single hold at that line in 208 of 213 seconds, so it ran at more than one submission a second and the trace is not the only reason. I did not measure how much of it a run without the three switches still pays. The 344 is less than the 442 of prep plus encode+commit because the executions without lists run from other sites.Texture sync, averaged per second
271 textures and 206 MiB read; 114 of them unchanged, 94 partly unreadable, 35 for the first time. Under the lock: probes 54 ms, blank ones 54 ms, uploads 18 ms. Off it: 134 ms.
VICTORY_TEXTURE_DROP_TOP_MIP=2in a third run: 1.37 fps against 1.37, one run each, measured the same way.One run of each kind; I can repeat any of it, or run a branch.