Skip to content

Add correlated V2 runtime latency profiles - #574

Open
ZenAlexa wants to merge 11 commits into
NVIDIA:mainfrom
ZenAlexa:contrib/538-api-user-input-latency-instrumentation
Open

ZenAlexa wants to merge 11 commits into
NVIDIA:mainfrom
ZenAlexa:contrib/538-api-user-input-latency-instrumentation

Conversation

@ZenAlexa

@ZenAlexa ZenAlexa commented Sep 3, 2026

Copy link
Copy Markdown

Summary

I added flashdreams-run-v2 --profile-path for host-side input-latency JSONL profiles. TimestampedInputSource supplies the session clock origin; each session segment includes its runtime settings and measurement endpoints.

Closes #538.

Measurements

  • input_to_ui_step_s: input timestamp to the IUILoop claiming the event.
  • input_to_window_write_s: input timestamp to the first following IClientWindow.write return. Native ends after the presenter call. WebRTC ends at the host write boundary, including queue admission when a video track is available.

Summaries retain exact counts and maxima, with a bounded 1,024-sample reservoir for median and p90. Replacement sessions receive independent profile segments.

Validation

The V2 CPU suite passed: 218 tests, 3 deselected. Focused runtime coverage includes timestamp correlation, bounded summaries, session replacement, and profile-path conflicts.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
Copilot AI lite review requested due to automatic review settings September 3, 2026 16:46
@copy-pr-bot

copy-pr-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR is not yet safe to merge because disconnected WebRTC tracks still admit writes that are recorded as completed latency observations without an active sender.

Summary

  • Adds --profile-path wiring and per-session profiler lifecycle management.
  • Correlates input events with UI claims and subsequent client-window writes.
  • Exposes timestamp origins for native and WebRTC input sources.
  • Documents measurement boundaries and adds focused runtime tests.

Diagram

sequenceDiagram
    participant Input as Input source
    participant Runtime as Session runner
    participant UI as IUILoop
    participant Window as Client window
    participant Profiler as RuntimeProfiler
    Input->>Runtime: Timestamped input events
    Runtime->>Profiler: Record pending inputs
    Runtime->>UI: Claim event batch
    Runtime->>Profiler: Record input_to_ui_step_s
    UI-->>Runtime: StepResult
    Runtime->>Window: write(StepResult)
    Window-->>Runtime: write returns
    Runtime->>Profiler: Record input_to_window_write_s
    Profiler-->>Profiler: Append JSONL records and summaries
Loading

Reviews (9) · Last reviewed commit: "Merge main into runtime input latency pr..."

Comment thread flashdreams/flashdreams/runtime_v2/serving/webrtc_server.py Outdated
Linearize peer availability and frame admission under the track state lock.
Preserve negotiation queuing and reopen admission after peer recovery.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>

@ArielG-NV ArielG-NV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment

Comment thread flashdreams/flashdreams/api_v2/client_window.py Outdated
Keep the timestamp clock bridge on a dedicated input-source extension.
Measure IUILoop claim and the first following window write.
Remove transport-specific and duplicated stage instrumentation.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
Define WebRTC timing at the existing single-slot sender mailbox write.
Keep active-peer delivery and display timing in matching client telemetry.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
@ZenAlexa

ZenAlexa commented Sep 3, 2026

Copy link
Copy Markdown
Author

Good catch to check this race. input_to_window_write_s deliberately ends at the existing IClientWindow.write return; for WebRTC that is the host's single-slot sender-mailbox write. Active-peer delivery, RTP transit, browser decode, composition, and display live beyond this host-side sample and need client telemetry. _sender_available changes transport queuing behavior; client telemetry supplies the presentation timestamp, so that state stays outside this profiling patch.

…r-input-latency-instrumentation

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>

# Conflicts:
#	flashdreams/flashdreams/runtime_v2/application_runner.py
#	flashdreams/flashdreams/runtime_v2/cli.py
#	flashdreams/flashdreams/runtime_v2/session_runner.py
#	flashdreams/flashdreams/runtime_v2/webrtc_client_window.py
@ZenAlexa

ZenAlexa commented Sep 3, 2026

Copy link
Copy Markdown
Author

Pulled #548's multi-session lifecycle into 5a90e4e9 and followed its new session ownership through the profiler path.

Each replacement now gets a fresh clock binding and an independent JSONL segment, with WebRTC's rebased timestamps mapped back to the correct monotonic session origin. The complete V2 CPU suite passes: 211 passed, 3 deselected. The two metrics remain anchored at IUILoop claim and the first following window write (ง •̀_•́)ง

@ZenAlexa

ZenAlexa commented Sep 3, 2026

Copy link
Copy Markdown
Author

I rechecked this against current HEAD and the PR diff. input_to_window_write_s intentionally ends when the existing IClientWindow.write call returns; for WebRTC that records host-side materialization and mailbox admission, including the existing disconnected-state behavior. Active-peer delivery, RTP transit, decode, composition, and display require client timestamps, so they remain a separate telemetry continuation.

This review keeps the transport contract unchanged and keeps #574 scoped to the two host-side perceived-latency checkpoints (•̀ᴗ•́)و

…r-input-latency-instrumentation

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>

# Conflicts:
#	flashdreams/flashdreams/runtime_v2/session_runner.py
Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
@ZenAlexa

ZenAlexa commented Sep 4, 2026

Copy link
Copy Markdown
Author

Synced current main through #584 in 0e007995 and resolved the new UILoopRequests flow at the profiling boundary. The V2 CPU suite completes with 215 passed / 3 deselected; Ruff, focused ty, compileall, and diff checks pass. The WebRTC endpoint description now follows #579's bounded two-frame sender queue.

Comment thread flashdreams/flashdreams/runtime_v2/runtime_profiler.py
Comment thread flashdreams/flashdreams/runtime_v2/runtime_profiler.py Outdated
Comment thread flashdreams/flashdreams/runtime_v2/runtime_profiler.py Outdated

@jmccaffrey-nv jmccaffrey-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the implementation against #538, including native/WebRTC clock bridging, replacement-session ownership, correlation, cleanup, path collisions, security, and profiler overhead.

The PR satisfies the narrowed host-side checkpoints discussed on the issue: event receipt to IUILoop claim, and event receipt to the next window.write return. The latter is not causal or end-to-end perceived response latency: the UI can re-render a held pre-input frame, and WebRTC stops at host queue admission before transport, decode, composition, and scanout. The documentation states these limits; please keep that distinction explicit when closing #538.

Local validation at 0e007995: 215 V2 CPU tests passed; focused Ruff formatting/import checks, ty, compileall, and git diff --check passed. The documentation build reached the new section without a new warning; its warning-as-error run still reports 10 unrelated baseline warnings. GitHub currently shows only the successful Greptile check while NVIDIA runner validation awaits vetting.

I left three inline comments on self-describing profile metadata, unbounded in-memory summary retention, and stable event-type serialization. I found no new code-execution, deserialization, dependency, or credential-handling exposure.

-- reviewed using GPT-5.6 Sol

@jmccaffrey-nv

Copy link
Copy Markdown
Collaborator

/ok to test 0e00799

…r-input-latency-instrumentation

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
@ZenAlexa

ZenAlexa commented Sep 4, 2026

Copy link
Copy Markdown
Author

Addressed the three review threads in 020fddb4: session segments now include artifact and runtime context; summary quantiles use a bounded 1,024-sample reservoir with explicit approximation metadata; input types use UserInputEvent.get_type_name(). Endpoint docs now cover WebRTC's active-track and no-track write behavior.

Validation: 185 V2 CPU tests passed, 5 skipped in the local optional-dependency environment; 88 focused tests passed, 1 skipped; Ruff, focused ty, compileall, and diff checks passed. Sphinx built all 38 sources with 10 pre-existing warnings; current main reproduces all 10. A 20,000-input JSONL probe completed at a median 6.14 µs per profiled input across three runs, with 1,024 quantile samples retained per metric.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
@ZenAlexa

Copy link
Copy Markdown
Author

I've synced the profiling change with the new model-metrics sink on main.

Both outputs keep their session lifecycle, and replacement sessions retain independent profile segments. I've updated the validation section for the current branch.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
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.

[API] User Input Latency Instrumentation

4 participants