WIP: perf(vk): reuse matching live shader stages on first use #1596
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1596
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:perf/reuse-live-shader-stages"
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?
Type: perf · Risk: medium · Tested on: CachyOS Linux, Ryzen 9 7900X, 32 GiB, GeForce RTX 3090, NVIDIA 620.70.06
TL;DR
Share identical live shader stages between programs. Across 271 matched first uses at the Field entrance, total first-use time changed from 27.36 to 26.48 ms. This is one instrumented comparison.
Why and what changed
Recent stages occupy 32 bounded lookup slots. Reuse requires identical control and code bytes plus matching native MMA mode. A weak reference permits eviction while queued compilation work retains its own input. Previously each program lowered its stage independently.
Measurements
Both runs used a cache prepared by their own translator. Of the first uses inside the Field loading bracket, 271 matched by shader program, draw/dispatch, cache outcome and occurrence count. Those uses had median times of 0.030 ms on stock and 0.020 ms with reuse. Startup and route history differed. Overall FPS and stutter gains remain unproven.
Testing
The game completed the headless Market-to-Field route. A synthetic delayed-job regression covers releasing the source serial and displacing the lookup slot before running queued compilation. The full suite reported 721 passed, 41 failed and 19 skipped. All 41 failures reproduced on the control.
Risks and remaining work
The source change invalidates the translator stamp on first launch and can require substantial recompilation. Payloads up to 64 KiB are eligible per entry. Fresh preparations on both translators produced 47,867 common program keys. Every translated stage fingerprint matched. Four additional fixed-marker headless runs exercised independently prepared, stage-verified caches. The application pipeline cache was disabled and the NVIDIA driver cache was warm. Each run indexed 32,390 notes for 20,411 programs.
The GPU and route matched across arms. The first stock run coincided with an outside build detected by the local queue. The final stock run was faster in Field than either candidate run. Market p99 increased in both pairs and the Market FPS deltas changed sign. These runs leave an overall gameplay gain unproven.
Checklist
876dc360. Measurements were taken before the cold-install packaging change on that revision.Checks also failing on the control
tests/test_bug_report_defaults.py,tests/test_capture_readback_visibility.py,tests/test_cpu_report.py,tests/test_crt_options.py,tests/test_damage_debug_menu.py,tests/test_dev_packs.py,tests/test_display_startup_failure.py,tests/test_dlss_feature_size.py,tests/test_draw_stream_visibility.py,tests/test_failed_compile_keeps_objects.py,tests/test_fsr_image_retirement.py,tests/test_fsr_uniform_ownership.py,tests/test_guest_imported.py,tests/test_hud_layout_row.py,tests/test_invalidate_quick.py,tests/test_invalidate_vcore.py,tests/test_libc_hooks.py,tests/test_linux_preflight.py,tests/test_linux_pressure.py,tests/test_linux_update.py,tests/test_log_open_failure.py,tests/test_mirror_budget.py,tests/test_missing_nup.py,tests/test_mods_size_table.py,tests/test_nonuniform_image_arrays.py,tests/test_parallel_init_order.py,tests/test_pending_guest_import.py,tests/test_pipeline_play_cache.py,tests/test_present_source_crop.py,tests/test_present_thread.py,tests/test_profiling_mode.py,tests/test_psychov35_fsr3_fg.py,tests/test_readback_timeout_source.py,tests/test_replay_write_order.py,tests/test_run_all_changed.py,tests/test_slow_frames.py,tests/test_staging_burst.py,tests/test_switch_table.py,tests/test_upscaler_rows.py,tests/test_vk_occlusion_queries.py,tests/test_walk_key.pyTested in game: Linux, Ryzen 9 7900X, RTX 3090, NVIDIA 620.70.06. Completed the headless route from Market into Field. Compared 271 matched first shader uses at Field entry with matching keys and outcomes.
Possibly related, for context:
0a1c900364ae5ff24ac1Corrected author and committer attribution to HumanBean. Verified identical file contents before and after the metadata change. Fresh preparations had identical stage fingerprints for all 47,867 indexed program keys. The GCC and Clang delayed-job checks also passed.
Finished both headless timing orders with matching prepared stage fingerprints. Market FPS changed sign between pairs. Field 78.55 and 77.72 FPS with reuse overlaps the controls at 64.88 and 79.23 FPS. The queue detected an outside build in the first control. Full timings and p99 are now in the description.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.