fix(daemon): reduce memory footprint, fix LLM crash, fix DB lock contention#83
Merged
Conversation
ashu17706
force-pushed
the
fix/daemon-footprint-and-locking
branch
from
July 25, 2026 03:29
e7bdb53 to
1375369
Compare
…ze flushes, and add busy_timeout
… commit in range run()'s .trim() stripped the trailing %x09 of the oldest commit in a range whenever that commit had an empty body, dropping it below the 3-field threshold in parseCommit() and silently excluding it from commit_count/release notes. Confirmed this already affected v0.8.1's published notes (missing fix(ci): scope test runs to smriti suite). getCommits() now only strips trailing newlines, not the whole output.
ashu17706
force-pushed
the
fix/daemon-footprint-and-locking
branch
from
July 25, 2026 03:35
1375369 to
e49a798
Compare
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.
Summary
LlamaCpp/Llamabackend on every ingest flush (never disposed), causing multi-GB RSS spikes and a recurringLlamaGrammar ... different Llama instancecrash (~404 occurrences observed in a 24-day-old daemon.log, roughly 1 in 8 flushes) traced to the fire-and-forgetexpandQuery()auto-enrich call racing across overlapping flush cycles.closeDb()/closeQmdStore()now explicitly dispose the LLM backend on close instead of leaving it to the 5-min inactivity timer; the daemon now defaultsSMRITI_INGEST_NO_ENRICH=1so routine ingest never triggers LLM work as a side effect (opt back in viaenrichOnIngest: true); daemon flushes are now serialized (verified: overlapping construct/dispose of LlamaCpp/Llama instances can abort the process with a nativeGGML_ASSERTinggml-metal, since the shared_db/_storesingletons were never safe to touch concurrently).PRAGMA busy_timeout=5000— reproduced a realdatabase is lockedfailure between the daemon and a manualsmriti ingest --forcewriting to the same SQLite file at once; this makes concurrent writers retry briefly instead of failing instantly.scripts/monitor-resources.ts(resource-usage sampler used to verify all of the above) had its own bug:child.exitedwas observed to never resolve even after the spawned process had fully exited, hanging the wrapper indefinitely. Fixed with an independent pid-liveness watchdog raced against the real exit promise.Verification
test/daemon-runner.test.ts(enrich env var default + override) and a newtest/store.test.ts(LLM dispose behavior).LlamaGrammarerrors post-fix (previously ~1 in 8 flushes).database is lockederrors, versus one reproduced pre-fix.Test plan
bun test --cwd ./test— 373 pass, 0 failLlamaGrammarerrors indaemon.logsmriti ingest claude --forcewhile daemon runs concurrently, confirm nodatabase is lockederrorsbun run monitor exec -- <cmd>completes and exits cleanly instead of hanging