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

Open
github-bot wants to merge 1 commit from github-bot/gh-2310 into main AGit
Owner

@⁠narekshaghoyandev on GitHub · 2026-11-26 13:42 UTC · original
narekshaghoyandev:ubiq-queue-families-slot-max → main · +40 −1 · 2 files · 1 commits · open

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 (#1608)
AI-assisted: yes (Gemini)

**@⁠narekshaghoyandev** on GitHub · 2026-11-26 13:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2310) `narekshaghoyandev:ubiq-queue-families-slot-max` → `main` · +40 −1 · 2 files · 1 commits · open 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://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) AI-assisted: yes (Gemini)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:44:33 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 20:50 UTC · original · reviewed

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.

**@⁠lixonik** on GitHub · 2026-11-26 20:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2310#pullrequestreview-6080354619) · **reviewed** 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.
@ -0,0 +25,4 @@
// Regression: non-empty pool where every slot has UINT32_MAX users must still pick the earliest slot.
const std::array<std::uint32_t, 2> saturated{UINT32_MAX, UINT32_MAX};
const auto sat = pick_queue_slot({empty, saturated});
EXPECT(sat.pool == 1 && sat.index == 0);
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 20:50 UTC · original

[P3] Include this regression in the normal CTest run. I could reproduce the red/green result by compiling this file directly, but the configured runtime build has no target or test for it. The existing vk_queue_test.cpp already covers the empty-pool and tie cases of pick_queue_slot. Adding the saturated case alongside those would exercise it in CI without another executable.

**@⁠lixonik** on GitHub · 2026-11-26 20:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2310#discussion_r4713258570) [P3] Include this regression in the normal CTest run. I could reproduce the red/green result by compiling this file directly, but the configured runtime build has no target or test for it. The existing `vk_queue_test.cpp` already covers the empty-pool and tie cases of `pick_queue_slot`. Adding the saturated case alongside those would exercise it in CI without another executable.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2310/head:github-bot/gh-2310'
git switch 'github-bot/gh-2310'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2310'
git switch 'github-bot/gh-2310'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2310'
git switch 'github-bot/gh-2310'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2310'
git switch 'main'
git merge --squash 'github-bot/gh-2310'
git switch 'main'
git merge --ff-only 'github-bot/gh-2310'
git switch 'main'
git merge 'github-bot/gh-2310'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.