One host texture per range: share identical copies, give up placed copies another placement overlaps #356

Closed
opened 2026-11-27 13:50:22 +00:00 by m0rff · 6 comments
m0rff commented 2026-11-27 13:50:22 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by m0rff on 2026-11-27T13:50:22Z.


On a 24 GB M4 Pro (Series S, budget off), host texture copies reached 8.5 GB over 1.7 GB of distinct title memory during the world load and stopped it (#301, alicans' third run). Each title key (an object, or a placed address with its description) gets its own copy, even when other keys cover the same memory.

Two changes, stacked on #301:

  1. One texture for identical copies. A title texture laid out exactly as a live copy over the same memory (same start, size, layout, dimensions, host format, no format conversion, not a render target or depth) uses that copy's texture instead of making its own, as the R9G9B9E5-over-R32_UINT case already does. Draws sample the same bytes either way.
  2. A placed copy goes when another is placed over its memory at another start. Today it goes only when another description is placed at exactly its address, or with its pool. It is given up the way the budget gives copies up, so an entry or a submission's tables that still name it get it made again (one late upload, not black). Copies that hold what title memory does not (render targets, depth, GPU-written, viewed for unordered access) are kept. This is a guess that the title is done with a placed view once it places another over the memory, and it will be marked as one.

Proven with unit tests. Needs world runs before it can be judged.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6647746590 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/356). Originally posted by [m0rff](https://github.com/m0rff) on 2026-11-27T13:50:22Z. --- On a 24 GB M4 Pro (Series S, budget off), host texture copies reached 8.5 GB over 1.7 GB of distinct title memory during the world load and stopped it (#301, alicans' third run). Each title key (an object, or a placed address with its description) gets its own copy, even when other keys cover the same memory. Two changes, stacked on #301: 1. **One texture for identical copies.** A title texture laid out exactly as a live copy over the same memory (same start, size, layout, dimensions, host format, no format conversion, not a render target or depth) uses that copy's texture instead of making its own, as the R9G9B9E5-over-R32_UINT case already does. Draws sample the same bytes either way. 2. **A placed copy goes when another is placed over its memory at another start.** Today it goes only when another description is placed at exactly its address, or with its pool. It is given up the way the budget gives copies up, so an entry or a submission's tables that still name it get it made again (one late upload, not black). Copies that hold what title memory does not (render targets, depth, GPU-written, viewed for unordered access) are kept. This is a guess that the title is done with a placed view once it places another over the memory, and it will be marked as one. Proven with unit tests. Needs world runs before it can be judged.
m0rff commented 2026-11-27 13:50:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by m0rff on 2026-11-27T13:50:29Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7220009930 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/356#issuecomment-7220009930). Originally posted by [m0rff](https://github.com/m0rff) on 2026-11-27T13:50:29Z. --- /claim
github-actions[bot] commented 2026-11-27 13:50:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T13:50:41Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7220013897 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/356#issuecomment-7220013897). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T13:50:41Z. --- Claimed by @m0rff. Open a draft pull request with `Refs #356` in its description within 24 hours, or the claim expires.
alicans commented 2026-11-27 16:27:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alicans on 2026-11-27T16:27:57Z.


The world-load run m0rff asked for on #359, on 24 GB (M4 Pro), Series S, budget off, VICTORY_TRACE_TEXTURE_SYNC=1. The code was main 4cf84c83 merged with #359 at 69d0038a, so the same as main 1ba9f696 apart from docs context; it does not have 582670f1. My script stopped it at 81 s when free memory fell to 9 %, like the third run on #301 (that one at 127 s).

The last trace line before the stop, with the third run in brackets:

  • copies: 7507 MiB over 1566 MiB of distinct title memory (8544 over 1670)
  • textures sharing an identical copy: 0 on every line of the run
  • covered placed copies given up: 4451 in all, 236 MiB; covered still in use: 5750 on the last line
  • made again: 349 in all; 153 MiB of copies outside the title's pools

Most of the growth came at the end: over the last 8 lines (about one a second) the copies went from 3128 to 7507 MiB while distinct memory went from 1186 to 1566 MiB. No GPU errors; it was still at about 26 fps when stopped.

Is there a trace you'd like on for the next run, for example one that names the formats or views of the new copies?

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7223292595 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/356#issuecomment-7223292595). Originally posted by [alicans](https://github.com/alicans) on 2026-11-27T16:27:57Z. --- The world-load run m0rff asked for on #359, on 24 GB (M4 Pro), Series S, budget off, `VICTORY_TRACE_TEXTURE_SYNC=1`. The code was main `4cf84c83` merged with #359 at `69d0038a`, so the same as main `1ba9f696` apart from docs context; it does not have `582670f1`. My script stopped it at 81 s when free memory fell to 9 %, like the third run on #301 (that one at 127 s). The last trace line before the stop, with the third run in brackets: - copies: 7507 MiB over 1566 MiB of distinct title memory (8544 over 1670) - textures sharing an identical copy: 0 on every line of the run - covered placed copies given up: 4451 in all, 236 MiB; covered still in use: 5750 on the last line - made again: 349 in all; 153 MiB of copies outside the title's pools Most of the growth came at the end: over the last 8 lines (about one a second) the copies went from 3128 to 7507 MiB while distinct memory went from 1186 to 1566 MiB. No GPU errors; it was still at about 26 fps when stopped. Is there a trace you'd like on for the next run, for example one that names the formats or views of the new copies?
m0rff commented 2026-11-27 22:51:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by m0rff on 2026-11-27T22:51:43Z.


@alicans thank you for the run.

Your run shows that #359's sharing did not reduce the growth. No texture shared an identical copy on any line, so none of the 7507 MiB came from copies that sharing would have removed. The covered give-up freed 236 MiB, while 5750 covered copies were still in use at the end.

Here is what the code says about why sharing found nothing. It applies only when two copies are alive at the same title address with the same description: two resource objects over one address, or a placed view over an object's memory. Two placed copies at one address can never share. texture_placed releases the copy of another description at that address before the new one is made, and the same description at the same address is already the same key. Your trace does not split placed copies from objects, so I can't tell from it whether that is what your copies were.

For the next run, could you do a world load of the #355 head (10892d1b, on main b998bb65) with both of these on, set up as before (Series S, budget off, the same stop script):

VICTORY_TRACE_TEXTURE_OVERLAP=1 VICTORY_TRACE_TEXTURE_SYNC=1
  • VICTORY_TRACE_TEXTURE_SYNC=1 gives the same host texture copies: .. line as your run (copies, distinct memory, sharing, covered given up and still in use, made again), so the two runs can be compared line by line.
  • VICTORY_TRACE_TEXTURE_OVERLAP=1 adds host texture copies overlap: .. once a second. It answers two things:
    • Which kind of overlap the extra memory is (about 5.9 GB in your run). Identical layouts at one start means the same pool offset and layout in another host format, or the same pages reached through two title addresses. Sharing goes by title address and the same format, so it misses both, but one texture with views could serve them. Different layouts means another start or layout over the same bytes, which no sharing of one texture can serve.
    • Whether copies over one range take it from each other. Each upload into another copy's range is counted by what that copy was: a live identical layout, a live different one (where one texture per range would cost an upload each time, or black), or a copy that is gone (memory being reused).

I'm leaving a trace that names formats and views for later. This one says first which kind of copy the memory goes to. I'm keeping this issue open.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229677569 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/356#issuecomment-7229677569). Originally posted by [m0rff](https://github.com/m0rff) on 2026-11-27T22:51:43Z. --- @alicans thank you for the run. Your run shows that #359's sharing did not reduce the growth. No texture shared an identical copy on any line, so none of the 7507 MiB came from copies that sharing would have removed. The covered give-up freed 236 MiB, while 5750 covered copies were still in use at the end. Here is what the code says about why sharing found nothing. It applies only when two copies are alive at the same title address with the same description: two resource objects over one address, or a placed view over an object's memory. Two placed copies at one address can never share. `texture_placed` releases the copy of another description at that address before the new one is made, and the same description at the same address is already the same key. Your trace does not split placed copies from objects, so I can't tell from it whether that is what your copies were. For the next run, could you do a world load of the #355 head (`10892d1b`, on main `b998bb65`) with both of these on, set up as before (Series S, budget off, the same stop script): ``` VICTORY_TRACE_TEXTURE_OVERLAP=1 VICTORY_TRACE_TEXTURE_SYNC=1 ``` - **`VICTORY_TRACE_TEXTURE_SYNC=1`** gives the same `host texture copies: ..` line as your run (copies, distinct memory, sharing, covered given up and still in use, made again), so the two runs can be compared line by line. - **`VICTORY_TRACE_TEXTURE_OVERLAP=1`** adds `host texture copies overlap: ..` once a second. It answers two things: - **Which kind of overlap the extra memory is** (about 5.9 GB in your run). *Identical layouts at one start* means the same pool offset and layout in another host format, or the same pages reached through two title addresses. Sharing goes by title address and the same format, so it misses both, but one texture with views could serve them. *Different layouts* means another start or layout over the same bytes, which no sharing of one texture can serve. - **Whether copies over one range take it from each other.** Each upload into another copy's range is counted by what that copy was: a live identical layout, a live different one (where one texture per range would cost an upload each time, or black), or a copy that is gone (memory being reused). I'm leaving a trace that names formats and views for later. This one says first which kind of copy the memory goes to. I'm keeping this issue open.
LakshanSivakumar commented 2026-11-28 00:36:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-28T00:36:23Z.


Thank you for this. It is fixed on main by 55219dfa. I have not checked every case from this report in the game myself, so please retest on main a6a58361 and reopen this if you still see it. Closing as fixed.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231045753 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/356#issuecomment-7231045753). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-28T00:36:23Z. --- Thank you for this. It is fixed on main by 55219dfa. I have not checked every case from this report in the game myself, so please retest on main a6a58361 and reopen this if you still see it. Closing as fixed.
m0rff commented 2026-11-28 10:06:53 +00:00 (Migrated from github.com)
Author
Contributor

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


A note in case it was missed: #359 (55219dfa) did not fix the growth in alicans' 24 GB run. No texture shared an identical copy, and copies still reached 7507 MiB over 1566 MiB of distinct title memory before the run was stopped on free memory. I have no newer run, so main may behave differently now. The overlap trace in #355 is meant to show where the copies come from. Reopen or leave closed as you prefer.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7237680097 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/356#issuecomment-7237680097). Originally posted by [m0rff](https://github.com/m0rff) on 2026-11-28T10:06:53Z. --- A note in case it was missed: #359 (55219dfa) did not fix the growth in alicans' 24 GB run. No texture shared an identical copy, and copies still reached 7507 MiB over 1566 MiB of distinct title memory before the run was stopped on free memory. I have no newer run, so main may behave differently now. The overlap trace in #355 is meant to show where the copies come from. Reopen or leave closed as you prefer.
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#356
No description provided.