Repository navigation
fix(memory): the stress dictionary loads on first use instead of at every boot - #965
Merged
Merged
Conversation
…ead of at every boot (Refs #800, #963) Production parsed data/dictionaries/stress-dict.json at every start although it never speaks Russian through Silero (SILERO_PYTHON_PATH unset) and the MTProto service tier is off: in a bare bun process that file takes RSS from 51 MB to 362 MB at the peak and leaves 190 MB, on a container that shares an overcommitted, swapping 3.7 GB odroid. StressDictionary.lazyFromFile registers the file and ensureLoaded() reads it once, shared by concurrent callers; lookup_stress, the voice reply, the settings voice route and the voice-call TTS await it before marking stress, and an unloaded dictionary throws instead of reporting every word unknown. With SILERO_PYTHON_PATH set the file is read at startup as before, so an unreadable file keeps Silero off. The runbook records the measured steady state of the container (flat at 449-461 MiB, not a leak, same module-load footprint on ff93220 and e4185dd). Review: single-seat Opus via omp (two rounds; round 1 found the Silero request-time stall, the unstressed-Silero case, a stale README and a missing Silero-path test, all fixed; round 2 none). This is a single-seat review: the full-roster pass is owed in #961.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The bot used to parse the 555,461-entry Russian stress dictionary (
data/dictionaries/stress-dict.json, 27 MB) at every start. Production never speaks Russian through Silero (SILERO_PYTHON_PATHis unset) and the MTProto service tier is off, so the only reader there is thelookup_stressAI tool. In a bare bun process that parse takes RSS from 51 MB to 362 MB at the peak and leaves 190 MB, on a 1 GiB container that shares an overcommitted, swapping 3.7 GB odroid.Now
StressDictionary.lazyFromFileregisters the file andensureLoaded()reads it once (concurrent callers share one load).lookup_stress, the voice reply, the settings voice route and the voice-call TTS await it before marking stress; an unloaded dictionary throws instead of reporting every word unknown. WithSILERO_PYTHON_PATHset the file is still read at startup, so an unreadable file keeps Silero off as before. A missing file leaves the dictionary absent at startup, as before.The runbook (Deploy, resource limits) now records what was measured about the container's memory: a fresh container is flat at 449-461 MiB over 16 minutes, the module-load footprint is identical on ff93220 and e4185dd, and the 138-163 MiB seen on the old container was the host swapping its idle part out.
Refs #800, #963
Evidence
test/services/voice/stress-dictionary.test.ts16 pass,test/bootstrap/speech-stress-dictionary.test.ts4,test/services/ai/lookup-stress.test.ts3,test/bootstrap/voice-calls.test.ts8,test/bot/handlers/message-handler-units.test.ts20,test/bot/handlers/voice-prompt.test.ts11.biome checkonsrcandtest: clean.Review
Single-seat Opus via omp (
review diff --staged --task 963 --pool 1 -m omp:anthropic/claude-opus-5-5), two rounds. Round 1 found a request-time load stall when Silero is configured, an unstressed-Silero case when the file cannot be parsed, a stale README and a missing Silero-path test: all fixed. Round 2 found no actionable bug. The version was moved from 0.3.5 to 0.3.4 after round 2 (two lines, accepted by the commit gate's trivial-delta rule). This is a single-seat review; the full-roster pass is owed in #961.