Skip to content

Commit 1931ca4

Browse files
fix(watcher): reclaim mimalloc pages after in-process fallback reindex
watcher_index_fn routes re-indexing through the supervised subprocess (#832) so the long-lived server hands RSS back to the OS on each cycle. But the in-process degrade fallback — taken when the supervisor is off or the child spawn fails — ran cbm_pipeline_run()+cbm_pipeline_free() without the paired cbm_mem_collect() that every other post-pipeline-run site performs (mcp.c:5758, pipeline.c:834, pass_parallel.c:799/995, graph_buffer.c:1678). Because this fallback is the watcher's unattended path and fires on every poll while the working tree is dirty, the worker-thread pages mimalloc abandons at pool teardown were never returned. RSS ratcheted into tens of GB overnight indexing a small repo (observed: ~55GB private commit on ~200 files, Windows, where the supervised spawn degrades to in-process). Add the collect() to match the established pattern and bound the fallback path's peak. Signed-off-by: Greg Illingworth <g.illingworth86@gmail.com>
1 parent 1c1b6df commit 1931ca4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ static int watcher_index_fn(const char *project_name, const char *root_path, voi
198198

199199
int rc = cbm_pipeline_run(p);
200200
cbm_pipeline_free(p);
201+
cbm_mem_collect(); /* #832: return mimalloc pages to OS after the in-process
202+
* fallback re-index — mirrors the free()+collect() pairing at
203+
* mcp.c:5758/pipeline.c:834. This is the watcher's unattended
204+
* degrade path (supervisor off or spawn failed); without the
205+
* collect, worker-thread pages mimalloc abandons at pool
206+
* teardown are never returned, so RSS ratchets every poll. */
201207
cbm_pipeline_unlock();
202208
return rc;
203209
}

0 commit comments

Comments
 (0)