Skip to content

Time replay phases from the timestamp counter - #304

Closed
SkippySteve wants to merge 1 commit into
NotRexed:mainfrom
SkippySteve:fix/replay-clock
Closed

SkippySteve wants to merge 1 commit into
NotRexed:mainfrom
SkippySteve:fix/replay-clock

Conversation

@SkippySteve

Copy link
Copy Markdown
Contributor

Summary

  • The per-phase replay timers called QueryPerformanceCounter on the way into and out of every draw, dispatch, and descriptor build. The WebGPU renderer already measured ten of those reads as about 4% of the GPU thread, and switched its own stats clock to the timestamp counter.
  • prof_now now reads the invariant TSC after one calibration against the performance counter. When that counter's tick is a whole number of nanoseconds (Linux reports 1 ns), the conversion is an integer multiply, so a reading past 2^53 keeps its low bits.
  • The phase log is unchanged. If the calibration cannot get a span, the old counter path remains.

Test plan

  • python -I -B tests/test_prof_clock.py passes
  • The same test fails if the conversion always uses the double divide ((1<<53)+3 nanoseconds round away) and fails if prof_now no longer returns the timestamp-counter reading
  • CI: "Check the replay clock skips the performance counter"

A performance-counter read on every phase of every draw was already measured at about 4% of the GPU thread, and the double conversion dropped bits past 2^53.
@NotRexed

NotRexed commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Thanks! This one changes timing/locking on the replay's hot path, so I'll measure it (fps and frame times in Kokiri, plus a few boots) before merging. The two clock-gating PRs (#306, #308) are merged.

@NotRexed

NotRexed commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Thanks! Measured together with the other replay PRs (replay 27 -> 24-25 ms a frame, fps 23 -> 26 in Kokiri) and applied by hand (conflicts only in the CI workflow; #310 and #315 needed one declaration moved), pushed in 40c3f85.

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