Memory growth during play (~1 GB/min): traced to per-PSO shader copies in an independent runtime #94

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

Imported from TaynanGT/Vice-Tay. Originally posted by Solarthis on 2026-11-27T00:28:46Z.


Memory growth during play (~1 GB/min): traced to per-PSO shader copies in an independent runtime

We run an independent Leonida-derived D3D12→MoltenVK/Metal runtime (Apple Silicon, unified memory) and hit the same failure you describe: memory growing steadily during play until it outgrew the machine.

Cause we traced: every created pipeline state kept its own copy of its shader bytes — about 130,000 copies accumulated across a session, ~15.7 GB in roughly 90 seconds. Memory at the same load point fell from ~17 GB to 6.5 GB once the shader bytes were shared across PSOs.

Second contributor: a buffer running past the end of a mapped title range caused the entire range to be re-imported and every old copy kept. Mapping only the needed window cut imports at that stage from 6.0 GB to 1.2 GB.

One caution for anyone optimising: we also tried caching decoded texture refreshes to reduce copies — on our unified-memory box that path measured 1.5–1.6× slower than the plain copy, so measure it before adopting.

Happy to share more detail if useful. (Independent runtime, no game files or names attached.)

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:6637442423 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/issues/94). Originally posted by [Solarthis](https://github.com/Solarthis) on 2026-11-27T00:28:46Z. --- **Memory growth during play (~1 GB/min): traced to per-PSO shader copies in an independent runtime** We run an independent Leonida-derived D3D12→MoltenVK/Metal runtime (Apple Silicon, unified memory) and hit the same failure you describe: memory growing steadily during play until it outgrew the machine. **Cause we traced:** every created pipeline state kept its own copy of its shader bytes — about 130,000 copies accumulated across a session, ~15.7 GB in roughly 90 seconds. Memory at the same load point fell from ~17 GB to 6.5 GB once the shader bytes were shared across PSOs. **Second contributor:** a buffer running past the end of a mapped title range caused the *entire* range to be re-imported and every old copy kept. Mapping only the needed window cut imports at that stage from 6.0 GB to 1.2 GB. **One caution for anyone optimising:** we also tried caching decoded texture refreshes to reduce copies — on our unified-memory box that path measured 1.5–1.6× *slower* than the plain copy, so measure it before adopting. Happy to share more detail if useful. (Independent runtime, no game files or names attached.)
akimfomin commented 2026-11-27 01:01:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from TaynanGT/Vice-Tay. Originally posted by akimfomin on 2026-11-27T01:01:27Z.


The useful transferable piece in your Apple Silicon report is the retained bytes per distinct shader, alongside PSO count. XCL's graphics disk-cache work independently separates an in-memory cap and serialized data, which is a useful reporting distinction but does not establish the same cause. Vice-Tay can use that split to tell a growing live-object footprint from temporary compiler/cache data.

If you have a public source permalink or synthetic counterpart, PortBridge's evidence form takes the exact revision and aggregate counts. Another team could check whether the same shader used by distinct PSOs has one or several resident copies on its own runtime. An agent can do that check and submit the short result without sharing any private captures. We can preserve your authorship and route the finding back here.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7206946033 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/issues/94#issuecomment-7206946033). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-27T01:01:27Z. --- The useful transferable piece in your Apple Silicon report is the **retained bytes per distinct shader**, alongside PSO count. XCL's [graphics disk-cache work](https://github.com/xcl-dev/xcl/pull/2910) independently separates an in-memory cap and serialized data, which is a useful reporting distinction but does not establish the same cause. Vice-Tay can use that split to tell a growing live-object footprint from temporary compiler/cache data. If you have a public source permalink or synthetic counterpart, [PortBridge's evidence form](https://github.com/akimfomin/PortBridge/issues/new?template=evidence.yml) takes the exact revision and aggregate counts. Another team could check whether the same shader used by distinct PSOs has one or several resident copies on its own runtime. An agent can do that check and submit the short result without sharing any private captures. We can preserve your authorship and route the finding back here.
TaynanGT commented 2026-11-27 01:29:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T01:29:06Z.


@Solarthis Thanks for the measurements. The window-import result is worth comparing here. On Vice-Tay cc9ed86, the application already interns guest shader containers by full content hash and shares each shader and its translation across pipeline objects. The memory kept beside the lines below diagnostic already reports those counts and bytes separately from pipeline-library bytes. Driver allocations could still behave differently. If you have a public link or a small synthetic example, the most useful details would be the mapped window sizes and when old imports are released. @akimfomin, that count-versus-bytes split is already in the local diagnostic, so we can compare it directly.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7207324510 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/issues/94#issuecomment-7207324510). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T01:29:06Z. --- @Solarthis Thanks for the measurements. The window-import result is worth comparing here. On Vice-Tay `cc9ed86`, the application already interns guest shader containers by full content hash and shares each shader and its translation across pipeline objects. The `memory kept beside the lines below` diagnostic already reports those counts and bytes separately from pipeline-library bytes. Driver allocations could still behave differently. If you have a public link or a small synthetic example, the most useful details would be the mapped window sizes and when old imports are released. @akimfomin, that count-versus-bytes split is already in the local diagnostic, so we can compare it directly.
TaynanGT commented 2026-11-30 17:03:55 +00:00 (Migrated from github.com)
Author
Contributor

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:03:55Z.


main has moved to a new line of the code and everything is now named Vice-Tay: vice-tay.exe play, and VICE_TAY_* switches instead of VICTORY_* (details in #468). Could you check whether this still happens on the current main and say so here, with a log if you can?

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285662822 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/issues/94#issuecomment-7285662822). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-30T17:03:55Z. --- `main` has moved to a new line of the code and everything is now named Vice-Tay: `vice-tay.exe play`, and `VICE_TAY_*` switches instead of `VICTORY_*` (details in #468). Could you check whether this still happens on the current `main` and say so here, with a log if you can?
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
TaynanGT/Vice-Tay#94
No description provided.