feat(analyzer): surface TTFT/TPOT as features and CDF figures

The gateway records three epoch-ms stamps per request (admitted, forwarded to
backend, backend first token). They reached *-raw.jsonl but stopped there:
features.csv had only total latency, and none of the figures covered
time-to-first-token.

Derive ttft_ms, ttft_e2e_ms and tpot_ms in one helper shared by the streaming
path (preparation.py) and the in-memory path (features.py) so the two cannot
drift, and add figures 14 (TTFT, backend vs end-to-end) and 15 (TPOT). The two
TTFT series are plotted together because their offset is the gateway admission
delay, which is then readable straight off the chart.

Rows missing a backend stamp and single-token responses are recorded as 0 and
filtered at plot time; left in, they would stack at the origin and pull every
percentile down. Figure 15 is a single panel: TPOT is near-deterministic
(p50 21.9, p90 23.0), so a p90 zoom renders a flat line and a vertical edge.

Verified by recomputing ttft_ms straight from the original SLS rows for all
2190 requests of a sample: 0 mismatches.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-11 06:31:48 +00:00
parent 7cb4cac56d
commit 825062f554
8 changed files with 95 additions and 6 deletions

View File

@@ -10,7 +10,7 @@
- `trace_analyzer` 不再直接处理 provider-native 原始日志。
- `details/` 只放画图所需数据。
- `figures/` 只放最终图片。
- 当前主分析入口只维护 13 张图,对应的数据也只保留为这 13 张图服务的最小集合。
- 当前主分析入口只维护 15 张图,对应的数据也只保留为这 15 张图服务的最小集合。
朴素 wall-clock 时间字段如 `time` 按 `UTC+8` 解释。
@@ -113,6 +113,7 @@ outputs/
- `request_metrics.csv`
请求级主表。用于:
- TTFT / TPOT
- input/output length
- session turns / turn 维度请求长度
- trigger role 占比
@@ -131,7 +132,7 @@ outputs/
- `progress.json`
大 trace 运行时的进度与资源占用信息。
### `figures/` 当前只保留的 13 张图
### `figures/` 当前只保留的 15 张图
`figures/` 是展示层,只放图片和轻量说明文件。
@@ -148,6 +149,8 @@ outputs/
11. `11_alive_kvcache_blocks_timeline.png`
12. `12_bucket_kvcache_reuse_ratio.png`
13. `13_session_cross_bucket_kvcache_miss.png`
14. `14_ttft_cdf.png`
15. `15_tpot_cdf.png`
另外还有: