Repository navigation
vk_pipeline_check: a large module that must wait frees its worker (VK-PIPELINE-CHECK-LARGE-ADMISSION) - #2088
Open
c0pperlane wants to merge 2 commits into
Open
c0pperlane wants to merge 2 commits into
c0pperlane wants to merge 2 commits into
Conversation
…-PIPELINE-CHECK-LARGE-ADMISSION) A worker took the next index and only then waited in the large-module gate, so with the memory budget full the modules behind a large one sat untaken while spare workers blocked, and the pool ran below --jobs. LargeModuleQueue (large_module_gate.h) now hands out the indices. A large module the gate can't admit yet is put back and the worker takes the next one. The oldest module put back goes first as soon as the gate admits it and no later large module passes it; once every index is out, a worker waits for it. 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 unchanged, and --large-parallel 1 and --large-module-bytes 0 never ask the queue to admit. large_module_gate_test: the waiting module frees its worker (fails with the old claim-then-admit order), oldest-first and no double entry, the unchanged order, and every module once under 8 threads. AI-assisted (Claude Code).
3 of 4 tasks
Contributor
|
Integration finding: #2088 needs rebasing because |
…ission Conflict in runtime/test/large_module_gate.h: kept main's forwarding header to runtime/src/large_module_gate.h (unchanged) and put LargeModuleQueue after the include; it admits with the gate's admits() and a blocking Ticket under its own mutex, so try_enter and the try_to_lock Ticket are no longer needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: VK-PIPELINE-CHECK-LARGE-ADMISSION (#1608 (comment))
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 db1a22d, then merged with main at 33bd07c (merge commit de3ee20, no rebase). The merge moves the queue's admission onto main's shared
LargeModuleGateand 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 base 9f9a7c5 before 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 test: texture tiles NOTE only for the measured CopyTiles offset rounding on AMD and Intel (D3D-TILES-AMD-BYTE-OFFSET) #964 covers; main has since changed this test in test: respect LEONIDA_HOST_ADAPTER and layer LUID in d3d12_texture_tiles (RT-TEXTURE-TILES-HOST-ADAPTER) #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)