Avoid unnecessary native shader code copies during IR construction #1235

Closed
opened 2026-11-28 16:15:23 +00:00 by github-bot · 1 comment
Owner

@⁠Damokles2 on GitHub · 2026-11-28 16:11 UTC · original

NativeProgram::patched_code() currently clones the complete native shader code buffer even when no export words need to be replaced.

Its production caller, spill::build(), immediately passes the resulting buffer to ir::build(), which only requires a borrowed byte slice.

A small internal borrow-or-own helper can eliminate this unnecessary allocation and payload copy while preserving the existing public owned patched_code() API.

I have prepared and validated a narrow implementation against upstream commit 9ce3cf9.

Validation results:

  • All 1,014 differential cases passed.
  • All focused native and spill tests passed.
  • All 21 unpatched allocation workloads eliminated one allocation and one full payload copy.
  • All 14 patched workloads retained identical allocation and copy counts.
  • Exact code bytes, generated IR, input immutability, and existing error behavior were preserved.
  • No repeatable full-IR performance regression was observed.

The established benefit is reduced allocation and copying, not a demonstrated overall shader compilation or gameplay speedup.

Hosted validation:

Both runs passed compilation and applicable tests, with identical pre-existing Clippy, formatting, and asset-policy failures.

The implementation is ready for submission as a pull request.

AI-assisted with OpenAI Codex.

**@⁠Damokles2** on GitHub · 2026-11-28 16:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1235) `NativeProgram::patched_code()` currently clones the complete native shader code buffer even when no export words need to be replaced. Its production caller, `spill::build()`, immediately passes the resulting buffer to `ir::build()`, which only requires a borrowed byte slice. A small internal borrow-or-own helper can eliminate this unnecessary allocation and payload copy while preserving the existing public owned `patched_code()` API. I have prepared and validated a narrow implementation against upstream commit `9ce3cf9`. Validation results: - All 1,014 differential cases passed. - All focused native and spill tests passed. - All 21 unpatched allocation workloads eliminated one allocation and one full payload copy. - All 14 patched workloads retained identical allocation and copy counts. - Exact code bytes, generated IR, input immutability, and existing error behavior were preserved. - No repeatable full-IR performance regression was observed. The established benefit is reduced allocation and copying, not a demonstrated overall shader compilation or gameplay speedup. Hosted validation: - [[Baseline](https://github.com/Damokles2/VIctory-NVIDIA/actions/runs/46162937313)](https://github.com/Damokles2/VIctory-NVIDIA/actions/runs/46162937313) - [[Candidate](https://github.com/Damokles2/VIctory-NVIDIA/actions/runs/46162937381)](https://github.com/Damokles2/VIctory-NVIDIA/actions/runs/46162937381) Both runs passed compilation and applicable tests, with identical pre-existing Clippy, formatting, and asset-policy failures. The implementation is ready for submission as a pull request. AI-assisted with OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 16:15:23 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 16:11 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-28 16:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1235#issuecomment-7242049201) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
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/trustno1-coder--VIctory-NVIDIA#1235
No description provided.