[pr-fix] Calculate frame-time percentiles inside the requested benchmark window #172

Open
akimfomin wants to merge 2 commits from akimfomin/Darner:codex/bench-frame-window into main
First-time contributor

Contributor role (optional)

Fluxer ID omitted.

What it changes

The benchmark used the timestamp of a five-second diagnostic message to select every frame in that batch. A stall before the requested window could inflate p99, and a short window between messages could have zero frames. This change uses the batch timestamps and the recorded precision of each frame length to keep complete intervals inside the requested window. The report flags ambiguous boundary frames and explains missing coverage. Comparing older summaries also identifies their original percentile method.

How it was tested

  • Tested on Windows 11 against main 57dea7f236. The published tree at 228427ce57 is identical to the locally tested tree at 15a483385f.
  • Invoke-Pester -Script scripts/tests/bench-window.Tests.ps1 passed 5/5 on Windows PowerShell 5.1. cargo run --quiet --locked --offline -p xtask -- policy passed.
  • Ran the unmodified and patched scripts/bench.ps1 -From on separate copies of the same archived camera run. Compared each result with complete frame intervals from its timestamped CSV. Times below are p99 in milliseconds.
Window after the world marker Main, frames / p99 Patched, frames / p99 Independent CSV, frames / p99
10–20 s 233 / 198.6 244 / 73.1 244 / 73.05
31–33 s 0 / unavailable 50 / 52.4 51 / 52.34
30–60 s 718 / 70.2 688 / 74.6 689 / 74.57

The text log has coarser precision than the CSV. The two one-frame differences are at the window boundary. Coverage was offline with archived data and synthetic fixtures. No new gameplay sample or workspace-wide Clippy/test gate was run.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR’s dependencies below.
    • Depends on: none.

Checked for overlap

  • Searched open and closed issues and PRs for the same symptom and checked open PRs touching this script.
  • #152 discusses A/B measurement in the guide. It does not change window selection in the script. The separate crash-record change touches the same script. A local Git trial merge of the two branches completed without conflicts.
## Contributor role (optional) Fluxer ID omitted. ## What it changes The benchmark used the timestamp of a five-second diagnostic message to select every frame in that batch. A stall before the requested window could inflate p99, and a short window between messages could have zero frames. This change uses the batch timestamps and the recorded precision of each frame length to keep complete intervals inside the requested window. The report flags ambiguous boundary frames and explains missing coverage. Comparing older summaries also identifies their original percentile method. ## How it was tested - Tested on Windows 11 against main `57dea7f236`. The published tree at `228427ce57` is identical to the locally tested tree at `15a483385f`. - `Invoke-Pester -Script scripts/tests/bench-window.Tests.ps1` passed 5/5 on Windows PowerShell 5.1. `cargo run --quiet --locked --offline -p xtask -- policy` passed. - Ran the unmodified and patched `scripts/bench.ps1 -From` on separate copies of the same archived camera run. Compared each result with complete frame intervals from its timestamped CSV. Times below are p99 in milliseconds. | Window after the world marker | Main, frames / p99 | Patched, frames / p99 | Independent CSV, frames / p99 | |---|---:|---:|---:| | 10–20 s | 233 / 198.6 | 244 / 73.1 | 244 / 73.05 | | 31–33 s | 0 / unavailable | 50 / 52.4 | 51 / 52.34 | | 30–60 s | 718 / 70.2 | 688 / 74.6 | 689 / 74.57 | The text log has coarser precision than the CSV. The two one-frame differences are at the window boundary. Coverage was offline with archived data and synthetic fixtures. No new gameplay sample or workspace-wide Clippy/test gate was run. ## Checklist - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR’s dependencies below. - Depends on: none. ## Checked for overlap - [x] Searched open and closed issues and PRs for the same symptom and checked open PRs touching this script. - #152 discusses A/B measurement in the guide. It does not change window selection in the script. The separate crash-record change touches the same script. A local Git trial merge of the two branches completed without conflicts.
Contributor

Independent offline check against main ad070f0 and PR 228427ce, using the full scripts/bench.ps1 -From path on Windows PowerShell 5.1. The five Pester tests also passed.

With a 1,000 ms pause at t=1 s in the batch printed at t=5 s, the 4–6 s window reports 41 frames / p99 1,000 ms on main and 9 complete frames / p99 100 ms on the PR. The PR's smoothness.longest_gap_ms still reports 1,000 ms, with the event stamped at t=1 s. That field continues to describe the batches printed in the window, alongside the newly clipped percentiles.

I found one remaining edge in Get-WindowFrameTimes. The 6–8 s window yields 17 frames / p99 100 ms with 100 ms intervals and batch stamps at 0, 5, 10, 15, and 20 s. Changing only the final stamp from 20 to 15 s after the requested window gives 0 frames / p99 unavailable, even though the window is already bracketed. The non-positive span check runs before filtering the disjoint tail.

In a local trial, skipping a pair when both timestamps are past $to, before checking the span, restored the 17 frames and 100 ms p99. As a control, a reversed pair at 15 s and 7 s that crosses back into the window still withheld the result.

Independent offline check against main `ad070f0` and PR `228427ce`, using the full `scripts/bench.ps1 -From` path on Windows PowerShell 5.1. The five Pester tests also passed. With a 1,000 ms pause at t=1 s in the batch printed at t=5 s, the 4–6 s window reports **41 frames / p99 1,000 ms** on main and **9 complete frames / p99 100 ms** on the PR. The PR's `smoothness.longest_gap_ms` still reports 1,000 ms, with the event stamped at t=1 s. That field continues to describe the batches printed in the window, alongside the newly clipped percentiles. I found one remaining edge in `Get-WindowFrameTimes`. The 6–8 s window yields **17 frames / p99 100 ms** with 100 ms intervals and batch stamps at 0, 5, 10, 15, and 20 s. Changing only the final stamp from 20 to 15 s after the requested window gives **0 frames / p99 unavailable**, even though the window is already bracketed. The non-positive span check runs before filtering the disjoint tail. In a local trial, skipping a pair when both timestamps are past `$to`, before checking the span, restored the 17 frames and 100 ms p99. As a control, a reversed pair at 15 s and 7 s that crosses back into the window still withheld the result.
Author
First-time contributor

Thanks for the reproducer. I reproduced the zero-frame result on 228427ce and fixed it in 700df021da. In the 6–8 s window, final timestamps of 20, 15, and 12 s now all preserve 17 complete frames and a 100 ms p99. If the timestamp subsequently returns to 7 s, the benchmark still withholds the percentile and explains why.

All seven Windows PowerShell 5.1 Pester tests passed through the offline bench.ps1 -From path. The asset check passed for 554 files. The published tree matches the tested tree. As you noted, smoothness.longest_gap_ms still aggregates batches by their report timestamp.

Thanks for the reproducer. I reproduced the zero-frame result on 228427ce and fixed it in 700df021da. In the 6–8 s window, final timestamps of 20, 15, and 12 s now all preserve 17 complete frames and a 100 ms p99. If the timestamp subsequently returns to 7 s, the benchmark still withholds the percentile and explains why. All seven Windows PowerShell 5.1 Pester tests passed through the offline `bench.ps1 -From` path. The asset check passed for 554 files. The published tree matches the tested tree. As you noted, `smoothness.longest_gap_ms` still aggregates batches by their report timestamp.
First-time contributor

Tested 700df021da42 through scripts/bench.ps1 -From on Windows PowerShell 5.1. I used 200 consecutive archived bench-kit CSV rows (zero reported row loss) to make three synthetic diagnostic batches, then compared the PR with complete intervals in the raw CSV. For 61–70 s, the PR retained 90 frames at p99 165.7 ms; the CSV had 91 at 165.608 ms. For 68–74 s, the last batch ended at 70.492898 s: the PR retained 25 frames at 147.2 ms, versus 26 at 147.172 ms within the same coverage. Both p99 values agree after the producer rounds durations upward to tenths of a millisecond. The report also identified ambiguous boundary intervals. This was offline parser validation with archived timings.

I also checked a wider, fully bracketed 14-second window from the same CSV. The PR retained 143 intervals and reported p99 165.7 ms and p99.9 182.5 ms. Across the 144 complete raw CSV intervals, nearest-rank p99 was 165.608 ms and the maximum was 182.407 ms. The report flagged one ambiguous boundary interval. Here p99 is distinct from the maximum, and both reported values match the producer’s upward rounding to 0.1 ms.

Tested `700df021da42` through `scripts/bench.ps1 -From` on Windows PowerShell 5.1. I used 200 consecutive archived bench-kit CSV rows (zero reported row loss) to make three synthetic diagnostic batches, then compared the PR with complete intervals in the raw CSV. For 61–70 s, the PR retained 90 frames at p99 165.7 ms; the CSV had 91 at 165.608 ms. For 68–74 s, the last batch ended at 70.492898 s: the PR retained 25 frames at 147.2 ms, versus 26 at 147.172 ms within the same coverage. Both p99 values agree after the producer rounds durations upward to tenths of a millisecond. The report also identified ambiguous boundary intervals. This was offline parser validation with archived timings. I also checked a wider, fully bracketed 14-second window from the same CSV. The PR retained 143 intervals and reported p99 165.7 ms and p99.9 182.5 ms. Across the 144 complete raw CSV intervals, nearest-rank p99 was 165.608 ms and the maximum was 182.407 ms. The report flagged one ambiguous boundary interval. Here p99 is distinct from the maximum, and both reported values match the producer’s upward rounding to 0.1 ms.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'codex/bench-frame-window:akimfomin-codex/bench-frame-window'
git switch 'akimfomin-codex/bench-frame-window'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'akimfomin-codex/bench-frame-window'
git switch 'akimfomin-codex/bench-frame-window'
git rebase 'main'
git switch 'main'
git merge --ff-only 'akimfomin-codex/bench-frame-window'
git switch 'akimfomin-codex/bench-frame-window'
git rebase 'main'
git switch 'main'
git merge --no-ff 'akimfomin-codex/bench-frame-window'
git switch 'main'
git merge --squash 'akimfomin-codex/bench-frame-window'
git switch 'main'
git merge --ff-only 'akimfomin-codex/bench-frame-window'
git switch 'main'
git merge 'akimfomin-codex/bench-frame-window'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
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
TrustNo1/Darner!172
No description provided.