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

Open
opened 2026-11-27 00:42:06 +00:00 by github-bot · 2 comments
Owner

@⁠Solarthis on GitHub · 2026-11-27 00:28 UTC · original

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.)

**@⁠Solarthis** on GitHub · 2026-11-27 00:28 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/94) **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.)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:42:06 +00:00
Author
Owner

@⁠akimfomin on GitHub · 2026-11-27 01:01 UTC · original

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.

**@⁠akimfomin** on GitHub · 2026-11-27 01:01 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/94#issuecomment-7206946033) 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.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 01:29 UTC · original

@⁠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** on GitHub · 2026-11-27 01:29 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/94#issuecomment-7207324510) @⁠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.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/TaynanGT--Vice-Tay#94
No description provided.