Timeline: sleep between sampling scans #3942

Open
github-bot wants to merge 1 commit from github-bot/gh-3942 into main AGit
Owner

@⁠john-9474 on GitHub · 2026-11-30 12:33 UTC · original
john-9474:codex/timeline-sampler-sleep → main · +144 −9 · 2 files · 1 commits · open

The native timeline sampler busy-waits for 250µs after each scan, so the observer itself consumes roughly a CPU core while recording. Replace that tail spin with std::thread::sleep(250µs). Sampling remains opt-in through the existing diagnostics timeline; there is no new runtime switch or timer API.

This reduces sampling density. Documentation now states the actual contract: scan time plus at least 250µs asleep, with OS wake-up jitter, rather than a fixed 4kHz promise. Longer gaps can miss short work, so comparisons should use actual timestamps and sample counts.

A controlled native off/on/off comparison completed six 20-frame windows, with zero lost events and the registered target thread sampled in every window. The sampler's native CPU estimate fell from 24.9–29.2ms/frame to 1.1–1.2ms/frame. Median sample intervals increased from 266–270µs to about 547µs; p95 increased from 419–608µs to 1,217–1,267µs, with about 54% fewer samples inside the captured frame windows. These are observer-cost/cadence results, not a game FPS claim. The native CPU accounting is a cycle-counter estimate rather than an exact utilization percentage; teardown samples outside the first/last present were excluded from density calculations.

Two ignored, asset-free measurements make the behavior reproducible without a title or GPU: sample_pacing prints thread CPU cost and wait quantiles for the actual sleep helper and the previous spin; own_workers_are_sampled_and_the_sampler_stops exercises the real sampler against zero, one and three controlled Rust workers in its own process, checking sample coverage and recording cleanup after scoped joins. The fixture does not change the existing context-reading implementation. Scheduler-dependent timings and whether the sampler was already finished when capture teardown returned are reported rather than imposed as ordinary CI deadlines.

Focused validation on Windows:

  • Diagnostics GPU libtest built with cargo test --locked --profile diag -p victory-gpu --features diagnostics --lib --no-run; a final repeat confirmed the fingerprint after every source edit. Production-lib cargo check --locked --profile diag -p victory-gpu --features diagnostics passed.
  • Seven pure timeline tests passed (the original native real_waits hook test was excluded from this focused run).
  • The exact ignored owned-worker fixture passed in a fresh process: zero/one/three workers produced 0/180/528 samples, with no lost events or foreign sampled threads and recording state reset after joins. The sampler was already finished when end() returned in all three cases.
  • The exact ignored pacing measurement passed with no competing build/game/benchmark. Each spin control used 1,000ms thread CPU in 1,000ms wall; the sleep helper reported 0/15.625ms CPU in its two 1s trials, with median waits 516.5–517.6µs and p95 539.9–543.6µs. Thread CPU accounting is quantised; a reported zero is below its accounting quantum, not zero cost. The spin median was 250.1µs. These pauses alone do not measure context-sampling cost.
  • Staged asset policy (two files) and git diff --cached --check passed.

The new measurements are ignored tests, with no ordinary-CI timing thresholds. The full suite was not run.

Overlap scan: #1575 extends the same sampler to list threads but retains its spin; #2371 and #3913 change FSR presentation only. No existing sampler-pacing/sleep contribution was found.

**@⁠john-9474** on GitHub · 2026-11-30 12:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3942) `john-9474:codex/timeline-sampler-sleep` → `main` · +144 −9 · 2 files · 1 commits · open The native timeline sampler busy-waits for 250µs after each scan, so the observer itself consumes roughly a CPU core while recording. Replace that tail spin with `std::thread::sleep(250µs)`. Sampling remains opt-in through the existing diagnostics timeline; there is no new runtime switch or timer API. This reduces sampling density. Documentation now states the actual contract: scan time plus at least 250µs asleep, with OS wake-up jitter, rather than a fixed 4kHz promise. Longer gaps can miss short work, so comparisons should use actual timestamps and sample counts. A controlled native off/on/off comparison completed six 20-frame windows, with zero lost events and the registered target thread sampled in every window. The sampler's native CPU estimate fell from 24.9–29.2ms/frame to 1.1–1.2ms/frame. Median sample intervals increased from 266–270µs to about 547µs; p95 increased from 419–608µs to 1,217–1,267µs, with about 54% fewer samples inside the captured frame windows. These are observer-cost/cadence results, not a game FPS claim. The native CPU accounting is a cycle-counter estimate rather than an exact utilization percentage; teardown samples outside the first/last present were excluded from density calculations. Two ignored, asset-free measurements make the behavior reproducible without a title or GPU: `sample_pacing` prints thread CPU cost and wait quantiles for the actual sleep helper and the previous spin; `own_workers_are_sampled_and_the_sampler_stops` exercises the real sampler against zero, one and three controlled Rust workers in its own process, checking sample coverage and recording cleanup after scoped joins. The fixture does not change the existing context-reading implementation. Scheduler-dependent timings and whether the sampler was already finished when capture teardown returned are reported rather than imposed as ordinary CI deadlines. Focused validation on Windows: - Diagnostics GPU libtest built with `cargo test --locked --profile diag -p victory-gpu --features diagnostics --lib --no-run`; a final repeat confirmed the fingerprint after every source edit. Production-lib `cargo check --locked --profile diag -p victory-gpu --features diagnostics` passed. - Seven pure timeline tests passed (the original native `real_waits` hook test was excluded from this focused run). - The exact ignored owned-worker fixture passed in a fresh process: zero/one/three workers produced 0/180/528 samples, with no lost events or foreign sampled threads and recording state reset after joins. The sampler was already finished when `end()` returned in all three cases. - The exact ignored pacing measurement passed with no competing build/game/benchmark. Each spin control used 1,000ms thread CPU in 1,000ms wall; the sleep helper reported 0/15.625ms CPU in its two 1s trials, with median waits 516.5–517.6µs and p95 539.9–543.6µs. Thread CPU accounting is quantised; a reported zero is below its accounting quantum, not zero cost. The spin median was 250.1µs. These pauses alone do not measure context-sampling cost. - Staged asset policy (two files) and `git diff --cached --check` passed. The new measurements are ignored tests, with no ordinary-CI timing thresholds. The full suite was not run. Overlap scan: #1575 extends the same sampler to list threads but retains its spin; #2371 and #3913 change FSR presentation only. No existing sampler-pacing/sleep contribution was found.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 12:34:39 +00:00
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 origin '+refs/pull/3942/head:github-bot/gh-3942'
git switch 'github-bot/gh-3942'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3942'
git switch 'github-bot/gh-3942'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3942'
git switch 'github-bot/gh-3942'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3942'
git switch 'main'
git merge --squash 'github-bot/gh-3942'
git switch 'main'
git merge --ff-only 'github-bot/gh-3942'
git switch 'main'
git merge 'github-bot/gh-3942'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
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
github/trustno1-coder--VIctory-NVIDIA!3942
No description provided.