Skip to content

fix(asr): load the call's recognizer from the call's start, so the first lines stop waiting for the helper - #394

Merged
GeiserX merged 6 commits into
mainfrom
fix/live-cold-start-warm
Oct 11, 2026
Merged

GeiserX merged 6 commits into
mainfrom
fix/live-cold-start-warm

Conversation

@GeiserX

@GeiserX GeiserX commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

On a call that starts with the app cold, the first lines of the live transcript could land 1.5 to 5.8 s late (#378). The issue's guess was that the recognizer and the VAD do their first real work on the first utterance.

Measured, the first lines wait for the Parakeet load. The call's decode list builds the recognizer, and nothing is transcribed until it is loaded. The live layer only learned of a call from its first packet, so the load began once the capture helper delivered audio. On the G6 timeline the first mic line closes about 4.7 s into the call. In the eight Mac runs of 2026-10-09 the load ended 1.61 to 8.85 s in, and the three runs with late first lines are three of the four where it ended after 4.4 s. Once the model files are in the page cache, the first decode is as fast as any later one.

The fix

  • The recognizer loads from the call's start. The host begins the call on call.created, in a microtask, so the call's words, written right after it, are in the decode list the load is built for. The load runs while the capture helper starts. In this machine's own log the helper took 0.3 to 4.6 s, 0.48 s at the median over 11 calls, from the call's start to its first part. No model loads before a call, so the idle unload is unchanged. A call whose capture never starts now lets go of the Worker on call.failed, as it does on call.ended, so the idle unload still runs after it.
  • TitaNet loads as the call channel's speech starts. It used to load on the first call line, after its decode, which added 54 to 111 ms to that line.
  • Recognizer loads are timed. With AKOU_LINE_TIMING=1 the Worker logs each load, and scripts/gates/g6-live-latency.ts records them as loads.

Functions touched in src/main/asr/live-worker.ts: LiveAsr.onEvent (begins the call on call.created, and releases it on call.failed), LivePipeline.hot, setDecodeList, warmDictation, window and streamAudio. New: embedderAhead and LOAD_TIMING. Nothing is x64-specific. tests/api.e2e.test.ts pinned part.started as the fourth event. vocab.used can now come first, so the test pins the three events before capture and lets vocab.used land either side of part.started.

Measurements

G6 runs on a Mac mini M4 with 16 GB, with runs of this branch alternating with runs of main plus the load log. Every run started from a cold app with every model file evicted from the page cache first. The setup was otherwise G6's: fp32, beam search, the 12 words, four cold runs per diarizer per side. The machine also ran a VM, a 3 GB language-model server and at times another test run, at a load average of 2.3 to 10.9. G6's file-mode helper starts in about 0.1 s, so two runs per side model the median real helper with a wrapper that waits 0.5 s. The data is in docs/gates/g6-cold-start-mac.json.

Runs Code Load starts, after the part First 10 s, worst After 10 s, worst First call line
Cold, 8 This branch -40 to 3 ms 1.24 to 1.27 s 1.22 to 1.36 s 1.23 to 1.27 s
Cold, 8 main 32 to 37 ms 1.24 to 1.31 s 1.22 to 1.35 s 1.23 to 1.31 s
Helper 0.5 s slower, 2 This branch -518 ms 1.34, 1.36 s 1.29, 1.38 s 1.34, 1.36 s
Helper 0.5 s slower, 2 main 34 to 38 ms 1.42, 1.54 s 1.33, 1.35 s 1.42, 1.43 s
Fresh app, 2 This branch -40 ms 1.50, 1.58 s 1.38, 1.40 s 1.31, 1.36 s
Fresh app, 2 main 33 to 36 ms 1.39, 1.55 s 1.31, 1.32 s 1.34, 1.36 s

In the 16 cold runs both sides pass, because the load, 2.25 to 2.72 s, ends before the first line closes. With the slower helper the load gets its 0.5 s head start and the first lines improve. The fresh-app runs are still late, for a different reason, given below.

Tested

  • [#378] the recognizer loads as the call starts...: with the helper held before capturing, the recognizer is loaded once, for the call's words, and the first audio does not reload it. It fails when the early begin is removed (the load never happens before audio).
  • [#378] a call whose capture never starts lets go of the Worker...: the idle unload still fires after a failed start. It fails without the call.failed case (Expected: 1, Received: 0).
  • [#378] the call channel loads its embedder as speech starts...: red without the change, green with it.
  • [#378] AKOU_LINE_TIMING=1 logs each recognizer load..., with a control that logs nothing when the variable is unset.
  • Full bun run check on a Mac mini: 3202 passed, 34 skipped, 0 failed, within the floor.

What remains (akou-4qj)

  • The first run of a freshly copied app. Its first mic line was 1.50 and 1.58 s with this branch, and 1.39 and 1.55 s on main. The load ends about 3.3 s in, before the line closes. The time goes to the first decodes instead: the two provisional re-decodes before that line took 1.5 to 1.7 s, against about 0.75 s for the three before each later line, so the line's own decode started 0.5 s behind its audio. A decode on silence right after the load would take that one-time cost while the Worker waits for speech, and a load that starts with the call leaves time for it.
  • A load that outlasts the first utterance. A busy machine or a slow disk can still do this. Earlier fresh-copy app runs read 3.63 and 2.02 s. A smaller model for the first lines while fp32 loads would remove that wait.

Tried and left out: reading the recognizer's files through before the load. It shortened a cold load by 0.5 to 1.1 s on one Mac mini, did not shorten it on another, and costs 0.15 s on every warm load.

Refs #378

…cognizer load

A call's first line was embedded only after its decode, and the first embed
loaded TitaNet then: 54 to 111 ms on the first call line of every app run,
against 12 to 15 ms for every later one. The embedder now loads as the call
channel's speech starts, while the segment is still open.

With AKOU_LINE_TIMING=1 the Worker also logs each recognizer load (what asked
for it, when, how long, for how many hotwords), and the G6 live script records
them as `loads`. That is what showed the cause of #378's late first lines: the
call's decode list loads Parakeet when the call's first audio arrives, and on
a busy machine or with the files out of the page cache that load outlasts the
first utterance.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: GeiserX/akou/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3315db98-04ea-4d6c-aec7-2b80cea50fab

📥 Commits

Reviewing files that changed from the base of the PR and between 317980f and c9e2713.


📒 Files selected for processing (6)
  • docs/gates/M0-results.md
  • docs/gates/g6-cold-start-mac.json
  • scripts/gates/g6-live-latency.ts
  • src/main/asr/live-worker.ts
  • tests/api.e2e.test.ts
  • tests/asr-live.test.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

# Conflicts:
#	docs/gates/M0-results.md
#	tests/asr-live.test.ts
…ot on its first audio

The live layer learned of a call from its first packet, so the decode list,
and with it the Parakeet load, waited for the capture helper to start. In this
machine's log the helper took 0.3 to 4.6 s (median 0.48 s) from the call's
start to its first part, and the first lines wait for the load (#378).

The host now begins the call on `call.created`, in a microtask so the call's
words recorded right after it are in the list the load is built for. The load
runs while the helper starts, and the first packet finds it loaded. A call
whose capture never starts fails instead of ending, so `call.failed` now lets
go of the Worker like `call.ended`, and the idle unload still runs.
@GeiserX GeiserX changed the title fix(asr): stop the first call line waiting for TitaNet, and time recognizer loads to explain #378 fix(asr): load the call's recognizer from the call's start, so the first lines stop waiting for the helper Oct 11, 2026
@GeiserX
GeiserX merged commit db62454 into main Oct 11, 2026
47 of 49 checks passed
@GeiserX
GeiserX deleted the fix/live-cold-start-warm branch October 11, 2026 14:30
GeiserX added a commit that referenced this pull request Oct 12, 2026
… window behaves (#400)

The version bump for 1.1.0. The release itself is the `v1.1.0` tag on main once this is merged and `ci-ok` is green there.

## What 1.1.0 ships

The CHANGELOG section in this PR is the release note. In short: the server speaks Wyoming for Home Assistant's Assist (#395) and answers Bazarr's whisper endpoints (#396), both off by default; the desktop window stops scrolling past the app and the note and fix boxes grow with their text (#397); the ask box pre-starts the harness (#393); the recognizer loads from the call's start (#394); on four x64 cores a live line commits 0.4 s sooner (#391); the Docker Hub page is filled from the README (#389, #390); the watchdog test and the nightly stop flaking (#392, #399).

## The evidence a stable release needs (CI-28)

- **The 8-hour soak**, at real time with a busy process on every core, through the Rust helper in file mode, on main at b87ba3b (every change in this release but the UI-only #397): 9 of 9 checks ok, no audio hole, heap growth 0.16 MB, event loop late by at most 186 ms. The JSON is `docs/gates/soak-1.1.0.json`.
- **The terms table** has a row dated 2026-10-12. Both vendors' pages were read again today. Anthropic's pages are unchanged word for word. OpenAI's pages refuse plain fetches and the web archive was offline, so they were read in a browser: same dates, same clauses. The Consumer Terms outside the EEA could not be re-read today, and the row says so.
- `bun scripts/stamp-version.ts --check --tag v1.1.0` exits 0; with `v1.1.1` it exits 1, the control.

## Also in this PR

- The server docs' image tags and the README's DMG name say 1.1.0.
- `docs/DESIGN.md` step 6 states the x64 provisional rule that #391 introduced, which the judge of that PR asked for.

Depends on #399 merging first, since the CHANGELOG names it; I will bring main into this branch once it lands.
GeiserX added a commit that referenced this pull request Oct 13, 2026
…s, which came 6 to 8 s late (#406)

## The problem

A call's first lines can land seconds late after a cold start (#378). Measured on a busy M-series Mac, most of that wait is a model the call never uses.

A default call runs streaming Nemotron with greedy decoding and no second pass. Even so, the Worker loaded Parakeet fp32 on the call's decode list before it handled any audio. That load took 8.1 to 9.8 s here, and the first lines waited behind it. #394 moved the start of the load earlier, which gains about 0.5 s.

## The fix

1. **A streaming call loads no Parakeet it does not decode on.** With a stream engine, no second pass and greedy decoding, the call writes `vocab.used` from the decode list alone through a new `ModelSet.listOnly`. The content is the same as before: no entries, the recognizer's name, and the greedy warning when the list has words. Parakeet loads only if a dictation or a fallback decodes on it during the call.
2. **`asr.warmAtStart`, `off` by default.** `off` loads nothing at start: a call loads its streaming model as it starts. `auto` and `on` exist for a machine where the streaming model loads slowly. `auto` loads the call's streaming model at app start when at least 4 GB of memory is available, and never Parakeet. `on` loads both, whatever the memory. While the load holds the models, the app reads available memory every minute. Under 1.5 GB it lets them go if no call or dictation uses them.
3. **Available memory is read the right way.** On macOS the app reads `kern.memorystatus_level`, and on Linux `MemAvailable`. `os.freemem()` on macOS counts only free pages: 0.19 GB on a 24 GB Mac with 9 GB to give. That is trap T4.38.

**Unchanged: the cold path of a call that decodes on Parakeet.** A call with a second pass loads Parakeet on its decode list as before, whether the pass is Parakeet or Qwen. So does a call under beam search, which checks the words against the loaded model, and a call whose live model is Parakeet. `auto` warms none of these. Their first lines still wait for the Parakeet load, 8 to 10 s on this Mac.

## Measured

An M4 Pro Mac with 24 GB, load average 7 to 35 from other work. The app ran from source with default settings and Nemotron 3.5-560 live. Each run started the app, left it idle 40 s, then played a six-sentence fake call from the G6 clips through `akou-capture` in file mode at real-time speed. No device was opened and nothing was played. Three runs per column, alternating, and every run committed 6 of 6 lines with no clock step.

| | `main` | This PR, `off` | This PR, `auto` |
|---|---|---|---|
| First mic line, speech ending 3.99 s into the call | 6.41 to 8.25 s | 1.34 s | 1.34 s |
| Worst line in the first 10 s | 6.41 to 8.25 s | 1.98 to 1.99 s | 1.98 to 1.99 s |
| Parakeet load during the call | 8.1 to 9.8 s | none | none |
| Load at start | none | none | Nemotron, 0.93 to 1.45 s |
| App footprint, idle before the call | 49 to 50 MB | 48 to 49 MB | 1.56 to 1.92 GB |
| RSS after start | 0.05 to 0.07 GB | 0.07 to 0.09 GB | 1.42 to 1.92 GB in the start log line |

The `off` and `auto` columns match to the millisecond. On this timeline the first speech starts 1 s into the call, and loading Nemotron when the call starts ends before that sentence does. So the warm-up buys no latency here and holds about 1.9 GB while the app sits idle, which is why the default is `off`. It would help only when the first sentence ends within about a second of the call's start, or on a machine where the Nemotron load is slower than here.

## Tests

- `asr-live.test.ts`, "#378: a streaming call loads no recognizer it does not decode on". A default call with a fake stream engine never loads the offline recognizer and still writes `vocab.used`. The controls, a call with a second pass and a call under beam search, load it. A word added mid-call writes a new `vocab.used` with no recognizer.
- `asr-live.test.ts`, "asr.warmAtStart". `auto` loads the stream engine and never Parakeet at 4 GB available, and nothing below it. `off` loads nothing, and `on` loads both with 1 GB. The minute check lets the models go under 1.5 GB and never above, a running call keeps them until it ends, and a call that starts while the load runs on the real Worker loads nothing twice.
- `start-warm.test.ts`. `[T4.38]` checks both memory parsers and this machine's figure against its own source. The app tests cover the default `off` loading nothing with 64 GB available, `on`, `auto` with no stream engine, and `auto` under 4 GB. With the default set back to `auto`, the default test fails.
- `start-warm.test.ts`, "StartWarm on quit". A load that ends after `stop()` holds nothing, arms no memory check, and a later `start()` refuses. Without the stopped check the test fails.
- Positive controls, run by hand. Forcing the old Parakeet load fails the default-call tests. Removing the memory release fails the two release tests. A release that ignores a running call fails the call test.

## Known limitation, in the issue's terms

Suggested wording for #378: "A call that decodes on Parakeet, with a second pass, beam search or Parakeet as its live model, loads it when the call starts, and its first lines can be several seconds late on a busy machine. A default call, on a streaming model, does not wait for it."

Refs #378
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.

1 participant