perf(vk): combine contiguous sparse buffer mappings #1624

Merged
HumanBean merged 3 commits from HumanBean/Longshot:perf/sparse-buffer-bind-ranges into main 2026-11-18 17:21:25 +00:00
Owner

Type perf · Risk medium · Tested on Linux, RTX 3090 · Needs Windows and other sparse-capable drivers

TL;DR

When streaming into an area, the renderer can submit thousands of separate Vulkan memory mappings. Adjacent mappings that refer to consecutive bytes of the same allocation now use one range. A diagnostic Field crossing measured 10–15 ms waiting for unfinished sparse mappings, down from 230–240 ms. Complete crossing frames varied substantially over the repeats.

What changed

The renderer groups only adjacent records within one buffer, with equal flags, matching backing memory and contiguous memory offsets, or adjacent unbinds. The caller keeps ownership of the original per-block data used for rollback and future releases. The Vulkan queue submission and timeline signal are unchanged.

Measurements

All four runs used the same host binary and warmed cache seed on Ryzen 9 7900X, 32 GiB RAM, RTX 3090 with NVIDIA 620.70.06, CachyOS Linux. Each run followed the same Market and Field route at 2560×1440 with real-time simulation and frame generation off. The four runs below used the 430eef4f renderer baseline, physical device budget and the order shown. P99 and crossing times are milliseconds.

Run Market FPS Market p99 Field FPS Field p99 Worst crossing frame
ranges-stock-a 63.71 29.83 68.14 22.06 346.71
ranges-merged-a 65.52 24.99 73.02 18.84 174.94
ranges-merged-b 63.18 30.37 73.35 17.79 1045.24
ranges-stock-b 55.22 35.67 64.19 22.45 352.55

The third run recorded two outside builds and a 1,045 ms crossing frame. All four completed the route. This series supports fewer submitted ranges and a promising Field throughput result. End-to-end stutter remains mixed.

In one separately instrumented crossing per renderer the longest wait saw 12,073 original records at baseline. The candidate combined 11,484 records into 464 while mapping 717.8 MiB. Its longest guest fence dropped from 390.65 to 154.81 ms. The complete worst frame went from 399.98 to 489.00 ms, with 315 ms of scheduled main-game-thread CPU after the fence on the candidate.

A second instrumented run with the candidate combined 12,165 entries into 480 and measured 3.32–10.29 ms waiting on incomplete sparse signals. Its worst complete crossing frame took 173.43 ms.

Testing

The game-free fixture compiles the production queue path and checks mapping boundaries, different allocations and flags, unbinds, rejection and retry. The two candidate runs above exercised the production fix on the physical GPU budget. The submission rebases the fix onto ffec0cec. The bind function, its four updated call sites and the three affected test files match the measured implementation. The rebased head’s simulated 6 GiB smoke is pending. The full suite recorded 722 passes, 19 skips and 41 failures. Relative to its tested main baseline there were 0 additional failures.

Risks and remaining coverage

Each submission can temporarily allocate a vector sized to the inputs needing inspection. Errors retain the original bookkeeping. Other drivers and physically low-memory GPUs still need testing. Keep WIP while the end-to-end crossing result is being repeated.

**Type** perf · **Risk** medium · **Tested on** Linux, RTX 3090 · **Needs** Windows and other sparse-capable drivers ## TL;DR When streaming into an area, the renderer can submit thousands of separate Vulkan memory mappings. Adjacent mappings that refer to consecutive bytes of the same allocation now use one range. A diagnostic Field crossing measured 10–15 ms waiting for unfinished sparse mappings, down from 230–240 ms. Complete crossing frames varied substantially over the repeats. ## What changed The renderer groups only adjacent records within one buffer, with equal flags, matching backing memory and contiguous memory offsets, or adjacent unbinds. The caller keeps ownership of the original per-block data used for rollback and future releases. The Vulkan queue submission and timeline signal are unchanged. ## Measurements All four runs used the same host binary and warmed cache seed on Ryzen 9 7900X, 32 GiB RAM, RTX 3090 with NVIDIA 620.70.06, CachyOS Linux. Each run followed the same Market and Field route at 2560×1440 with real-time simulation and frame generation off. The four runs below used the 430eef4f renderer baseline, physical device budget and the order shown. P99 and crossing times are milliseconds. | Run | Market FPS | Market p99 | Field FPS | Field p99 | Worst crossing frame | |---|---:|---:|---:|---:|---:| | ranges-stock-a | 63.71 | 29.83 | 68.14 | 22.06 | 346.71 | | ranges-merged-a | 65.52 | 24.99 | 73.02 | 18.84 | 174.94 | | ranges-merged-b | 63.18 | 30.37 | 73.35 | 17.79 | 1045.24 | | ranges-stock-b | 55.22 | 35.67 | 64.19 | 22.45 | 352.55 | The third run recorded two outside builds and a 1,045 ms crossing frame. All four completed the route. This series supports fewer submitted ranges and a promising Field throughput result. End-to-end stutter remains mixed. In one separately instrumented crossing per renderer the longest wait saw 12,073 original records at baseline. The candidate combined 11,484 records into 464 while mapping 717.8 MiB. Its longest guest fence dropped from 390.65 to 154.81 ms. The complete worst frame went from 399.98 to 489.00 ms, with 315 ms of scheduled main-game-thread CPU after the fence on the candidate. A second instrumented run with the candidate combined 12,165 entries into 480 and measured 3.32–10.29 ms waiting on incomplete sparse signals. Its worst complete crossing frame took 173.43 ms. ## Testing The game-free fixture compiles the production queue path and checks mapping boundaries, different allocations and flags, unbinds, rejection and retry. The two candidate runs above exercised the production fix on the physical GPU budget. The submission rebases the fix onto ffec0cec. The bind function, its four updated call sites and the three affected test files match the measured implementation. The rebased head’s simulated 6 GiB smoke is pending. The full suite recorded 722 passes, 19 skips and 41 failures. Relative to its tested main baseline there were 0 additional failures. ## Risks and remaining coverage Each submission can temporarily allocate a vector sized to the inputs needing inspection. Errors retain the original bookkeeping. Other drivers and physically low-memory GPUs still need testing. Keep WIP while the end-to-end crossing result is being repeated.
Assisted-by: OpenAI Codex
Assisted-by: OpenAI Codex
docs(tested): record Market and Field sparse-mapping comparisons
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 18s
CI / Workflow lint (actionlint) (pull_request) Successful in 19s
Third-party parts / As their notes say (pull_request) Successful in 24s
PR description / Description follows the template (pull_request_target) Failing after 7s
8877cde0df
Assisted-by: OpenAI Codex
Author
Owner

Tested in game: Ryzen 9 7900X, 32 GiB RAM, RTX 3090 with NVIDIA 620.70.06, CachyOS Linux. Ran the production range combining change twice on the 2560×1440 headless, real-time simulation, frame generation off, fixed-marker Market walk and turn, physical crossing and Field walk and turn with physical VRAM policy. The benchmark commit was e07e6a7b. The rebased PR has the same bind function and changed calls. Worst crossing frames with the change were 174.94 and 1045.24 ms, versus 346.71 and 352.55 ms on control. Two outside builds were detected in the second candidate run.

Tested in game: Ryzen 9 7900X, 32 GiB RAM, RTX 3090 with NVIDIA 620.70.06, CachyOS Linux. Ran the production range combining change twice on the 2560×1440 headless, real-time simulation, frame generation off, fixed-marker Market walk and turn, physical crossing and Field walk and turn with physical VRAM policy. The benchmark commit was e07e6a7b. The rebased PR has the same bind function and changed calls. Worst crossing frames with the change were 174.94 and 1045.24 ms, versus 346.71 and 352.55 ms on control. Two outside builds were detected in the second candidate run.
Member

Possibly related, for context:

  • PR #1594 perf(vk): stream guest page-table ranges into bounded transfers — recent Vulkan performance work in the same renderer, but separate page-table transfer path
  • PR #1250 fix(vk): a sparse upload that runs out of staging binds what it queued — merged sparse-bind failure bookkeeping in neighboring Vulkan code
Possibly related, for context: - PR #1594 perf(vk): stream guest page-table ranges into bounded transfers — recent Vulkan performance work in the same renderer, but separate page-table transfer path - PR #1250 fix(vk): a sparse upload that runs out of staging binds what it queued — merged sparse-bind failure bookkeeping in neighboring Vulkan code
Author
Owner

The full rebased suite finished. The new sparse-binding regression passed. The candidate recorded 722 passes, 19 skips and 41 failures. All 41 also failed on the matched main baseline.

The full rebased suite finished. The new sparse-binding regression passed. The candidate recorded 722 passes, 19 skips and 41 failures. All 41 also failed on the matched main baseline.
HumanBean changed title from WIP: perf(vk): combine contiguous sparse buffer mappings to perf(vk): combine contiguous sparse buffer mappings 2026-11-18 17:21:14 +00:00
HumanBean deleted branch perf/sparse-buffer-bind-ranges 2026-11-18 17:21:25 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
MagicBeanDev/Longshot!1624
No description provided.