doxa-maps/backend/rudder-engine
Doxa Maps c067a5d069 Dictation fell behind because our own build took every core
Rudder was measured slowing after about 1,400 words while a Tauri build
ran. The word count is incidental — it is a proxy for how long the build had
been going. The speech model runs on the CPU (backend/rudder-engine starts it
with --device cpu), and a Rust build saturates every core, so at equal priority
it starves the one process whose latency a person can hear.

Three changes, and the direction of the first is forced rather than chosen:

1. internal/desktop-build.mjs nices the whole build tree to 10, through the one
   run() helper every step goes through, so cargo, rustc and the linker inherit
   it. We nice the COMPETITOR because an unprivileged process cannot raise its
   own priority on Linux — a negative nice needs CAP_SYS_NICE — so "promote the
   ASR" would fail with EPERM. If nice(1) is missing the build still runs and
   says so, because a silent fallback would look exactly like the fix working.

2. cargo is capped at cores-1. nice decides who wins a CONTESTED core; it does
   not stop the build taking all of them, and a fully subscribed machine still
   adds scheduling latency to the audio path. An explicit CARGO_BUILD_JOBS is
   honoured rather than overridden.

3. yieldCPU reports its error instead of discarding it. It was
   `_ = syscall.Setpriority(...)`, which cannot fail visibly — a call that
   silently does nothing is indistinguishable from one that worked, and this one
   guards something audible.

Also, one real O(n) in the widget, found while checking studio's answer that the
collapsed pill already shows the last words: sendActivity split the ENTIRE draft
on every activity tick to take five words. Measured at 3,000 words: 1.61ms per
tick against 0.051ms for a bounded tail, 31x, with byte-identical output.

Verify the priority work with `ps -o ni=` on the running cargo processes, never
by any of these calls returning.
2026-09-29 05:26:25 +00:00
..
devices.go rudder-engine builds for macOS and Windows, finds its runtime per platform, and accepts the desktop webview's stream 2026-09-28 02:38:49 +00:00
go.mod Add Rudder (rudder-voice): offline streaming voice-to-text, a desktop-target plugin 2026-09-27 08:23:17 +00:00
go.sum Add Rudder (rudder-voice): offline streaming voice-to-text, a desktop-target plugin 2026-09-27 08:23:17 +00:00
main.go Rudder: plain streaming by default; sentence detection only while the robot voice is on 2026-09-28 17:27:13 +00:00
procattr_linux.go Dictation fell behind because our own build took every core 2026-09-29 05:26:25 +00:00
procattr_other.go Rudder keeps streaming on a thin client: reconnect a broken speech stream, say when it falls behind 2026-09-28 15:31:19 +00:00
setup-runtime.sh Rudder: Robot voice — speak each sentence in a synthetic voice, offline, for videos without your real voice 2026-09-28 14:30:56 +00:00
tts.go Rudder: plain streaming by default; sentence detection only while the robot voice is on 2026-09-28 17:27:13 +00:00