queue_families: select earliest slot in pick_queue_slot when all slots are UINT32_MAX #2310

Merged
leonida/mandy
narekshaghoyandev merged 1 commit from ubiq-queue-families-slot-max into main 2026-11-29 14:26:21 +00:00

Pull request successfully merged and closed

narekshaghoyandev commented 2026-11-26 13:42:20 +00:00

Fixes an edge case in leonida::pick_queue_slot() (runtime/src/queue_families.h):

  • Previously, fewest was initialized to UINT32_MAX and updated only when users[i] < fewest. If every slot in non-empty pools had UINT32_MAX users, pick_queue_slot() returned {SIZE_MAX, 0} (the sentinel meaning every pool is empty).
  • Check chosen.pool == SIZE_MAX || users[i] < fewest so the earliest available slot is always selected when at least one pool is non-empty.
  • Added standalone unit test runtime/test/queue_families_test.cpp.

Verification

  • g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/queue_families_test.cpp passed
  • g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/queue_families_test.cpp passed
  • Negative control: new test failed on line 28 (sat.pool == 1 && sat.index == 0, exit 1) against unmodified ubiq/main
  • python3 -I scripts/check_no_game_data.py runtime/src/queue_families.h runtime/test/queue_families_test.cpp clean

Claimed in the coordination issue as: RT-QUEUE-FAMILIES-SLOT-MAX (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193699762)
AI-assisted: yes (Gemini)

Fixes an edge case in `leonida::pick_queue_slot()` (`runtime/src/queue_families.h`): - Previously, `fewest` was initialized to `UINT32_MAX` and updated only when `users[i] < fewest`. If every slot in non-empty pools had `UINT32_MAX` users, `pick_queue_slot()` returned `{SIZE_MAX, 0}` (the sentinel meaning every pool is empty). - Check `chosen.pool == SIZE_MAX || users[i] < fewest` so the earliest available slot is always selected when at least one pool is non-empty. - Added standalone unit test `runtime/test/queue_families_test.cpp`. ### Verification - `g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/queue_families_test.cpp` passed - `g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/queue_families_test.cpp` passed - Negative control: new test failed on line 28 (`sat.pool == 1 && sat.index == 0`, exit 1) against unmodified `ubiq/main` - `python3 -I scripts/check_no_game_data.py runtime/src/queue_families.h runtime/test/queue_families_test.cpp` clean Claimed in the coordination issue as: RT-QUEUE-FAMILIES-SLOT-MAX (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193699762) AI-assisted: yes (Gemini)
lixonik reviewed 2026-11-26 20:50:23 +00:00
lixonik left a comment
No description provided.
Compared the new standalone test with GCC on Ubuntu against `main` at `fac8b4bb9` and the PR merged onto that revision. Only the baseline failed the saturated-slot assertion at line 28. The existing `vk_queue` CTest also passed on Windows 11 with MSVC and an RTX 5070. The standalone regression needs to be included in the normal test run. AI-assisted.
zmasi commented 2026-11-28 12:16:03 +00:00

VERIFY-2310 — verified head bddeb09264 merged cleanly with main d48a957bb on Windows 11 Pro (build 26200), MSVC 19.44 (x64, /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc), synthetic queue-family slot arrays only.

Red (main d48a957bb) -> Green (d48a957bb + bddeb09264)

  • Red on main:
    • Compiling and running runtime/test/queue_families_test.cpp against main's runtime/src/queue_families.h -> FAILED (exit 1 at line 28: sat.pool == 1 && sat.index == 0, because users[i] < fewest never matched when fewest started at UINT32_MAX and every non-empty pool slot had UINT32_MAX users).
  • Green on merged PR:
    • cl.exe /nologo /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc /I"runtime/src" runtime/test/queue_families_test.cpp (with Vulkan headers) -> 0 warnings, exit 0 (queue_families_test: ok).

AI-assisted.

`VERIFY-2310` — verified head `bddeb09264` merged cleanly with `main` `d48a957bb` on Windows 11 Pro (build 26200), MSVC `19.44` (`x64`, `/std:c++20 /W4 /WX /permissive- /utf-8 /EHsc`), synthetic queue-family slot arrays only. ### Red (`main` `d48a957bb`) -> Green (`d48a957bb` + `bddeb09264`) - **Red on `main`**: - Compiling and running `runtime/test/queue_families_test.cpp` against `main`'s `runtime/src/queue_families.h` -> **FAILED** (`exit 1` at `line 28: sat.pool == 1 && sat.index == 0`, because `users[i] < fewest` never matched when `fewest` started at `UINT32_MAX` and every non-empty pool slot had `UINT32_MAX` users). - **Green on merged PR**: - `cl.exe /nologo /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc /I"runtime/src" runtime/test/queue_families_test.cpp` (with Vulkan headers) -> **0 warnings**, exit **`0`** (`queue_families_test: ok`). AI-assisted.
OreoFR commented 2026-11-28 22:01:52 +00:00

Verified by OreoFR

  • Base: main c1ecf04ed + PR head bddeb0926; green run in a merge package of 16 PRs, no new ctest failure vs main
  • Test: standalone build of queue_families_test.exe (the test is not registered in CMake)
  • Red on main: exit code 1, line 28 sat.pool == 1 && sat.index == 0
  • Green with the PR: OK
  • Verdict: READY (the test is not in CMake: ctest will never run it)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

**Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `bddeb0926`; green run in a merge package of 16 PRs, no new ctest failure vs main - Test: `standalone build of queue_families_test.exe (the test is not registered in CMake)` - Red on main: exit code 1, line 28 `sat.pool == 1 && sat.index == 0` - Green with the PR: OK - Verdict: READY (the test is not in CMake: ctest will never run it) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
TheGeogeo commented 2026-11-28 22:49:46 +00:00

Tested bddeb0926 merged (no commit) with main aa918e5d9, MSVC 19.52 (Visual Studio 18), Windows 11 10.0.26300.

Blocker: runtime/test/queue_families_test.cpp is new but is not registered in runtime/CMakeLists.txt, so neither CI nor ctest ever builds or runs it. ctest -N on the merge lists no such test, and tests/test_ctest_registration.py still passes, so nothing catches this. Registering it the way the other header-only tests are would fix that:

add_executable(queue_families_test test/queue_families_test.cpp)
add_test(NAME queue_families COMMAND queue_families_test)

Also, queue_families.h includes vulkan/vulkan.h, so this test needs target_link_libraries(queue_families_test PRIVATE Vulkan::Headers) inside the if(TARGET Vulkan::Headers) block.

Hand-compiled (cl /std:c++20 /EHsc /O2):

  • Green: queue_families_test: ok, exit 0.
  • Red, with runtime/src/queue_families.h back to main: line 28: sat.pool == 1 && sat.index == 0, exit 1.

I did not run the ctest tests relinked by the header change: test runs on this machine are paused for memory.

AI-assisted (Claude Code).

Tested `bddeb0926` merged (no commit) with `main` `aa918e5d9`, MSVC 19.52 (Visual Studio 18), Windows 11 10.0.26300. **Blocker:** `runtime/test/queue_families_test.cpp` is new but is not registered in `runtime/CMakeLists.txt`, so neither CI nor `ctest` ever builds or runs it. `ctest -N` on the merge lists no such test, and `tests/test_ctest_registration.py` still passes, so nothing catches this. Registering it the way the other header-only tests are would fix that: ```cmake add_executable(queue_families_test test/queue_families_test.cpp) add_test(NAME queue_families COMMAND queue_families_test) ``` Also, `queue_families.h` includes `vulkan/vulkan.h`, so this test needs `target_link_libraries(queue_families_test PRIVATE Vulkan::Headers)` inside the `if(TARGET Vulkan::Headers)` block. Hand-compiled (`cl /std:c++20 /EHsc /O2`): - Green: `queue_families_test: ok`, exit 0. - Red, with `runtime/src/queue_families.h` back to `main`: `line 28: sat.pool == 1 && sat.index == 0`, exit 1. I did not run the ctest tests relinked by the header change: test runs on this machine are paused for memory. AI-assisted (Claude Code).
timbot103 reviewed 2026-11-29 04:28:10 +00:00
timbot103 left a comment
No description provided.
Static review of `bddeb0926` only. I ran no builds, tests, or GPU runs. `runtime/src/queue_families.h:110` now selects the first slot on an all-`UINT32_MAX` tie. The strict comparison keeps the first minimum in pool and slot order, so zero counts win, lower counts displace saturated ones, and no supplied slots still yields `{SIZE_MAX, 0}`. The changed condition uses the existing C++20 types and limit macros on MSVC and Linux. - In `runtime/shims/d3d12_vulkan_device.cpp:16162`, two saturated graphics slots with an empty own-family pool now select graphics slot 0. Its 32-bit live-user count wraps to zero as the caller takes the lease, so another selection can treat that busy queue as unused. Please return `E_OUTOFMEMORY` if the selected counter is already at `UINT32_MAX`, while holding `queue_mutex_` and before incrementing. - The assertion at `runtime/test/queue_families_test.cpp:28` has no CMake target or CTest entry. Please register it in the Vulkan-headers section of `runtime/CMakeLists.txt:1895` and link it to `Vulkan::Headers` so the CPU-only regression runs in the normal suite. AI-assisted.
MoonEyes commented 2026-11-29 14:26:23 +00:00

Merged. Tested by OreoFR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) on this head: queue_families_test red on main (line 28), green with the PR. Note: the test is not registered in CMake. AI-assisted: yes.

Merged. Tested by OreoFR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) on this head: queue_families_test red on main (line 28), green with the PR. Note: the test is not registered in CMake. AI-assisted: yes.
Sign in to join this conversation.
No description provided.