Repository navigation
fix(server): bound native heap retention in the shared daemon - #48
Merged
Merged
Conversation
The shared daemon reached 33 GiB RSS plus 27 GiB swap after 58 hours with no active jobs and an empty symbol cache. Allocator evidence places the memory in glibc malloc arenas: freed LanceDB scan memory stays in fragmented per-thread arenas, while the Python heap, the Arrow pool, and the Lance caches stay small. Each owner connection also got its own default Lance session (6 GiB index + 1 GiB metadata cap). - Cap glibc malloc arenas at 4 in run_server before threads start. - RuntimeSupervisor trims free heap (malloc_trim) on a timer thread after the last active job finishes, at most every 30 seconds. - Every chunk-store connection shares one Lance session bounded at 256 MiB index + 256 MiB metadata cache. - lgrep_diagnostics adds process_memory (RSS, swap, Lance cache bytes and limits, arena cap, trim count), separate from symbol_cache. A bounded probe over three live caches through ChunkStore and RuntimeSupervisor held idle RSS at 697-792 MiB over 10 cycles; the baseline climbed from 1778 to 2482 MiB. All hooks are no-ops off glibc. Refs LGREP-56
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.
Problem
After 58 hours with no active jobs, the shared lgrep daemon (Vision child) held 33 GiB RSS plus 27 GiB swap, almost all of it anonymous private dirty memory.
lgrep_diagnosticscould not explain it: the symbol cache reported 0 bytes and all 8 owner stores were idle. This takes most of the host's swap away from concurrent agent work. Tracked in LGREP-56.Cause (allocator evidence)
malloc_trimran.Change
run_servercaps glibc malloc arenas at 4 before any worker or LanceDB thread starts.RuntimeSupervisortrims free heap on a timer thread after the last active job finishes, at most once every 30 seconds. The trim never runs on the event loop or a worker thread.lgrep_diagnostics.process_memoryreports RSS, swap, Lance cache bytes and limits, the arena cap, and the trim count, separately fromsymbol_cache.docs/operations.mddescribes both.Evidence
pytest: 1237 passed, 1 xfailed.ruff checkandruff format --checkare clean.ChunkStoreandRuntimeSupervisorover three live caches, 10 cycles, sampled while idle. With the fix, RSS stayed at 697–792 MiB with no upward trend. The baseline (default sessions, no cap, no trim) climbed from 1778 to 2482 MiB. Searches kept returning results throughout.Not in scope