mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:25:52 +01:00
[PR #2088] vk_pipeline_check: a large module that must wait frees its worker (VK-PIPELINE-CHECK-LARGE-ADMISSION) #2094
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2094
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2088
Author: @c0pperlane
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:vk-pipeline-large-admission📝 Commits (2)
6c6a8cdvk_pipeline_check: a large module that must wait frees its worker (VK-PIPELINE-CHECK-LARGE-ADMISSION)de3ee20Merge remote-tracking branch 'origin/main' into vk-pipeline-large-admission📊 Changes
4 files changed (+230 additions, -7 deletions)
View changed files
📝
docs/pipeline_check.md(+3 -1)📝
runtime/test/large_module_gate.h(+71 -0)📝
runtime/test/large_module_gate_test.cpp(+150 -0)📝
runtime/test/vk_pipeline_check.cpp(+6 -6)📄 Description
Claimed in the coordination issue as: VK-PIPELINE-CHECK-LARGE-ADMISSION (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7171910784)
Depends on: #1890 (conflict only, one line: it edits the line above
std::atomic<size_t> next{0}, done{0};and this dropsnextfrom it; nothing is built on it)What and why
A worker of
vk_pipeline_checktook the next index (next++) and only then waited in the large-module gate. With the memory budget full, spare workers blocked holding large modules while smaller modules behind them sat untaken, so the pool ran below--jobs(finding by akimfomin).LargeModuleQueueinruntime/test/large_module_gate.hnow hands out the indices. A large module the gate can't admit yet is put back and the worker takes the next module. The oldest module put back goes first as soon as the gate admits it, no later large module passes it (so none waits forever), and once every index is out a worker waits for it. Each module is still checked exactly once: every branch before the gate that counts or prints ends incontinuebefore a module can be put back, so a module that comes back only re-reads its size. Nothing is put back while the gate admits each large module as it comes, so with one worker or room under the budget the order is the old one.--large-parallel 1(and the unknown-memory fallback) and--large-module-bytes 0never ask the queue to admit, so they behave as before.--large-parallel N(N ≥ 2, a count without a budget) puts modules back too.LargeModuleGateitself is unchanged. Main moved it toruntime/src/large_module_gate.hin RT-BIG-COMPUTE-BUDGET; its arrival order and demand-before-speculative ordering belong to the read-budget constructor, which only the runtime uses.vk_pipeline_check's fixed-budget gate admits whatever fits, so the order among the modules put back comes from this queue.LargeModuleQueuestays in the forwarding headerruntime/test/large_module_gate.h. It admits withadmits()and a blockingTicketunder its own mutex, which is atomic because every large module ofvk_pipeline_checkenters the gate through the queue. One sentence indocs/pipeline_check.md.Tested
Windows 11 Pro (10.0.26300), MSVC 14.44.35207 (VS 2022 Build Tools), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0. First tested on
db1a22d2, then merged with main at33bd07cf(merge commitde3ee203b2, no rebase). The merge moves the queue's admission onto main's sharedLargeModuleGateand changes nothing else.On the merged tree:
large_module_gate_test big_compile_gate_test vk_pipeline_check pipeline_cache_seed_test, plus thed3d12_big_compute, pipeline-cache and compile tests that includeruntime/src/large_module_gate.h.ctest -R "large_module|pipeline_check|pipeline_summary|big_comp|compile|pipeline_cache": 20/20 passed.python -m unittest discover -s tests -p "test_vk_pipeline_check*.py": 21 OK.git merge-treewith main: clean.The bullets below ran before the merge.
CI-style Windows build (Ninja, RelWithDebInfo,
LEONIDA_D3D12_SHIM_TESTS=ON,LEONIDA_REQUIRE_VULKAN=ON): 985 steps, no errors, no warnings from the changed files.ctest --test-dir runtime/build --output-on-failure --timeout 300 -R "large_module|vk_pipeline_check" --repeat until-fail:3: 3/3 tests, 3 times each, on the rebased branch.New cases in
large_module_gate_test: a waiting large module frees its worker; oldest-first, with no double entry for a module that comes back with its place; unchanged order while the gate admits (one worker,--large-parallel 2with room, counting only); every module once under 8 threads, 300 modules, budget never exceeded. With the queue switched back to claim-then-admit (take()returns the next index,admit()waits on a blocking ticket), the first case fails:line 145: (while_other_in == std::vector<size_t>{1, 2}).A CPU probe compiled from the worker-loop and gate statements of main's and this branch's
vk_pipeline_check.cpp, after the finding's fixture approach: main fails the full-budget case (waits on module 0, the small module never starts) and this branch passes it (1, then 0). The room-in-budget,--large-parallel 2, gate-disabled and exclusive cases give the same order and locks on both.python -I tests/test_vk_pipeline_check_isolate.py: 10 OK.vk_pipeline_checkon 40 synthetic compute modules (20 over--large-module-bytes 2000) with--jobs 4 --large-parallel 2, the default budget,--large-parallel 1,--large-module-bytes 0and--jobs 1: every run 40/40 modules and pipelines ok, large modules counted 20 wherever the gate is on, on both GPUs below.Full
ctest --test-dir runtime/build --output-on-failure --timeout 300(serial), run on the branch's original base9f9a7c5fbefore the rebase: 424 run, 422 passed, 11 skipped for lack of game files or hardware, 2 disabled (no SDL3). The two failures don't involve this change:d3d12_texture_tilesfailed in its native-D3D12 half on the AMD Radeon 610M (got 0x20000cc, expected 0xcc020000, AMD's CopyTiles byte offset, the case #964 covers; main has since changed this test in #1941), andxs_proxy_mockfailed once on its timing-dependent tear check (line 4487) and passed 3/3 reruns on this branch and 3/3 on main's sources. Neither binary changes with this pull request.python -I scripts/check_no_game_data.pyon every changed file: clean.Not built on Linux or macOS here; throughput and peak memory on a real large corpus were not measured (that needs game files).
GPUs tested: NVIDIA GeForce RTX 5080 Laptop GPU (Windows driver 32.0.16.2124) and AMD Radeon 610M (driver 32.0.21030.34003), Windows 11; synthetic modules only. The gate tests themselves are CPU-only.
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.