Commit 7ac046f
authored
Add WebSocket round-trip metrics (Time To Last Round Trip and Avg RTT) (#850)
## Summary
Adds two round-trip metrics to the realtime WebSocket backend (`openai_websocket`): **Time To Last Round Trip** and an approximate **Avg RTT**. In streaming transcription, input packets and output tokens flow as separate streams, so the existing token metrics (TTFT, ITL, TPOT) do not capture the send-to-receive lag a user actually experiences. These two estimate that lag from the send and receive timestamps and are reported automatically whenever the WebSocket backend is used. Per the issue discussion, Time To First Round Trip is omitted because it overlaps the existing TTFT, and the names avoid `TTFT`/`TTLT` to prevent collision with the token metrics.
## Details
- `schemas/info.py`: add scalar timing fields to `RequestTimings` (`last_request_sent`, `request_sent_sum`/`request_sent_count`, `token_received_sum`/`token_received_count`). Scalars rather than lists, so they stay correct under `RequestInfo.model_copy` (which shallow-copies timings).
- `backends/openai/websocket.py`: record a timestamp after each outbound frame (`session.update`, audio appends, both commits) via a small `_record_request_sent` helper, and accumulate received content-token timestamps in `_record_content_tokens`.
- `schemas/request_stats.py`: add computed properties `time_to_last_round_trip_ms` (last received token minus last sent packet) and `avg_round_trip_time_ms` (mean received minus mean sent). Both return `None` when no sends were recorded, so non-WebSocket backends are unaffected.
- `benchmark/schemas/metrics.py` and `accumulator.py`: add the two `StatusDistributionSummary` fields, compile them in `GenerativeMetrics.compile()`, and accumulate them for live progress.
- `benchmark/outputs/console.py` and `csv.py`: show both in the request-latency table and the CSV export. JSON/YAML already include them via the schema. The HTML report is left for a follow-up.
- `docs/guides/metrics.md`: document both metrics, noting they are WebSocket-only and that Avg RTT is approximate (it assumes sent packets and received tokens line up evenly in time).
## Test Plan
- `tox -e test-unit` passes, including new tests:
- `tests/unit/backends/openai/test_realtime_ws.py`: the backend records send/receive timestamps (counts, sums, last-sent) over an in-process WebSocket stub.
- `tests/unit/schemas/test_request_stats.py`: the two properties compute correctly and return `None` without send timings.
- `tests/unit/benchmark/schemas/test_metrics.py`: the metrics expose schema fields and compile into distributions.
- `tox -e lint-check` and `tox -e type-check` pass.
- Manual check on CPU (no GPU): drove `OpenAIWebSocketBackend.resolve()` against a fake realtime server with ~100 ms simulated per-token lag. Time To Last Round Trip came out around 300 ms and Avg RTT around 200 ms (matching the lag), and both were `None` for a non-WebSocket request. For a live run, point a benchmark at a vLLM realtime server (e.g. Voxtral) and confirm both metrics appear in the console latency table and `benchmarks.json`.
## Related Issues
- Resolves #832
---
- [x] "I certify that all code in this PR is my own, except as noted below."
## Use of AI
- [x] Includes code generated or substantially modified by an AI agent
- [x] Includes tests generated or substantially modified by an AI agent
> NOTE: the `Generated-by` or `Assisted-by` trailers should be used in git commit messages when code or tests were generated or substantially modified by an AI agent, as described in the project's [`DEVELOPING.md`](https://github.com/vllm-project/guidellm/blob/main/DEVELOPING.md) file.
---
# git log
commit 457d56e
Author: Suraj Singh <[email protected]>
Date: Wed Jun 24 15:00:52 2026 -0700
test(openai): add failing websocket round-trip metric tests (#832)
Add RED unit tests for Time To Last Round Trip and Avg RTT on the openai_websocket backend (send/receive timestamp recording, computed properties, None-gating, and metric compile). They fail until the implementation lands.
Assisted-by: Claude Code
Signed-off-by: Suraj Singh <[email protected]>
commit 81a0aee
Author: Suraj Singh <[email protected]>
Date: Wed Jun 24 15:00:52 2026 -0700
feat(openai): record websocket send/receive timestamps (#832)
Add scalar round-trip timing fields to RequestTimings and record per-frame sent timestamps and received content-token timestamps in the openai_websocket backend. These feed the Time To Last Round Trip and Avg RTT metrics; HTTP backends leave them unset.
Assisted-by: Claude Code
Signed-off-by: Suraj Singh <[email protected]>
commit 94f941c
Author: Suraj Singh <[email protected]>
Date: Wed Jun 24 15:00:52 2026 -0700
feat(benchmark): compute and aggregate websocket round-trip metrics (#832)
Add time_to_last_round_trip_ms and avg_round_trip_time_ms as computed request stats (None unless send timings exist), aggregate them in GenerativeMetrics.compile(), and accumulate them for live progress. Avg RTT is an approximation of the mean send-to-receive lag.
Assisted-by: Claude Code
Signed-off-by: Suraj Singh <[email protected]>
commit c5efcaf
Author: Suraj Singh <[email protected]>
Date: Wed Jun 24 15:00:52 2026 -0700
feat(benchmark): show websocket round-trip metrics in console and CSV (#832)
Surface Time To Last Round Trip and Avg RTT in the request latency console table and the CSV export. JSON/YAML already include them via the schema; the HTML report is left for a follow-up.
Assisted-by: Claude Code
Signed-off-by: Suraj Singh <[email protected]>
commit da70077
Author: Suraj Singh <[email protected]>
Date: Wed Jun 24 15:00:53 2026 -0700
docs(metrics): document websocket round-trip metrics (#832)
Describe Time To Last Round Trip and Avg RTT in the metrics guide, noting they are websocket-only and that Avg RTT is an approximation.
Assisted-by: Claude Code
Signed-off-by: Suraj Singh <[email protected]>
commit ee76dd2
Author: Suraj Singh <[email protected]>
Date: Tue Aug 11 09:59:50 2026 -0700
fix(outputs): hide realtime-only metrics from console
Signed-off-by: Suraj Singh <[email protected]>
---------
Assisted-by: Claude Code
Signed-off-by: Suraj Singh <[email protected]>1 parent d3a6da9 commit 7ac046f
11 files changed
Lines changed: 400 additions & 3 deletions
File tree
- docs/guides
- src/guidellm
- backends/openai
- benchmark
- outputs
- schemas
- schemas
- tests/unit
- backends/openai
- benchmark/schemas
- schemas
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| |||
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
95 | 110 | | |
96 | 111 | | |
97 | 112 | | |
| |||
377 | 392 | | |
378 | 393 | | |
379 | 394 | | |
380 | | - | |
381 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
382 | 398 | | |
383 | 399 | | |
384 | 400 | | |
| |||
454 | 470 | | |
455 | 471 | | |
456 | 472 | | |
| 473 | + | |
457 | 474 | | |
458 | 475 | | |
459 | 476 | | |
460 | 477 | | |
461 | 478 | | |
462 | 479 | | |
| 480 | + | |
463 | 481 | | |
464 | 482 | | |
465 | 483 | | |
| 484 | + | |
466 | 485 | | |
467 | 486 | | |
468 | 487 | | |
| 488 | + | |
469 | 489 | | |
470 | 490 | | |
471 | 491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
484 | 483 | | |
485 | 484 | | |
486 | 485 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
458 | 472 | | |
459 | 473 | | |
460 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
498 | 506 | | |
499 | 507 | | |
500 | 508 | | |
| |||
539 | 547 | | |
540 | 548 | | |
541 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
542 | 556 | | |
543 | 557 | | |
544 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
813 | 813 | | |
814 | 814 | | |
815 | 815 | | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
816 | 828 | | |
817 | 829 | | |
818 | 830 | | |
| |||
939 | 951 | | |
940 | 952 | | |
941 | 953 | | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
942 | 966 | | |
943 | 967 | | |
944 | 968 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
81 | 110 | | |
82 | 111 | | |
83 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
173 | 212 | | |
174 | 213 | | |
175 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
0 commit comments