LoveLogicAI commited on
Commit
b22cea1
Β·
verified Β·
1 Parent(s): 7bc76a5

Profiling campaign results: transport gap, pause-render verdict, clause chunking, remaining levers

Browse files
Files changed (1) hide show
  1. docs/LATENCY.md +45 -36
docs/LATENCY.md CHANGED
@@ -2,58 +2,67 @@
2
 
3
  ## MEASURED β€” MVP slice, 2026-10-04, cpu-upgrade (8 vCPU cgroup quota, CPU-only)
4
 
5
- End-to-end run `ml-intern-freestream-e2e-wincondition` (final: job `6ac2e372404719ba3765176e`,
6
- ASR profile tiny.en @1 thread):
7
  livekit-server v1.13.7 dev mode in-container, bot joined via the real CLI,
8
- test client asked a spoken question, timings measured at the receiving client.
9
 
10
  | Metric | Measured | Target | Verdict |
11
  |---|---|---|---|
12
- | **t_perceived** (speech-end β†’ first bot audio at client) | **3.11s** | ≀ 4.0s (win condition) | **PASS** |
13
- | t_ready (CLI join β†’ bot ready, incl. model + disclosure warmup) | 14.6s | β€” | β€” |
14
- | ASR finalize (whisper tiny.en int8, 1 thread) | 1.33s | 400–700ms | over, halved from 2.04s |
15
- | TTS first-audio path (cached consent disclosure) | ~0.2s (pre-roll + transport) | β€” | PASS |
16
- | Full turn (speech-end β†’ answer finished) | 18.9s (14.9s of audio) | β€” | pipelined |
17
- | Piper in-context RTF (later sentences) | ~0.8–1.2 | <1.0 | borderline |
18
- | Piper standalone RTF (no co-tenants) | 0.55–0.87 | <1.0 | PASS |
19
- | Mouth movement during speech | 234 video frames, median luma diff 0.70 | >0 | PASS |
20
  | Replay logs | both hash chains verify | valid | PASS |
21
 
22
- Findings from the measurement campaign:
23
 
24
  1. **cgroup oversubscription is the #1 CPU pitfall**: the container reports
25
  `os.cpu_count()=64` under an 8-core quota. Whisper tiny at 8 threads
26
- measured **39.5s** vs **1.16s** at 1 thread (same transcript). Pin threads
27
- low; `effective_cpu_count()` in freestream/asr.py reads the cgroup quota.
28
- 2. **The fixed consent disclosure is pre-synthesizable** (CONSENT.md #2): it
29
- is static text, so caching it at session start removes Piper entirely from
30
- the first-audio critical path (mitigation #4 extended).
31
- 3. **Piper runs ~2Γ— slower in the bot process than standalone** (RTF ~0.8–1.2
32
- vs 0.55–0.87) β€” suspected contention with the co-resident whisper model
33
- and render loop. Pipelined sentence synthesis (rest-of-reply synthesizes
34
- while sentence 1 plays, mitigation #2) keeps the turn flowing: 14.9s of
35
- audio completed in 18.9s wall clock. Fixing the contention is the next
36
- performance item.
37
- 4. **whisper tiny.en vs base accuracy**: base transcribed the bot name
38
- "Streamy" correctly; tiny/tiny.en heard "Streami"/"streaming". The latency
39
- profile uses tiny.en (measured best: standalone RTF 0.25 @1 thread vs 0.31
40
- for tiny @2); base (+~2s ASR) is the accuracy upgrade path.
41
- 5. **Quantization verdict β€” asymmetric**: int8-dynamic-quantizing the Piper
 
42
  voice (63.2 β†’ 18.7 MB) made TTS **3–4Γ— slower** (RTF 2.50–2.98 vs 0.79–0.86
43
  fp32): dequant overhead dominates the conv-heavy VITS graph on this CPU
44
- (no VNNI). Rejected for this hardware; artifact + verdict archived at
45
  [LoveLogicAI/piper-en_US-amy-medium-int8](https://huggingface.co/LoveLogicAI/piper-en_US-amy-medium-int8)
46
- for re-testing on VNNI-capable hosts. ASR, in contrast, was **already**
47
- int8 (CTranslate2 compute_type="int8") and got faster by switching to the
48
- English-only tiny.en at 1 thread.
 
 
 
 
 
 
 
 
 
 
49
 
50
  The tables below are the original design targets, kept for reference.
51
 
52
- ## Budget (from the concept package, to be measured β€” not yet achieved)
53
 
54
- These are the *targets* the MVP slice is designed against. Nothing in this
55
- repo has been benchmarked yet; the harness below is how every number gets
56
- produced and re-produced.
57
 
58
  | Stage | Local CPU-only | Local + GPU/ANE | Pika (published) |
59
  |---|---|---|---|
 
2
 
3
  ## MEASURED β€” MVP slice, 2026-10-04, cpu-upgrade (8 vCPU cgroup quota, CPU-only)
4
 
5
+ End-to-end run `ml-intern-freestream-e2e-clausechunks` (final: job `6ac2e57d404719ba376518ab`,
6
+ two turns, ASR tiny.en @1 thread, clause-level chunking):
7
  livekit-server v1.13.7 dev mode in-container, bot joined via the real CLI,
8
+ test client asked spoken questions, timings measured at the receiving client.
9
 
10
  | Metric | Measured | Target | Verdict |
11
  |---|---|---|---|
12
+ | **t_perceived, turn 1** (cached disclosure) | **3.12s** | ≀ 4.0s (win condition) | **PASS** |
13
+ | t_perceived, turn 2 (dynamic reply) | 5.73s | β€” | was 9.32s before clause chunking |
14
+ | t_ready (CLI join β†’ bot ready, incl. warmup) | 12.7s | β€” | β€” |
15
+ | ASR finalize (tiny.en int8, 1 thread) | 1.21–1.31s | 400–700ms | over; standalone RTF 0.25 |
16
+ | First-chunk synth, turn 2 | 3.66s (was 7.47s) | 200–400ms | clause-capped |
17
+ | bot→client transport gap | 0.14s (t1) / 0.48s (t2) | — | negligible |
18
+ | Mouth movement | 13/13 checks incl. both turns | >0 | PASS |
 
19
  | Replay logs | both hash chains verify | valid | PASS |
20
 
21
+ Findings from the profiling campaign:
22
 
23
  1. **cgroup oversubscription is the #1 CPU pitfall**: the container reports
24
  `os.cpu_count()=64` under an 8-core quota. Whisper tiny at 8 threads
25
+ measured **39.5s** vs **1.16s** at 1 thread (same transcript). Thread
26
+ counts are pinned low (FREESTREAM_WHISPER_THREADS).
27
+ 2. **The fixed consent disclosure is pre-synthesizable** (CONSENT.md #2):
28
+ caching it at session start removes Piper entirely from the first turn's
29
+ audio path.
30
+ 3. **botβ†’client transport is nearly free (0.1–0.5s)** β€” measured with
31
+ absolute cross-process timestamps. Earlier estimates of a ~1.6s gap were
32
+ measurement artifacts, not transport cost.
33
+ 4. **Pausing the render loop during ASR does not help** (1.66s vs 1.33s
34
+ unpainted baseline, noise-level difference). The in-context slowdown vs
35
+ standalone RTF is not the render loop; the knob
36
+ (FREESTREAM_PAUSE_RENDER) remains for future profiling.
37
+ 5. **First-chunk synth length was the real turn-2+ bottleneck**: a 99-char
38
+ first sentence cost 7.47s of synthesis. Clause-level chunking (cap ~60
39
+ chars at comma boundaries) cut it to 3.66s and turn-2 t_perceived to
40
+ 5.73s. Later chunks pipeline behind playback.
41
+ 6. **Quantization verdict β€” asymmetric**: int8-dynamic-quantizing the Piper
42
  voice (63.2 β†’ 18.7 MB) made TTS **3–4Γ— slower** (RTF 2.50–2.98 vs 0.79–0.86
43
  fp32): dequant overhead dominates the conv-heavy VITS graph on this CPU
44
+ (no VNNI). Rejected here; artifact + verdict archived at
45
  [LoveLogicAI/piper-en_US-amy-medium-int8](https://huggingface.co/LoveLogicAI/piper-en_US-amy-medium-int8)
46
+ for re-testing on VNNI-capable hosts. ASR was already int8 (CTranslate2)
47
+ and got faster via English-only tiny.en @1 thread.
48
+ 7. **whisper tiny.en vs base accuracy**: base transcribed the bot name
49
+ "Streamy" correctly; tiny.en hears "Streami"/"streaming". The latency
50
+ profile uses tiny.en; base (+~2s ASR) is the accuracy upgrade path.
51
+
52
+ Remaining levers, in order of expected yield: (a) the ~0.9s of unexplained
53
+ utterance-finalization lag beyond the 600ms hangover; (b) in-context ASR/synth
54
+ contention (standalone RTF 0.25/0.79 vs in-context ~0.5/~1.2) β€” the render
55
+ loop is exonerated, so the suspect is WebRTC encode + thread interference;
56
+ (c) the concept's speculative dispatch at ~600ms silence (overlaps agent
57
+ response with utterance tail) β€” the largest structural win for turn-2+,
58
+ but a bigger build.
59
 
60
  The tables below are the original design targets, kept for reference.
61
 
62
+ ## Budget (from the concept package; measured results above)
63
 
64
+ These are the *targets* the MVP slice was designed against; the MEASURED
65
+ section above is the current scorecard against them.
 
66
 
67
  | Stage | Local CPU-only | Local + GPU/ANE | Pika (published) |
68
  |---|---|---|---|