Skip to content

present: look up retained frame tokens by age - #1198

Open
Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:perf/retained-frame-token-lookup
Open

Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:perf/retained-frame-token-lookup

Conversation

@Kadamitas

@Kadamitas Kadamitas commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

@Kadamitas
Kadamitas force-pushed the perf/retained-frame-token-lookup branch from 63d70f3 to 7b61143 Compare November 24, 2026 20:17
clquwu pushed a commit to clquwu/leonida-ultimate that referenced this pull request Nov 25, 2026
…e pacing (#891/#1198/#1237/#939), and capture guard (#1223)

- Composite unflagged 2-plane PresentX UI overlays (SDR+SDR, HDR10+HDR10, SDR+HDR10) while keeping HDR10 + unflagged SDR GameDVR copy exclusion (clean-room concept from Marvisak/VIctory #211, GPL-3.0).
- Guard VulkanPresenter::make_capture_buffer() against null vkGetPhysicalDeviceMemoryProperties_ before buffer allocation (ProjectLeonida/mandy#1223).
- Cancel FramePacer waits spanning suspend/resume/re-registration via suspend_generation_ (ProjectLeonida/mandy#1237).
- Add O(1) age-indexed retained token lookup with FrameTokenSource-safe binary-search fallback and pre-issue record append (ProjectLeonida/mandy#1198).
- Add BL-6 frame-pacing drift and latency percentile reporting (p50/p95/p99, suspend-gap exclusion, teardown summary log) (ProjectLeonida/mandy#891).
- Wire current_origin_poll into FramePacer from XboxPresentation (ProjectLeonida/mandy#939).
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@PierreEbele

Copy link
Copy Markdown
Contributor

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

Origin waits append consecutive tokens to the 64-record history. Index the matching record from the back and reuse it during present, statistics and retirement. Advance the issued counter only after appending succeeds, so a failed allocation cannot leave a hole in the history.
@Kadamitas
Kadamitas force-pushed the perf/retained-frame-token-lookup branch from 7b61143 to 475d6b2 Compare November 27, 2026 18:56
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants