Download docs/LATENCY.md from LoveLogicAI/freestream: direct link, hf CLI and curl.
- Browser
- Download file 6.85 kB
-
https://huggingface.co/datasets/LoveLogicAI/freestream/resolve/main/docs/LATENCY.md
- Command line
-
hf download hf://datasets/LoveLogicAI/freestream/docs/LATENCY.md
-
curl -L -o LATENCY.md https://huggingface.co/datasets/LoveLogicAI/freestream/resolve/main/docs/LATENCY.md
LATENCY β benchmarking methods & budget tables
MEASURED β MVP slice, 2026-10-04, cpu-upgrade (8 vCPU cgroup quota, CPU-only)
End-to-end run ml-intern-freestream-e2e-speculative (final: job 6ac2e756404719ba37651973,
two turns, speculative dispatch ON, ASR tiny.en @1 thread, clause-level chunking):
livekit-server v1.13.7 dev mode in-container, bot joined via the real CLI,
test client asked spoken questions, timings measured at the receiving client.
| Metric | Measured | Target | Verdict |
|---|---|---|---|
| t_perceived, turn 1 (speculative + cached disclosure) | 2.94s | β€ 4.0s (win condition) | PASS π₯ |
| t_perceived, turn 2 (speculative, dynamic reply) | 5.79s | β | both turns via speculative path |
| t_perceived, roleplay mode (LLM agent in the loop) | 7.1β7.4s | relaxed (12s) | HF router generation dominates |
| t_ready (CLI join β bot ready, incl. warmup) | 12.5s | β | β |
| ASR finalize (tiny.en int8, 1 thread) | 1.25β1.46s | 400β700ms | over; standalone RTF 0.25 |
| First-chunk synth, turn 2 | 4.09s | 200β400ms | clause-capped (was 7.47s) |
| botβclient transport gap | 0.04s (t1) / 0.45s (t2) | β | negligible |
| cgroup CPU throttling during turns | 0 periods, 0ms | β | contention myth settled |
| Mouth movement | 13/13 checks incl. both turns | >0 | PASS |
| Replay logs | both hash chains verify | valid | PASS |
Findings from the profiling campaign:
- cgroup oversubscription is the #1 CPU pitfall: the container reports
os.cpu_count()=64under an 8-core quota. Whisper tiny at 8 threads measured 39.5s vs 1.16s at 1 thread (same transcript). Thread counts are pinned low (FREESTREAM_WHISPER_THREADS). - The fixed consent disclosure is pre-synthesizable (CONSENT.md #2): caching it at session start removes Piper entirely from the first turn's audio path.
- botβclient transport is nearly free (0.04β0.5s) β measured with absolute cross-process timestamps.
- Speculative dispatch works (concept mitigation #1): dispatching ASR + agent + first-chunk synth at ~300ms of silence (with cancellation on speech resume and dedup against the final event) took turn 1 from 3.12s to 2.94s. Both measured turns completed via the speculative path; the cancellation path is exercised by the segmenter's "resumed" event.
- The contention question is settled: zero cgroup throttling (cpu.stat deltas across turns: 0 periods, 0ms). The in-context vs standalone RTF gap is not quota starvation β it is cold-start effects (page cache, allocator warmup) and benign thread scheduling. The ORT thread-cap countermeasure was not needed (knob FREESTREAM_ORT_THREADS remains for other hosts).
- First-chunk synth length was the real turn-2+ bottleneck: a 99-char first sentence cost 7.47s of synthesis. Clause-level chunking (cap ~60 chars at comma boundaries) cut it to ~4s. Later chunks pipeline behind playback.
- Quantization verdict β asymmetric: int8-dynamic-quantizing the Piper voice (63.2 β 18.7 MB) made TTS 3β4Γ slower (RTF 2.50β2.98 vs 0.79β0.86 fp32): dequant overhead dominates the conv-heavy VITS graph on this CPU (no VNNI). Rejected here; artifact + verdict archived at LoveLogicAI/piper-en_US-amy-medium-int8. ASR was already int8 (CTranslate2) and got faster via English-only tiny.en @1 thread.
- whisper tiny.en vs base accuracy: base transcribed the bot name "Streamy" correctly; tiny.en hears "Streami". The latency profile uses tiny.en; base (+~2s ASR) is the accuracy upgrade path.
Remaining levers, in order of expected yield: (a) the 0.9s of unexplained
utterance-finalization lag beyond the 600ms hangover; (b) in-context ASR/synth
contention (standalone RTF 0.25/0.79 vs in-context ~0.5/1.2) β the render
loop is exonerated, so the suspect is WebRTC encode + thread interference;
(c) the concept's speculative dispatch at ~600ms silence (overlaps agent
response with utterance tail) β the largest structural win for turn-2+,
but a bigger build.
The tables below are the original design targets, kept for reference.
Budget (from the concept package; measured results above)
These are the targets the MVP slice was designed against; the MEASURED section above is the current scorecard against them.
| Stage | Local CPU-only | Local + GPU/ANE | Pika (published) |
|---|---|---|---|
| ASR finalize | 400β700ms | 150β250ms | β |
| Agent first token | 300β900ms | 150β400ms | β |
| TTS first chunk | 200β400ms | 80β150ms | β |
| Avatar render | 500β900ms | 200β350ms | β |
| Perceived turn | ~2.5β4.5s | ~1.2β2.0s | ~1.5s |
The mitigations that make 2.5s feel like 1.5s
- Speculative dispatch at ~600ms of silence β partial ASR transcripts go to the agent before the utterance finalizes; resumed speech cancels the generation. Saves 200β600ms.
- Sentence-level pre-roll β the agent's first sentence starts TTS while later sentences are still generating. Saves one TTS round-trip.
- Lead-out motion β avatar mouth motion starts ~150ms before audio playout, perceptually erasing the render handshake.
- Cached identity β avatar/voice assets are loaded and warmed at session start, never per turn.
Fidelity ladder rungs & FPS targets
| Rung | Name | Target FPS | Host |
|---|---|---|---|
| 4 | FULL_PORTRAIT | 20β24 | GPU / Apple ANE |
| 3 | VISEME_STILL | β₯15 (MVP) | CPU |
| 2 | AUDIO_REACTIVE_WAVE | β₯10 | CPU (weak) |
| 1 | STATIC_CARD | n/a | anything |
Rung selection is select_rung() at join time; runtime degradation
triggers when measured FPS < target for 5 consecutive seconds (event:
persona.rung_change).
Benchmark harness (MVP acceptance)
python benchmarks/turn_latency.py (lands with the MVP slice) measures,
per turn over β₯50 synthetic Q&A turns:
t_asr_final: speech-end β final transcriptt_first_token: transcript β agent first sentencet_tts_chunk: sentence β first audio chunkt_avatar_frame: audio chunk β first frame on the virtual camerat_perceived: speech-end β first audible+visible output
Win condition from the concept: agent joins, answers within 4s with a
moving mouth, leaves, and produces a valid replay log β i.e.
t_perceived p50 < 4.0s on CPU at rung 3, and
EventLog(...).verify() == (True, None).
Reporting rules
- Report p50/p95, machine, and library versions with every number.
- Faster-whisper int8, Piper medium voices; note thread counts.
- If FULL_PORTRAIT can't hold 20 FPS on Apple Silicon, video becomes a cloud-burst feature and rung 3 becomes the local ceiling β that is a finding to report, not a failure to hide.