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

Open
opened 2026-11-27 21:03:46 +00:00 by Hayyan612 · 3 comments
Hayyan612 commented 2026-11-27 21:03:46 +00:00 (Migrated from github.com)
Contributor

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 from ExecuteCommandLists to 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 MTLParallelRenderCommandEncoder per 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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6654441976 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/461). Originally posted by [Hayyan612](https://github.com/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 from `ExecuteCommandLists` to 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 `MTLParallelRenderCommandEncoder` per 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.
AnastasisKon commented 2026-11-27 22:04:51 +00:00 (Migrated from github.com)
Author
Contributor

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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229009722 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/461#issuecomment-7229009722). Originally posted by [AnastasisKon](https://github.com/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.
github-actions[bot] commented 2026-11-27 22:05:02 +00:00 (Migrated from github.com)
Author
Contributor

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 #461 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229012404 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/461#issuecomment-7229012404). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T22:05:02Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #461` in its description within 24 hours, or the claim expires.
maaalrey commented 2026-11-28 05:57:23 +00:00 (Migrated from github.com)
Author
Contributor

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 2f4d81e0 plus #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 with VICTORY_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 commands

commands in the execution executions a second prep, each prep, ms a second encode+commit, each encode+commit, ms a second
0 26.6 0.7 ms 20 0.0 ms 0
1 to 99 16.0 1.5 ms 25 0.14 ms 2
100 to 999 11.4 13.2 ms 150 1.07 ms 12
1,000 and more 2.3 91.2 ms 207 11.6 ms 26
all 56.3 7.1 ms 401 0.7 ms 41

The lines count every execute of the host: 26 a second are ExecuteCommandLists calls (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:

site calls a second held, ms a second waited, ms a second
glue::submit, the last with_title (glue.rs:299): the submission itself 26 344 0
glue::submit, the first with_title (glue.rs:286): probes and jobs for the texture sync 26 285 0
the refresh timer 201 96 654
glue::mirror (glue.rs:1058) 36,355 81 1,581

One caution about the 285: keep_named was 131 ms a second of it. It runs only when names_wanted is 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, and keep_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=2 in 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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7234988921 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/461#issuecomment-7234988921). Originally posted by [maaalrey](https://github.com/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 2f4d81e0 plus #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 with `VICTORY_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 commands | commands in the execution | executions a second | prep, each | prep, ms a second | encode+commit, each | encode+commit, ms a second | |---|---|---|---|---|---| | 0 | 26.6 | 0.7 ms | 20 | 0.0 ms | 0 | | 1 to 99 | 16.0 | 1.5 ms | 25 | 0.14 ms | 2 | | 100 to 999 | 11.4 | 13.2 ms | 150 | 1.07 ms | 12 | | 1,000 and more | 2.3 | 91.2 ms | 207 | 11.6 ms | 26 | | all | 56.3 | 7.1 ms | 401 | 0.7 ms | 41 | The lines count every `execute` of the host: 26 a second are `ExecuteCommandLists` calls (`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: | site | calls a second | held, ms a second | waited, ms a second | |---|---|---|---| | `glue::submit`, the last `with_title` (glue.rs:299): the submission itself | 26 | 344 | 0 | | `glue::submit`, the first `with_title` (glue.rs:286): probes and jobs for the texture sync | 26 | 285 | 0 | | the refresh timer | 201 | 96 | 654 | | `glue::mirror` (glue.rs:1058) | 36,355 | 81 | 1,581 | One caution about the 285: `keep_named` was 131 ms a second of it. It runs only when `names_wanted` is 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, and `keep_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=2` in 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS#461
No description provided.