World frame rate: texture sync still reads unchanged textures whole (~410 MiB/s); about 1.7 fps now #179

Open
opened 2026-11-26 23:14:54 +00:00 by LakshanSivakumar · 26 comments
LakshanSivakumar commented 2026-11-26 23:14:54 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T23:14:54Z.


On main, a world frame takes about 1.6–1.7 s of CPU (about 0.5 fps on an M5 Pro, 48 GB). A call profile and stack samples of the world (warm run, 60 s window) put almost all of it in the queue's ExecuteCommandLists: 53.4 s of 60 s.

Inside it, Title::sync_dirty → sync_keys runs on the submit thread, under the host's global lock. For each texture that's unloaded or changed, one by one, it:

  • reads the texture's memory whole (mach_vm_read_overwrite, ~42 %);
  • hashes it (blake3, ~7 %);
  • detiles it and uploads it (textures::upload, ~50 %).

World streaming feeds it all the time. The other title threads queue behind the lock: ResetX and placed-view calls show 100 s and 63 s of waiting per 60 s. Metal encoding didn't show up in any sample, and creating a view plus a heap entry costs about 2 µs, so neither of those is the cost.

Being fixed in two parts:

  1. Skip textures that haven't changed, or are blank, before reading them whole.
  2. Move read, hash and detile off the lock, so only the upload holds it.

An off-by-default VICTORY_TRACE_TEXTURE_SYNC=1 (textures and MiB per second, unchanged or blank counts, ms per step) will land with it.

Related: #47 (where a world frame goes on the Wine route).

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6636632822 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T23:14:54Z. --- On main, a world frame takes about 1.6–1.7 s of CPU (about 0.5 fps on an M5 Pro, 48 GB). A call profile and stack samples of the world (warm run, 60 s window) put almost all of it in the queue's `ExecuteCommandLists`: **53.4 s of 60 s**. Inside it, `Title::sync_dirty` → `sync_keys` runs on the submit thread, under the host's global lock. For each texture that's unloaded or changed, one by one, it: - reads the texture's memory whole (`mach_vm_read_overwrite`, ~42 %); - hashes it (blake3, ~7 %); - detiles it and uploads it (`textures::upload`, ~50 %). World streaming feeds it all the time. The other title threads queue behind the lock: `ResetX` and placed-view calls show 100 s and 63 s of waiting per 60 s. Metal encoding didn't show up in any sample, and creating a view plus a heap entry costs about 2 µs, so neither of those is the cost. Being fixed in two parts: 1. Skip textures that haven't changed, or are blank, before reading them whole. 2. Move read, hash and detile off the lock, so only the upload holds it. An off-by-default `VICTORY_TRACE_TEXTURE_SYNC=1` (textures and MiB per second, unchanged or blank counts, ms per step) will land with it. Related: #47 (where a world frame goes on the Wine route).
Olima34 commented 2026-11-26 23:53:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T23:53:40Z.


A data point for part 2 of this, since we tried the same idea locally. It is not conclusive, so take it as a caution, not a result.

Apple M5 Pro, 48 GB, Series S, windowed, warm cache.

  • Base (49b5521b plus diagnostics only):
    • after frame 2300, submit holds the title lock 3.65 s per 5 s window;
    • frames 2300→2700 take 26 s;
    • reached frame 2974, no crash.
  • Off-lock sync: under the lock, only planning (snapshotting what to sync) and the upload; read, hash and detile run on 6 worker threads in batches of up to 256 MiB of detiled copies.
    • The lock holds per window spread out: ~0.3 s planning, ~0.44 s apply plus encode, and 1.1 s at a site I couldn't identify.
    • But frames 2304→2418 took 48 s, slower than the base.
    • Then 7 kIOGPUCommandBufferCallbackErrorTimeout and "held for a wait", and the title watchdog at +186 s.
    • A minute later the whole Mac's WindowServer froze (userspace_watchdog_timeout). Other builds were running at the same time, so that run is unreliable.

What I'd watch, as guesses: the worker threads competing with the title's own threads under Rosetta, and the memory held by large detiled batches. Part 1 of your plan (skip unchanged or blank textures before reading them whole) may matter more than moving the work off the lock. I'm not pursuing this further; it's yours.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7205966055 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7205966055). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-26T23:53:40Z. --- A data point for part 2 of this, since we tried the same idea locally. It is **not conclusive**, so take it as a caution, not a result. Apple M5 Pro, 48 GB, Series S, windowed, warm cache. - **Base** (`49b5521b` plus diagnostics only): - after frame 2300, `submit` holds the title lock **3.65 s per 5 s window**; - frames 2300→2700 take **26 s**; - reached frame 2974, no crash. - **Off-lock sync**: under the lock, only planning (snapshotting what to sync) and the upload; read, hash and detile run on 6 worker threads in batches of up to 256 MiB of detiled copies. - The lock holds per window spread out: ~0.3 s planning, ~0.44 s apply plus encode, and 1.1 s at a site I couldn't identify. - But frames 2304→2418 took **48 s**, slower than the base. - Then 7 `kIOGPUCommandBufferCallbackErrorTimeout` and "held for a wait", and the title watchdog at +186 s. - A minute later the whole Mac's WindowServer froze (`userspace_watchdog_timeout`). Other builds were running at the same time, so that run is unreliable. What I'd watch, as guesses: the worker threads competing with the title's own threads under Rosetta, and the memory held by large detiled batches. Part 1 of your plan (skip unchanged or blank textures before reading them whole) may matter more than moving the work off the lock. I'm not pursuing this further; it's yours.
LakshanSivakumar commented 2026-11-27 01:03:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T01:03:30Z.


Landed 2d4cd0a1: a submission's textures are read, hashed and detiled off the host lock, gathered without a list search each, and a render target remade under a released key starts over in the scanner. Warm runs, world frames a second over 30-150 s after the world starts: 0.38 before, 1.17 with reads off the lock, 1.73 with the full change (one run reached 2.57 over its last 75 s). Measured before the last two main merges. Still open: unchanged textures are still read whole (about 410 MiB a second), and nearly half the textures read are not readable at once and go page by page. VICTORY_TRACE_TEXTURE_SYNC=1 shows the numbers.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7206975280 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7206975280). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T01:03:30Z. --- Landed 2d4cd0a1: a submission's textures are read, hashed and detiled off the host lock, gathered without a list search each, and a render target remade under a released key starts over in the scanner. Warm runs, world frames a second over 30-150 s after the world starts: 0.38 before, 1.17 with reads off the lock, 1.73 with the full change (one run reached 2.57 over its last 75 s). Measured before the last two main merges. Still open: unchanged textures are still read whole (about 410 MiB a second), and nearly half the textures read are not readable at once and go page by page. `VICTORY_TRACE_TEXTURE_SYNC=1` shows the numbers.
Sheffy007 commented 2026-11-27 10:59:45 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T10:59:45Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216553662 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7216553662). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T10:59:45Z. --- /claim
github-actions[bot] commented 2026-11-27 10:59:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T10:59:56Z.


Claimed by @Sheffy007. Open a draft pull request with Refs #179 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216556999 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7216556999). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T10:59:56Z. --- Claimed by @Sheffy007. Open a draft pull request with `Refs #179` in its description within 24 hours, or the claim expires.
Sheffy007 commented 2026-11-27 17:11:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T17:11:38Z.


/release

#326 (reverse-mip chain probe sampling + coalesced contiguous pool reads) is now merged on main (061ba4da). Releasing the claim so anyone with a warm world setup can measure or take the next slice.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7224132680 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7224132680). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T17:11:38Z. --- /release #326 (reverse-mip chain probe sampling + coalesced contiguous pool reads) is now merged on `main` (`061ba4da`). Releasing the claim so anyone with a warm world setup can measure or take the next slice.
derz92 commented 2026-11-27 22:32:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T22:32:11Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229409382 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7229409382). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T22:32:11Z. --- /claim
github-actions[bot] commented 2026-11-27 22:32:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T22:32:23Z.


@derz92 this is already claimed by @Sheffy007. Pick another issue, or ask them here.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229412159 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7229412159). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T22:32:23Z. --- @derz92 this is already claimed by @Sheffy007. Pick another issue, or ask them here.
derz92 commented 2026-11-27 22:34:00 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T22:34:00Z.


@Sheffy007, your /release above (17:11) doesn't seem to have cleared the claim: the bot still lists you. Are you OK with me taking the next slice of this? It's small and measured:

  • Change: the hot and blank texture probes (PROBE_BUDGET, 2 ms a round) get one budget per presented frame instead of one per submission. It's opt-in, VICTORY_PROBE_PER_FRAME=1.
  • Why: a world frame here makes about 17 submissions, and probing at each held the host lock for about 70 ms of the frame (hold_sync).
  • A/B: one binary, warm cache, M5 Max, Series S, two runs each way, median of the last 100 world frames. Probes per submission: 417 ms (the other "off" run froze, #456, so it can't be compared). Probes per frame: 362 and 363 ms, with hold_sync going from 71 to 23–49 ms. That's about 13% faster.
  • Trade-off: a texture the title writes can be noticed up to a frame later, unless the scanner catches it first. It's off by default for that reason.

If you'd rather keep it, no problem; I'll drop it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229434759 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7229434759). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T22:34:00Z. --- @Sheffy007, your `/release` above (17:11) doesn't seem to have cleared the claim: the bot still lists you. Are you OK with me taking the next slice of this? It's small and measured: - **Change:** the hot and blank texture probes (`PROBE_BUDGET`, 2 ms a round) get one budget per presented frame instead of one per submission. It's opt-in, `VICTORY_PROBE_PER_FRAME=1`. - **Why:** a world frame here makes about 17 submissions, and probing at each held the host lock for about 70 ms of the frame (`hold_sync`). - **A/B:** one binary, warm cache, M5 Max, Series S, two runs each way, median of the last 100 world frames. Probes per submission: 417 ms (the other "off" run froze, #456, so it can't be compared). Probes per frame: 362 and 363 ms, with `hold_sync` going from 71 to 23–49 ms. That's about 13% faster. - **Trade-off:** a texture the title writes can be noticed up to a frame later, unless the scanner catches it first. It's off by default for that reason. If you'd rather keep it, no problem; I'll drop it.
Sheffy007 commented 2026-11-28 03:02:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-28T03:02:08Z.


/release

@derz92 released via the bot now — all yours, nice measurement on VICTORY_PROBE_PER_FRAME!

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232751051 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7232751051). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-28T03:02:08Z. --- /release @derz92 released via the bot now — all yours, nice measurement on VICTORY_PROBE_PER_FRAME!
github-actions[bot] commented 2026-11-28 03:02:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T03:02:17Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232752665 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7232752665). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T03:02:17Z. --- Released. This issue is free to claim.
AnastasisKon commented 2026-11-28 10:53:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T10:53:36Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7238190062 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7238190062). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T10:53:36Z. --- /claim
github-actions[bot] commented 2026-11-28 10:53:45 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T10:53:45Z.


Claimed by @AnastasisKon. Open a draft pull request with Refs #179 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7238191783 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7238191783). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T10:53:45Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #179` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-28 12:30:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:30:01Z.


Perf batch in flight from my fork, all Refs #179, CI green on each unless noted:

  • #603 hash big texture syncs on the rayon pool (blake3 update_rayon >= 1 MiB)
  • #604 detile big textures mip/slice-parallel on the rayon pool
  • #605 read big texture memory chunk-parallel (read_into), scanner big path included
  • #608 scanner rounds themselves run over the rayon pool (per-entry scan_one + one apply pass)
  • #610 big whole probes read chunk-parallel
  • #609 eight TEB-only/constant kernel functions (Get/SetLastError, TlsGet/SetValue, GetCurrentThread/Process(Id)) bound with no bridge swap — removes the ~370 ns GS swap per call (docs/native-host.md's "next step")
  • #595 (earlier) scanner stash + adaptive sync threads

Game folder on the external SSD is still downloading (no PE exe yet), so no in-game run numbers from my side yet.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239269463 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7239269463). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:30:01Z. --- Perf batch in flight from my fork, all `Refs #179`, CI green on each unless noted: - #603 hash big texture syncs on the rayon pool (blake3 update_rayon >= 1 MiB) - #604 detile big textures mip/slice-parallel on the rayon pool - #605 read big texture memory chunk-parallel (read_into), scanner big path included - #608 scanner rounds themselves run over the rayon pool (per-entry scan_one + one apply pass) - #610 big whole probes read chunk-parallel - #609 eight TEB-only/constant kernel functions (Get/SetLastError, TlsGet/SetValue, GetCurrentThread/Process(Id)) bound with no bridge swap — removes the ~370 ns GS swap per call (docs/native-host.md's "next step") - #595 (earlier) scanner stash + adaptive sync threads Game folder on the external SSD is still downloading (no PE exe yet), so no in-game run numbers from my side yet.
4TheDoctor commented 2026-11-28 20:24:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by 4TheDoctor on 2026-11-28T20:24:43Z.


Numbers from an M3 Max (48 GB, macOS 27.2.1, Series X) on main 26817285, with VICTORY_TRACE_TEXTURE_SYNC=1. They cover loading and world entry only: the run crashed about 4 minutes in, an unhandled 0xc0000005 at image+0x55e56f8. Medians of 153 one-second lines with at least 300 textures:

Per second
textures synced 1,343 (740 MiB)
first time 191
unchanged 258
partly unreadable 581
under the lock: hot probes / blank probes / uploads 72 / 74 / 86 ms
sync threads: read / hash / detile 374 / 453 / 96 ms

Detiling is the smallest part here. Most of the time goes to finding out what changed (reading whole and hashing), and to textures retried while their pages aren't readable yet.

@AnastasisKon your rayon batch makes those reads and hashes faster. I'd like to take the complementary part, if that doesn't step on your claim: a per-page change test, so a texture nobody wrote since its last sync is skipped without being read or hashed. victory-platform::watch already has the signal-safe mechanism for the descriptor trace (pages made read-only, the write fault reopens the page and records it, the next interval closes them again). The plan is to generalize it to a dirty-page bitmap over the pool pages that sampled textures live on. Then a texture is read only when one of its pages is dirty, and a partly unreadable texture is retried only once its pages are mapped.

Two things I'd handle first:

  • host writes that don't fault, like file reads straight into title memory (DirectStorage), would fail on a read-only page instead of faulting, so those paths open the pages first and mark them dirty;
  • the cost of a write fault under Rosetta, measured per fault before it goes on by default.

It would land behind an off-by-default switch with the trace numbers above, as a separate PR with Refs #179. Is that OK with you and @LakshanSivakumar, or is someone already on it?

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245266669 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245266669). Originally posted by [4TheDoctor](https://github.com/4TheDoctor) on 2026-11-28T20:24:43Z. --- Numbers from an M3 Max (48 GB, macOS 27.2.1, Series X) on main `26817285`, with `VICTORY_TRACE_TEXTURE_SYNC=1`. They cover loading and world entry only: the run crashed about 4 minutes in, an unhandled 0xc0000005 at image+0x55e56f8. Medians of 153 one-second lines with at least 300 textures: | Per second | | | --- | --- | | textures synced | 1,343 (740 MiB) | | first time | 191 | | unchanged | 258 | | partly unreadable | 581 | | under the lock: hot probes / blank probes / uploads | 72 / 74 / 86 ms | | sync threads: read / hash / detile | 374 / 453 / 96 ms | Detiling is the smallest part here. Most of the time goes to finding out what changed (reading whole and hashing), and to textures retried while their pages aren't readable yet. @AnastasisKon your rayon batch makes those reads and hashes faster. I'd like to take the complementary part, if that doesn't step on your claim: a per-page change test, so a texture nobody wrote since its last sync is skipped without being read or hashed. `victory-platform::watch` already has the signal-safe mechanism for the descriptor trace (pages made read-only, the write fault reopens the page and records it, the next interval closes them again). The plan is to generalize it to a dirty-page bitmap over the pool pages that sampled textures live on. Then a texture is read only when one of its pages is dirty, and a partly unreadable texture is retried only once its pages are mapped. Two things I'd handle first: - host writes that don't fault, like file reads straight into title memory (DirectStorage), would fail on a read-only page instead of faulting, so those paths open the pages first and mark them dirty; - the cost of a write fault under Rosetta, measured per fault before it goes on by default. It would land behind an off-by-default switch with the trace numbers above, as a separate PR with `Refs #179`. Is that OK with you and @LakshanSivakumar, or is someone already on it?
AnastasisKon commented 2026-11-28 20:32:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T20:32:37Z.


Unclaiming this one — I am not working on it and nobody should hold it blocked on me. cc @4thedoctor (notified per request).

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245362404 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245362404). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T20:32:37Z. --- Unclaiming this one — I am not working on it and nobody should hold it blocked on me. cc @4thedoctor (notified per request).
4TheDoctor commented 2026-11-28 20:35:44 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by 4TheDoctor on 2026-11-28T20:35:44Z.


Correction to my plan above, after reading the code. Page protection is the wrong first step on the native host:

  • Rosetta. docs/macos.md ("Masked stores into protected pages hang Rosetta"): an AVX masked store, or a vcvtps2ph/vextract*128 store, that starts writable and ends in a protected page hangs the process. masked::patch is #[cfg(windows)] (victory-loader/src/masked.rs:389), so the native host has no cover for that.
  • Writers a protection can't see. DirectStorage page destinations write through the pool base (xmem_physical.rs:11-13, PageWindow/write_physical; report_written is a no-op on macOS). GPU Copy/Fill/UAV writes don't fault either, and a remap resets the protection.
  • Writers it would break. ReadFile, fread and uncompressed DirectStorage reads pread straight into title memory, and they'd get EFAULT.

So the revised plan is to know who writes instead of catching every write:

  1. Measure first. A trace that tags each texture the scanner finds changed with whether a known writer touched its range since the last sync: DirectStorage (both destination kinds), GPU writes at fence completion, or a mapping change. If known writers explain most changes, the rest is worth doing.
  2. Partly unreadable textures wait for their mapping. They wait on PoolTable::signature/generation() instead of being retried every scanner round and every job. On my run that's 43 % of what is synced each second.
  3. Event-sourced dirty marks. Those writers mark textures dirty directly, so a texture only they write is never hashed to find out.
  4. Later, only if needed: port the masked-store patch to the native loader. Page protection would then be possible for the textures the title writes on the CPU.

None of this overlaps the rayon batch. I'd start with 1 and 2, behind off-by-default switches, Refs #179, unless you'd rather I open a separate issue for them.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245401044 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245401044). Originally posted by [4TheDoctor](https://github.com/4TheDoctor) on 2026-11-28T20:35:44Z. --- Correction to my plan above, after reading the code. Page protection is the wrong first step on the native host: - **Rosetta.** `docs/macos.md` ("Masked stores into protected pages hang Rosetta"): an AVX masked store, or a `vcvtps2ph`/`vextract*128` store, that starts writable and ends in a protected page hangs the process. `masked::patch` is `#[cfg(windows)]` (`victory-loader/src/masked.rs:389`), so the native host has no cover for that. - **Writers a protection can't see.** DirectStorage page destinations write through the pool base (`xmem_physical.rs:11-13`, `PageWindow`/`write_physical`; `report_written` is a no-op on macOS). GPU Copy/Fill/UAV writes don't fault either, and a remap resets the protection. - **Writers it would break.** `ReadFile`, `fread` and uncompressed DirectStorage reads `pread` straight into title memory, and they'd get EFAULT. So the revised plan is to know who writes instead of catching every write: 1. **Measure first.** A trace that tags each texture the scanner finds changed with whether a known writer touched its range since the last sync: DirectStorage (both destination kinds), GPU writes at fence completion, or a mapping change. If known writers explain most changes, the rest is worth doing. 2. **Partly unreadable textures wait for their mapping.** They wait on `PoolTable::signature`/`generation()` instead of being retried every scanner round and every job. On my run that's 43 % of what is synced each second. 3. **Event-sourced dirty marks.** Those writers mark textures dirty directly, so a texture only they write is never hashed to find out. 4. **Later, only if needed:** port the masked-store patch to the native loader. Page protection would then be possible for the textures the title writes on the CPU. None of this overlaps the rayon batch. I'd start with 1 and 2, behind off-by-default switches, `Refs #179`, unless you'd rather I open a separate issue for them.
AnastasisKon commented 2026-11-28 20:44:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T20:44:15Z.


Yes to both: take 1 (the writer trace) and 2 (partly-unreadable textures waiting on PoolTable::signature/generation), behind off-by-default switches, Refs #179, as your own PR. No overlap with the rayon batch.

Two notes from our fork: the native host's write-trap instrumentation is being rebuilt right now (AnastasisKon/Native-Victory-macOS #75, #78) so it logs its arming and first hits — that should give you the per-writer evidence for item 1 before you add new switches. And your Rosetta masked-store caution is exactly why: a trap that fails silently reads as a negative result, which cost us a wrong conclusion on the boot blocker.

On your crash 4 minutes in at image+0x55e56f8: that is the title's own crash reporter dereferencing a null list, documented in our docs/native-host.md — downstream of whatever faulted first, not a new blocker.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245503039 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245503039). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T20:44:15Z. --- Yes to both: take 1 (the writer trace) and 2 (partly-unreadable textures waiting on PoolTable::signature/generation), behind off-by-default switches, Refs #179, as your own PR. No overlap with the rayon batch. Two notes from our fork: the native host's write-trap instrumentation is being rebuilt right now (AnastasisKon/Native-Victory-macOS #75, #78) so it logs its arming and first hits — that should give you the per-writer evidence for item 1 before you add new switches. And your Rosetta masked-store caution is exactly why: a trap that fails silently reads as a negative result, which cost us a wrong conclusion on the boot blocker. On your crash 4 minutes in at image+0x55e56f8: that is the title's own crash reporter dereferencing a null list, documented in our docs/native-host.md — downstream of whatever faulted first, not a new blocker.
4TheDoctor commented 2026-11-28 20:44:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by 4TheDoctor on 2026-11-28T20:44:53Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245510618 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245510618). Originally posted by [4TheDoctor](https://github.com/4TheDoctor) on 2026-11-28T20:44:53Z. --- /claim
github-actions[bot] commented 2026-11-28 20:45:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T20:45:01Z.


@4TheDoctor this is already claimed by @AnastasisKon. Pick another issue, or ask them here.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245511987 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245511987). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T20:45:01Z. --- @4TheDoctor this is already claimed by @AnastasisKon. Pick another issue, or ask them here.
4TheDoctor commented 2026-11-28 20:45:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by 4TheDoctor on 2026-11-28T20:45:42Z.


Thanks @AnastasisKon, that settles it, and thanks for the pointer on the crash. The claim bot still has you on this one, so could you comment /release? Then I'll claim it and open the draft PR for 1 and 2 with Refs #179 within the 24 hours. I'll look at your fork's write-trap work (#75, #78) before adding switches for item 1.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245520190 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245520190). Originally posted by [4TheDoctor](https://github.com/4TheDoctor) on 2026-11-28T20:45:42Z. --- Thanks @AnastasisKon, that settles it, and thanks for the pointer on the crash. The claim bot still has you on this one, so could you comment `/release`? Then I'll claim it and open the draft PR for 1 and 2 with `Refs #179` within the 24 hours. I'll look at your fork's write-trap work (#75, #78) before adding switches for item 1.
AnastasisKon commented 2026-11-28 21:03:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T21:03:57Z.


/release

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245746104 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245746104). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T21:03:57Z. --- /release
github-actions[bot] commented 2026-11-28 21:04:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T21:04:07Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245748165 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7245748165). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T21:04:07Z. --- Released. This issue is free to claim.
4TheDoctor commented 2026-11-28 21:37:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by 4TheDoctor on 2026-11-28T21:37:46Z.


For the record: #578 says nothing new lands in this repository, so item 1 went to AnastasisKon's fork as a draft: AnastasisKon/Native-Victory-macOS#80. It adds VICTORY_TRACE_TEXTURE_WRITERS=1. Each time a texture is read again, the trace says what changed its memory since the last read: DirectStorage, a mapping change, both, or neither.

The short version, from two 300 s runs on an M3 Max (Series X, into the prologue world). The storm of re-read textures this issue was about is not on that fork's main. Comparing it with this repository's main 26817285, per second:

  • textures already uploaded that changed again: 737 → 1–3
  • time under the TITLE lock: 213 → 14–21 ms

The few re-reads left all fall under "neither". DirectStorage does report its writes (about 90 MiB/s), but none of them land in a texture the sync already holds. So item 2 (partly unreadable textures waiting on the mapping) has nothing left to win there, and I am not doing it. The tables are in the PR.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7246156385 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7246156385). Originally posted by [4TheDoctor](https://github.com/4TheDoctor) on 2026-11-28T21:37:46Z. --- For the record: #578 says nothing new lands in this repository, so item 1 went to AnastasisKon's fork as a draft: AnastasisKon/Native-Victory-macOS#80. It adds `VICTORY_TRACE_TEXTURE_WRITERS=1`. Each time a texture is read again, the trace says what changed its memory since the last read: DirectStorage, a mapping change, both, or neither. The short version, from two 300 s runs on an M3 Max (Series X, into the prologue world). The storm of re-read textures this issue was about is not on that fork's `main`. Comparing it with this repository's `main` 26817285, per second: - textures already uploaded that changed again: 737 → 1–3 - time under the `TITLE` lock: 213 → 14–21 ms The few re-reads left all fall under "neither". DirectStorage does report its writes (about 90 MiB/s), but none of them land in a texture the sync already holds. So item 2 (partly unreadable textures waiting on the mapping) has nothing left to win there, and I am not doing it. The tables are in the PR.
AnastasisKon commented 2026-11-29 14:27:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-29T14:27:55Z.


Measured on the now-complete data folder (209 GB; the archives stopped changing on 28 Nov), one 120 s headless Series X run on an M3 Pro / 36 GB. This does not fix the issue; it narrows what costs the frame, and it contradicts one of the two suspects in ROADMAP.md.

Texture sync is not what costs the frame outside the world. The roadmap's leading suspect was the scanner re-hashing every watched texture each round ("not measured on a world run yet"). Over the whole boot-to-prologue run, VICTORY_TRACE_TEXTURE_SYNC=1 gives 46,554 textures in 1,604 batches, 17.2 GiB, while the menus held 30 fps:

  • 93.9% of syncs were first uploads and only 2.1% were found unchanged, so the unchanged-texture fast path (and the #595 stash, which saves the second read of a changed texture) has little to save in this phase.
  • The cost is spread, not blocking a frame: hashing 20.7 s of one core (18.4% of wall time), detile 8.3 s, reading title memory 14.7 s; the TITLE lock was held 5.9 s for uploads and 2.2 s for blank probes (7.8% in all).
  • 11.8% of syncs (5,488) met memory that could not be read at once.
  • A wider read pool is not the lever either: a warm-cache run with VICTORY_PREWARM_WORKERS=10 moved the median 30.0 to 29.5 fps.

The slow seconds in that same run are the DirectStorage poll. Frames ~1024 and ~2300 on drop from 30 to 17-20 fps, and those seconds are the ones full of dstorage: a status entry is still pending (one line per 5,000 polls). The counter reached 4,970,000 in 118 s: ~42,000 polls a second across the run, ~650,000 a second inside a dip, with the lane holding 12 running 64 KiB reads of G:\shaders.rpf and up to ~470 more queued. The boot-phase figure already in native-host.md is 20,000 polls in 20 s (1,000 a second), so the world load polls 40 times denser, and what it waits on is the shader archive rather than the ttpf data.

Shader translation is absorbed, so it is not the wait either. The cold run made 422 cache-miss translations worth 450 s of work (121 past 0.5 s, the longest 16.3 s) and still held 30 fps in the menus, because the prewarm pool takes it off the title's thread; first binds fall from 2,147 on a cold cache to 37 once warm.

So the next thing to attack for world frame rate is the poll loop and the read latency behind it, not the scanner. Per-second figures and command lines are in the pull request.

VICTORY_TRACE_TEXTURE_SYNC=1 VICTORY_PAIRED_WAVES=1 /usr/bin/lockf -k /tmp/victory-game.lock \
  timeout 150 nice -n 10 tools/macos/run-native.sh --headless --seconds 120 --console series-x \
  "<data folder>"
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7257323339 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7257323339). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-29T14:27:55Z. --- Measured on the now-complete data folder (209 GB; the archives stopped changing on 28 Nov), one 120 s headless Series X run on an M3 Pro / 36 GB. This does not fix the issue; it narrows what costs the frame, and it contradicts one of the two suspects in ROADMAP.md. **Texture sync is not what costs the frame outside the world.** The roadmap's leading suspect was the scanner re-hashing every watched texture each round ("not measured on a world run yet"). Over the whole boot-to-prologue run, `VICTORY_TRACE_TEXTURE_SYNC=1` gives 46,554 textures in 1,604 batches, 17.2 GiB, while the menus held 30 fps: - 93.9% of syncs were first uploads and only 2.1% were found unchanged, so the unchanged-texture fast path (and the #595 stash, which saves the second read of a *changed* texture) has little to save in this phase. - The cost is spread, not blocking a frame: hashing 20.7 s of one core (18.4% of wall time), detile 8.3 s, reading title memory 14.7 s; the `TITLE` lock was held 5.9 s for uploads and 2.2 s for blank probes (7.8% in all). - 11.8% of syncs (5,488) met memory that could not be read at once. - A wider read pool is not the lever either: a warm-cache run with `VICTORY_PREWARM_WORKERS=10` moved the median 30.0 to 29.5 fps. **The slow seconds in that same run are the DirectStorage poll.** Frames ~1024 and ~2300 on drop from 30 to 17-20 fps, and those seconds are the ones full of `dstorage: a status entry is still pending` (one line per 5,000 polls). The counter reached 4,970,000 in 118 s: ~42,000 polls a second across the run, ~650,000 a second inside a dip, with the lane holding 12 running 64 KiB reads of `G:\shaders.rpf` and up to ~470 more queued. The boot-phase figure already in native-host.md is 20,000 polls in 20 s (1,000 a second), so the world load polls 40 times denser, and what it waits on is the shader archive rather than the `ttpf` data. **Shader translation is absorbed, so it is not the wait either.** The cold run made 422 cache-miss translations worth 450 s of work (121 past 0.5 s, the longest 16.3 s) and still held 30 fps in the menus, because the prewarm pool takes it off the title's thread; first binds fall from 2,147 on a cold cache to 37 once warm. So the next thing to attack for world frame rate is the poll loop and the read latency behind it, not the scanner. Per-second figures and command lines are in the pull request. ``` VICTORY_TRACE_TEXTURE_SYNC=1 VICTORY_PAIRED_WAVES=1 /usr/bin/lockf -k /tmp/victory-game.lock \ timeout 150 nice -n 10 tools/macos/run-native.sh --headless --seconds 120 --console series-x \ "<data folder>" ```
AnastasisKon commented 2026-11-29 14:58:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-29T14:58:56Z.


Second measurement on this, and it corrects my first comment: the slow seconds are not the DirectStorage polls, and the GPU is not the bottleneck either.

  • VICTORY_TRACE_COMMITS=1 over one 120 s headless Series X run: 9,080 command buffers, 11.8 s of GPU time in 94.8 s of wall time — the GPU is 12% busy, and 1-16% busy in the exact seconds where fps falls from 30 to 17-20. Per-command-buffer gpu_ms has a median of 0.0 and a single 169 ms outlier.
  • VICTORY_DSTORAGE_LOG=1 in a second run: the read pool peaks at 3.9 of 12 workers with staging_waits=0 and up to 246 MB/s. The title submits in bursts, the pool drains each in milliseconds and then waits. Not our read path.
  • What remains is the title's own x86-64 work under Rosetta, and it cannot be attributed by a CPU profiler: sample reports Code Type: X86-64 (translated) and puts 11,067 of ~12,000 samples at one address in the Rosetta runtime with no symbols — and our own Rust frames are translated the same way, so they do not symbolize either. The host's own counters are the only CPU attribution this port has.

For calibrating what is achievable: the reference Windows host shipped next to this data reports, on an RX 7900 XTX, 30 fps in menus, 13-20 fps in the prologue and 6-10 fps in a street chase. Our port reaches the world load at 15-23 fps on an M3 Pro under Rosetta, so world frame rate here is already at parity with the host people play on, and the lever for more is the arm64 recompilation rather than more Metal or texture-sync work.

Detailed in the pull request.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7257725971 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7257725971). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-29T14:58:56Z. --- Second measurement on this, and it corrects my first comment: **the slow seconds are not the DirectStorage polls, and the GPU is not the bottleneck either.** - `VICTORY_TRACE_COMMITS=1` over one 120 s headless Series X run: 9,080 command buffers, **11.8 s of GPU time in 94.8 s of wall time — the GPU is 12% busy**, and **1-16% busy** in the exact seconds where fps falls from 30 to 17-20. Per-command-buffer `gpu_ms` has a median of 0.0 and a single 169 ms outlier. - `VICTORY_DSTORAGE_LOG=1` in a second run: the read pool peaks at **3.9 of 12 workers** with `staging_waits=0` and up to 246 MB/s. The title submits in bursts, the pool drains each in milliseconds and then waits. Not our read path. - What remains is the title's own x86-64 work under Rosetta, and it cannot be attributed by a CPU profiler: `sample` reports `Code Type: X86-64 (translated)` and puts **11,067 of ~12,000 samples at one address in the Rosetta runtime with no symbols** — and our own Rust frames are translated the same way, so they do not symbolize either. The host's own counters are the only CPU attribution this port has. For calibrating what is achievable: the reference Windows host shipped next to this data reports, on an RX 7900 XTX, 30 fps in menus, **13-20 fps in the prologue and 6-10 fps in a street chase**. Our port reaches the world load at 15-23 fps on an M3 Pro under Rosetta, so world frame rate here is already at parity with the host people play on, and the lever for more is the arm64 recompilation rather than more Metal or texture-sync work. Detailed in the pull request.
a-sheff commented 2026-11-29 15:13:49 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by a-sheff on 2026-11-29T15:13:49Z.


Hello @AnastasisKon, the work from this repo has moved to a private repo. If you'd like to contribute, please join the discord here: https://discord.gg/taabYVrVa and we will get you an invite to the private repo.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7257923141 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/179#issuecomment-7257923141). Originally posted by [a-sheff](https://github.com/a-sheff) on 2026-11-29T15:13:49Z. --- Hello @AnastasisKon, the work from this repo has moved to a private repo. If you'd like to contribute, please join the discord here: https://discord.gg/taabYVrVa and we will get you an invite to the private repo.
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#179
No description provided.