[PR #891] [MERGED] runtime: frame pacing drift and latency percentile reporting (BL-6) #929

Closed
opened 2026-11-26 20:19:31 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/891
Author: @SweatierKey
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @aslan2142

Base: main ← Head: feat/bl6-frame-pacing-drift


📝 Commits (1)

  • 7bb915d runtime: frame pacing drift and latency percentile reporting (BL-6)

📊 Changes

8 files changed (+320 additions, -4 deletions)

View changed files

📝 docs/boot.md (+5 -2)
📝 docs/d3d12_vulkan.md (+8 -0)
📝 runtime/shims/xbox_present.cpp (+21 -0)
📝 runtime/shims/xbox_present.h (+3 -0)
📝 runtime/src/frame_pacer.h (+99 -1)
📝 runtime/test/frame_pacer_test.cpp (+108 -0)
📝 tests/test_boot_trace.py (+36 -0)
📝 tools/boot_trace.py (+40 -1)

📄 Description

Claimed in the coordination issue as: BL-6 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134996146)

What and why

Implements boot lead BL-6 (docs/boot_leads.md): long-running frame pacing can drift against the target interval, and per-frame percentiles plus origin-to-present latency make that drift visible in run summaries.

  • runtime/src/frame_pacer.h:
    • Adds fixed-capacity ring buffers (frame_pacing_window = 1024) recording present-to-present frame intervals and origin-to-present latencies across commit_present_token and note_untokened_present.
    • Resets the last-present anchor across suspend() so suspended pauses do not pollute frame-time statistics after resume.
    • Adds FramePacer::pacing_summary() returning FramePacingSummary (frames, samples, target_interval_us, mean_us, drift_us = mean_us - target_interval_us, nearest-rank p50_us/p95_us/p99_us, and latency_samples/latency_p50_us/latency_p95_us/latency_p99_us). Unpaced/uncapped runs keep target_interval_us = 0 and drift_us = 0.0 while still tracking frame intervals.
  • runtime/shims/xbox_present.h, runtime/shims/xbox_present.cpp:
    • Exposes XboxPresentation::pacing_summary() and log_pacing_summary(), and logs one [rt] present: pacing summary ... line on stderr at teardown whenever at least one frame was presented.
  • tools/boot_trace.py:
    • Parses [rt] present: pacing summary ... from --d3d12 stderr logs (including PowerShell's <exe> : prefix), renders the frame-pacing summary line beside the D3D12 counts in text output, and includes the numeric frame_pacing dictionary in --json and --counts-only.
  • docs/d3d12_vulkan.md, docs/boot.md:
    • Documents the ring buffer, percentile/drift calculation, confirmation tests, and summary fields.

Tested

  • Built frame_pacer_test.exe, xbox_present_test.exe, and gta6rt.exe cleanly with clang-cl 23.1.6 + Windows SDK 10.0.26100 + ninja.
  • frame_pacer_test.exe: PASS (all cases pass), including 6 new fake-clock (ManualFrameClock) test cases covering empty/single-frame edge cases, a 100-frame known distribution (exact p50/p95/p99, mean_us, positive drift_us, and origin-to-present latencies), negative drift, suspend()/resume() pause exclusion, full 1024-frame ring-buffer wrap-around, and uncapped mode.
  • xbox_present_test.exe on NVIDIA GeForce RTX 5070 Ti: PASS (all cases pass), confirming live [rt] present: pacing summary ... output at teardown (e.g. frames=35 samples=34 target_us=16667 mean_us=18002.1 drift_us=+1335.1 p50_us=16513 p95_us=38025 p99_us=48016 latency_samples=34 latency_p50_us=718 latency_p95_us=21880 latency_p99_us=32067).
  • python3 -I tests/test_boot_trace.py: 33/33 passed (including new test_frame_pacing_summary_parsed_formatted_and_kept_in_counts_only).
  • python3 -I tests/test_dev_boot_trace.py: 5/5 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed; python3 -I scripts/check_no_game_data.py and python3 -m compileall -q make_game.py tools tests: passed.

GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 616.92, Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — runtime/tooling lead recorded in docs/d3d12_vulkan.md and docs/boot.md per docs/boot_leads.md.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/891 **Author:** [@SweatierKey](https://github.com/SweatierKey) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `feat/bl6-frame-pacing-drift` --- ### 📝 Commits (1) - [`7bb915d`](https://github.com/ubiquitarianism/leonida/commit/7bb915dd3e8ee68a2591cc93814ddb201f59464c) runtime: frame pacing drift and latency percentile reporting (BL-6) ### 📊 Changes **8 files changed** (+320 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+5 -2) 📝 `docs/d3d12_vulkan.md` (+8 -0) 📝 `runtime/shims/xbox_present.cpp` (+21 -0) 📝 `runtime/shims/xbox_present.h` (+3 -0) 📝 `runtime/src/frame_pacer.h` (+99 -1) 📝 `runtime/test/frame_pacer_test.cpp` (+108 -0) 📝 `tests/test_boot_trace.py` (+36 -0) 📝 `tools/boot_trace.py` (+40 -1) </details> ### 📄 Description Claimed in the coordination issue as: BL-6 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134996146) ### What and why Implements boot lead **BL-6** (`docs/boot_leads.md`): long-running frame pacing can drift against the target interval, and per-frame percentiles plus origin-to-present latency make that drift visible in run summaries. - **`runtime/src/frame_pacer.h`**: - Adds fixed-capacity ring buffers (`frame_pacing_window = 1024`) recording present-to-present frame intervals and origin-to-present latencies across `commit_present_token` and `note_untokened_present`. - Resets the last-present anchor across `suspend()` so suspended pauses do not pollute frame-time statistics after resume. - Adds `FramePacer::pacing_summary()` returning `FramePacingSummary` (`frames`, `samples`, `target_interval_us`, `mean_us`, `drift_us = mean_us - target_interval_us`, nearest-rank `p50_us`/`p95_us`/`p99_us`, and `latency_samples`/`latency_p50_us`/`latency_p95_us`/`latency_p99_us`). Unpaced/uncapped runs keep `target_interval_us = 0` and `drift_us = 0.0` while still tracking frame intervals. - **`runtime/shims/xbox_present.h`, `runtime/shims/xbox_present.cpp`**: - Exposes `XboxPresentation::pacing_summary()` and `log_pacing_summary()`, and logs one `[rt] present: pacing summary ...` line on stderr at teardown whenever at least one frame was presented. - **`tools/boot_trace.py`**: - Parses `[rt] present: pacing summary ...` from `--d3d12` stderr logs (including PowerShell's `<exe> : ` prefix), renders the frame-pacing summary line beside the D3D12 counts in text output, and includes the numeric `frame_pacing` dictionary in `--json` and `--counts-only`. - **`docs/d3d12_vulkan.md`, `docs/boot.md`**: - Documents the ring buffer, percentile/drift calculation, confirmation tests, and summary fields. ### Tested - Built `frame_pacer_test.exe`, `xbox_present_test.exe`, and `gta6rt.exe` cleanly with `clang-cl 23.1.6` + Windows SDK `10.0.26100` + `ninja`. - `frame_pacer_test.exe`: PASS (`all cases pass`), including 6 new fake-clock (`ManualFrameClock`) test cases covering empty/single-frame edge cases, a 100-frame known distribution (exact `p50`/`p95`/`p99`, `mean_us`, positive `drift_us`, and origin-to-present latencies), negative drift, `suspend()`/`resume()` pause exclusion, full 1024-frame ring-buffer wrap-around, and uncapped mode. - `xbox_present_test.exe` on NVIDIA GeForce RTX 5070 Ti: PASS (`all cases pass`), confirming live `[rt] present: pacing summary ...` output at teardown (e.g. `frames=35 samples=34 target_us=16667 mean_us=18002.1 drift_us=+1335.1 p50_us=16513 p95_us=38025 p99_us=48016 latency_samples=34 latency_p50_us=718 latency_p95_us=21880 latency_p99_us=32067`). - `python3 -I tests/test_boot_trace.py`: 33/33 passed (including new `test_frame_pacing_summary_parsed_formatted_and_kept_in_counts_only`). - `python3 -I tests/test_dev_boot_trace.py`: 5/5 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed; `python3 -I scripts/check_no_game_data.py` and `python3 -m compileall -q make_game.py tools tests`: passed. GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 616.92, Windows 11 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (N/A — runtime/tooling lead recorded in `docs/d3d12_vulkan.md` and `docs/boot.md` per `docs/boot_leads.md`.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:31 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#929
No description provided.