present: look up retained frame tokens by age #1198

Closed
Kadamitas wants to merge 1 commit from upstream-pr/1198 into main
Kadamitas commented 2026-11-24 20:02:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kadamitas on 2026-11-24T20:02:42Z.


Claimed in the coordination issue as direct lookup of retained FramePacer records.

What and why

Several FramePacer operations scan the same retained history to find one frame token. The shared token source can issue tokens that the pacer never records. Search the retained records by unsigned age and verify the token ID. This gives one binary lookup for statistics, present timing, and retirement while preserving missing and expired token behavior under the existing lock.

Tested

  • The Windows frame-pacer suite passed after rebasing onto 43a9d562d.
  • Regression cases cover tokens issued externally by the shared source and unrecorded polls after suspend and resume. Neither gap can return another token's record.

GPUs tested: N/A. The frame-pacer fixture uses a simulated clock.

AI-assisted: yes.

Checklist

  • Based on current main (43a9d562d).
  • One topic.
  • No game data, keys or decryption.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5479412286 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1198). Originally posted by [Kadamitas](https://github.com/Kadamitas) on 2026-11-24T20:02:42Z. --- Claimed in the coordination issue as [direct lookup of retained FramePacer records](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142953830). ### What and why Several FramePacer operations scan the same retained history to find one frame token. The shared token source can issue tokens that the pacer never records. Search the retained records by unsigned age and verify the token ID. This gives one binary lookup for statistics, present timing, and retirement while preserving missing and expired token behavior under the existing lock. ### Tested - The Windows frame-pacer suite passed after rebasing onto `43a9d562d`. - Regression cases cover tokens issued externally by the shared source and unrecorded polls after suspend and resume. Neither gap can return another token's record. GPUs tested: N/A. The frame-pacer fixture uses a simulated clock. AI-assisted: yes. ### Checklist - [x] Based on current `main` (`43a9d562d`). - [x] One topic. - [x] No game data, keys or decryption.
PierreEbele commented 2026-11-25 07:07:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T07:07:07Z.


Reviewed 7b61143: built and ran runtime/test/frame_pacer_test.cpp (g++ -std=c++20) in the sandbox on PR, main, and PR-test-on-main — all pass, and a 70-frame differential probe (aging, repeated/stale/null/untokened presents, immediate, suspend/resume, uncapped) is byte-identical across this branch, base 58be9cdf, and origin/main, so the refactor is sound at its base. However, this branch conflicts in runtime/src/frame_pacer.h (main's test does not compile against it), and the age-index lookup cannot survive a rebase onto origin/main: records_ is no longer consecutive with tokens_->issued() because FrameTokenSource is shared with the device proxy (and unregistered current_origin_poll also issues tokens without recording). With the PR's lookup hand-applied onto main's header, an external token issue makes the pacer's own freshest record disappear (statistics(2) hr=0x1 count=0 vs main hr=0x0 [time=16000]), and statistics(4) / commit_present_token(4) bind token 2's record (time=16000 vs main 32000); the same shift occurs after suspend()/resume() + unregistered current_origin_poll without a shared source. Please rebase and keep Record::token in token_record_locked() (e.g., scan or std::lower_bound on the monotonic records_ deque) so lookup survives gaps while keeping the single-lookup cleanup, and add a regression test covering shared-source / poll gaps. AI-assisted review.
Recommendation: Fix first

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7155507530 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1198#issuecomment-7155507530). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T07:07:07Z. --- Reviewed 7b61143: built and ran `runtime/test/frame_pacer_test.cpp` (`g++ -std=c++20`) in the sandbox on PR, main, and PR-test-on-main — all pass, and a 70-frame differential probe (aging, repeated/stale/null/untokened presents, immediate, suspend/resume, uncapped) is byte-identical across this branch, base `58be9cdf`, and `origin/main`, so the refactor is sound at its base. However, this branch conflicts in `runtime/src/frame_pacer.h` (main's test does not compile against it), and the age-index lookup cannot survive a rebase onto `origin/main`: `records_` is no longer consecutive with `tokens_->issued()` because `FrameTokenSource` is shared with the device proxy (and unregistered `current_origin_poll` also issues tokens without recording). With the PR's lookup hand-applied onto main's header, an external token issue makes the pacer's own freshest record disappear (`statistics(2) hr=0x1 count=0` vs main `hr=0x0 [time=16000]`), and `statistics(4)` / `commit_present_token(4)` bind token 2's record (`time=16000` vs main `32000`); the same shift occurs after `suspend()`/`resume()` + unregistered `current_origin_poll` without a shared source. Please rebase and keep `Record::token` in `token_record_locked()` (e.g., scan or `std::lower_bound` on the monotonic `records_` deque) so lookup survives gaps while keeping the single-lookup cleanup, and add a regression test covering shared-source / poll gaps. AI-assisted review. **Recommendation:** Fix first
OreoFR commented 2026-11-28 21:47:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:47:23Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head 475d6b252
  • Test: ctest -R ^frame_pacer$
  • Red on main: OK
  • Green with the PR: OK
  • Verdict: NO RED (token lookup by age; the test also passes on main; frame_pacer.h is also touched by #1263 and #1237)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246273581 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1198#issuecomment-7246273581). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:47:23Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `475d6b252` - Test: `ctest -R ^frame_pacer$` - Red on main: OK - Green with the PR: OK - Verdict: NO RED (token lookup by age; the test also passes on main; frame_pacer.h is also touched by #1263 and #1237) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-28 21:51:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T21:51:58Z.


Independent Verification Report — 475d6b2527 + origin/main (a8465211fb)

Environment: Windows 11 (26200), AMD Ryzen 9 5950X, MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8, Debug /Od /MDd & Release /O2 /MD).
Verdict: PASS (Ready to merge) — clean Git merge with origin/main (6c38876b2660).

1. Build, Correctness & Throughput Verification on Windows 11 + MSVC 19.44

  • frame_pacer_test (Debug /Od /MDd & Release /O2 /MD on 475d6b2527 + origin/main): PASS (frame_pacer_test: all cases pass), 0 warnings under /W4 /permissive-, covering shared-FrameTokenSource token gaps, unregistered wait_flag_current_token gaps across suspend()/resume(), and > 64-frame window eviction.
  • Audited token_record_locked unsigned age comparator (newest - record.token > newest - token): monotone partition invariant holds across gaps, future/unregistered tokens (token > newest), and unsigned 64-bit UINT64_MAX -> 0 wraparound.
  • Throughput (300,000 paced wait_frame_event + commit_present_token + mid-window get_frame_statistics(tok - 32) iterations, MSVC /O2 /MD):
    • origin/main (linear scans across 64-record deque): 71.16 ms
    • 475d6b2527 (token_record_locked binary search): 43.00 ms (1.65x faster end-to-end with bit-identical statistics output).
  • Cross-PR Note: Pairwise git merge-tree with open PR #1263 (origin_observed check) touches FramePacer::record_present_timing_locked; reconciling the two is a 1-line check (if (record && record->origin_observed && now >= record->origin_us)).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246329935 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1198#issuecomment-7246329935). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T21:51:58Z. --- ### Independent Verification Report — `475d6b2527` + `origin/main` (`a8465211fb`) **Environment:** Windows 11 (`26200`), AMD Ryzen 9 5950X, MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8`, Debug `/Od /MDd` & Release `/O2 /MD`). **Verdict:** **PASS (Ready to merge)** — clean Git merge with `origin/main` (`6c38876b2660`). #### 1. Build, Correctness & Throughput Verification on Windows 11 + MSVC `19.44` - `frame_pacer_test` (Debug `/Od /MDd` & Release `/O2 /MD` on `475d6b2527` + `origin/main`): **PASS** (`frame_pacer_test: all cases pass`), `0` warnings under `/W4 /permissive-`, covering shared-`FrameTokenSource` token gaps, unregistered `wait_flag_current_token` gaps across `suspend()`/`resume()`, and `> 64`-frame window eviction. - Audited `token_record_locked` unsigned age comparator (`newest - record.token > newest - token`): monotone partition invariant holds across gaps, future/unregistered tokens (`token > newest`), and unsigned 64-bit `UINT64_MAX -> 0` wraparound. - **Throughput (`300,000` paced `wait_frame_event` + `commit_present_token` + mid-window `get_frame_statistics(tok - 32)` iterations, MSVC `/O2 /MD`):** - `origin/main` (linear scans across 64-record deque): `71.16 ms` - `475d6b2527` (`token_record_locked` binary search): `43.00 ms` (**1.65x faster** end-to-end with bit-identical statistics output). - **Cross-PR Note:** Pairwise `git merge-tree` with open PR `#1263` (`origin_observed` check) touches `FramePacer::record_present_timing_locked`; reconciling the two is a 1-line check (`if (record && record->origin_observed && now >= record->origin_us)`). AI-assisted.
TheGeogeo commented 2026-11-29 14:44:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:44:43Z.


Read at 475d6b252 against main bd643e46e (diff reading, no build here). This answers the "no test" question.

  • No failing test is possible by design. The change replaces the scans of the retained history with one lookup by age, and it keeps the missing-token and expired-token results.
  • The added frame_pacer_test.cpp cases pin those results: externally issued tokens, unregistered tokens after suspend/resume, and statistics of the newest token. They pass on main too, as reported above, so they guard against regressions but do not show a red.
  • The speed claim is not covered by a test.
  • Merges cleanly with current main. frame_pacer.h is also touched by #1263 and #1237.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257542297 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1198#issuecomment-7257542297). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T14:44:43Z. --- Read at 475d6b252 against main bd643e46e (diff reading, no build here). This answers the "no test" question. - No failing test is possible by design. The change replaces the scans of the retained history with one lookup by age, and it keeps the missing-token and expired-token results. - The added `frame_pacer_test.cpp` cases pin those results: externally issued tokens, unregistered tokens after suspend/resume, and statistics of the newest token. They pass on main too, as reported above, so they guard against regressions but do not show a red. - The speed claim is not covered by a test. - Merges cleanly with current main. `frame_pacer.h` is also touched by #1263 and #1237. AI-assisted (Claude Code).
aslan2142 commented 2026-12-01 16:33:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:33:53Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317815235 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1198#issuecomment-7317815235). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:33:53Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1198
No description provided.