runtime: early-exit pending_through and cache semaphore completions in RetireTickets #2025
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2025"
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?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T18:28:20Z.
Coordination item:
RT-RETIRE-TICKETS-EARLY-BREAK-AND-SEM-CACHE(claimed on #1608).Why
RetireTickets::pending_through(ticket)scanned the entirepending_deque even though normalrecord()calls arrive in non-decreasing ticket order (as documented at the top ofretire_tickets.h). Under deletion-queue backpressure (VulkanBackend::wait_retire_ticket(old_ticket)), scanning thousands of newer in-flight submissions wastes mutex-held CPU time undersubmit_mutex_.RetireTickets::completed(query)invoked the caller's Vulkan semaphore query (vkGetSemaphoreCounterValue) for every non-idle pending entry, even when a previous entry in the same pass already confirmed an equal or higher timeline value on that semaphore.Changes
runtime/src/retire_tickets.h:monotonic_(automatically reset totruewhenpending_drains, cleared if an out-of-order ticket< pending_.back().ticketis recorded) sopending_through(ticket)returns immediately whenticket < pending_.front().ticketand breaks as soon asentry.ticket > ticketin the monotonic case, while preserving full-scan exactness for out-of-order tickets.(semaphore, highest_confirmed_value)entries on the stack insidecompleted(query)so subsequent entries in the same pass withfront.value <= confirmedskip redundantquery()calls.runtime/test/retire_tickets_test.cpp: add tests for per-pass confirmed-value caching, >8-semaphore cache eviction, non-monotonicpending_through()fallback, monotonic reset after drain, and cutoff-before-front early return.Verification
runtime/test/retire_tickets_test.cppwithclang++ -std=c++20 -Wall -Wextra -Werror:-O1 -g -fsanitize=address,undefined): PASS.-O1 -g -fsanitize=thread): PASS.-O2): PASS.-O2benchmark (50,000 calls topending_through(16)on 4,096 pending submissions across 3 queues):main:137.223 ms(acc=2400000)8.417 ms(acc=2400000, 16.30× faster, bit-exact).python3 -I scripts/check_no_game_data.py runtime/src/retire_tickets.h runtime/test/retire_tickets_test.cpp: clean.python3 -I tests/test_text_write_line_endings.py: 3/3 OK.Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T18:28:32Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:51:50Z.
Verified on Windows 11 (
10.0.26200.9974) with MSVC19.44.35228(x64,/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) againstmain24549bdb1+cf5127e81(claim#2570#issuecomment-7238799031):runtime/src/retire_tickets.h,runtime/test/retire_tickets_test.cpp); caches confirmed timeline values per semaphore (8-slot ring) withincompleted()to skip redundant counter queries on repeated/lower values, and tracksmonotonic_ticket order sopending_through()early-exits when monotonic while remaining exact when out-of-order tickets are recorded.check_no_game_data.pyclean.24549bdb1+ PR test):retire_tickets_test.exefails (rc=8, redundant semaphore queries on repeated/lower timeline values).24549bdb1+cf5127e81merge): Merges cleanly (rc=0), compiles with0/W4warnings, andretire_tickets_test.exepasses (out-of-order queue completion kept the retirement prefix safe,rc=0).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:54:18Z.
Red/green: On main retire_tickets_test exits with code 8 (completions are not cached, so retired/query counts are wrong), and with the PR ctest -R "^retire_tickets$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main
c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:58:13Z.
Verified by OreoFR
c1ecf04ed+ PR headcf5127e81; green run in a merge package of 16 PRs, no new ctest failure vs mainctest -R ^retire_tickets$AI-assisted (Claude Code, Claude Opus 5.5).