perf(shader): borrow unpatched native code during IR construction #1240
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!1240
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1240"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Damokles2 on GitHub · 2026-11-28 16:14 UTC · original
Damokles2:perf-shader-borrow-unpatched-code→main· +53 −9 · 2 files · 1 commits · merged 2026-11-29 08:16 UTCSummary
NativeProgram::patched_code()eagerly clones the entire native shader byte buffer, even when there are no export words to replace. Its caller,spill::build(), passes the bytes directly toir::build(), which accepts a borrowed&[u8].The internal
code_for_ir()helper returns aCow<'_, [u8]>. It borrows the original code when there are no export words to replace and clones once when patching is required. The publicpatched_code() -> Vec<u8>API still returns owned bytes. The helper preserves export patch order and bounds checks, including the existing offset arithmetic for empty patches, and leaves the input program unchanged.Validation
Representative unpatched compute code-preparation medians from the synthetic benchmark:
Some small patched workloads showed roughly 3–11 ns of helper-only overhead. No repeatable full-IR slowdown was observed. The timings above cover code preparation only.
Hosted Windows checks
9ce3cf9e340adb1cc8de3a681e0f1b8016d46b3e. Baseline run0f5793399dfbe5ff87d1afce7351451c36881f19. Candidate runBoth jobs finished with identical pre-existing failures in strict default and all-features Clippy, the same 3,793 formatting diff hunks, and asset-policy rejection of the upstream
bindings.inifile type.Closes #1235.
AI-assisted with OpenAI Codex.
@Damokles2 on GitHub · 2026-11-28 16:23 UTC · original
The official CI failure matches the pre-existing Clippy diagnostics identified during baseline validation:
clippy::let_and_returninvictory-shader/src/emit/mod.rs:2768:9clippy::manual_is_multiple_ofinvictory-gpu/src/shadow.rs:1708:32Neither file is modified by this PR.
Both hosted validation runs reproduced these exact diagnostics:
Both hosted runs passed locked workspace compilation and all applicable CPU, native shader, and spill tests. The candidate additionally passed all 1,014 differential cases and all 35 allocation-comparison workloads.
No candidate-specific failures were observed.
The production patch remains unchanged to keep the contribution focused.