runtime: frame pacing drift and latency percentile reporting (BL-6) #891

Manually merged
github merged 1 commit from gh-pr/891/head into gh-pr/891/base 2026-11-26 09:26:34 +00:00
Owner

@⁠SweatierKey on GitHub · 2026-11-24 14:58 UTC · original
SweatierKey:feat/bl6-frame-pacing-drift → main · +320 −4 · 8 files · 1 commits · merged 2026-11-24 18:24 UTC

Claimed in the coordination issue as: BL-6 (#14)

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.)
**@⁠SweatierKey** on GitHub · 2026-11-24 14:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/891) `SweatierKey:feat/bl6-frame-pacing-drift` → `main` · +320 −4 · 8 files · 1 commits · merged 2026-11-24 18:24 UTC Claimed in the coordination issue as: BL-6 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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`.)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:26:32 +00:00
github manually merged commit 7bb915dd3e into gh-pr/891/base 2026-11-26 09:26:34 +00:00
Author
Owner

@⁠morodirule on GitHub · 2026-11-24 16:45 UTC · original

Independent Linux check (native g++-13, no game/GPU/Wine): frame_pacer_test from head 7bb915dd3 builds clean and reports "all cases pass", exit 0, including the BL-6 fake-clock section (p50/p95/p99, mean drift, origin-to-present latency). Main frame_pacer.h has no p50_us/drift_us fields, so the new reporting tests inherently exercise the header change. Not claiming; review evidence.

**@⁠morodirule** on GitHub · 2026-11-24 16:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/891#issuecomment-7138168199) Independent Linux check (native g++-13, no game/GPU/Wine): frame_pacer_test from head 7bb915dd3 builds clean and reports "all cases pass", exit 0, including the BL-6 fake-clock section (p50/p95/p99, mean drift, origin-to-present latency). Main frame_pacer.h has no p50_us/drift_us fields, so the new reporting tests inherently exercise the header change. Not claiming; review evidence.
This discussion has been locked. Commenting is limited to contributors.
No description provided.