perf: shrink index allocations after scan — reduce steady-state RSS (#261)#262
Merged
justrach merged 1 commit intorelease/v0.2.57from Apr 13, 2026
Merged
perf: shrink index allocations after scan — reduce steady-state RSS (#261)#262justrach merged 1 commit intorelease/v0.2.57from
justrach merged 1 commit intorelease/v0.2.57from
Conversation
Add shrinkPostingLists() to TrigramIndex and shrinkAllocations() to WordIndex. Both release ArrayList over-allocation (capacity > length) after initial scan completes. This reduces steady-state RSS for long-running MCP servers by reclaiming ~50% of ArrayList capacity waste. Note: peak RSS during cold indexing is unchanged — the shrink runs after the peak. The peak is dominated by GPA page retention from alloc/free churn during indexing. Further reduction would require a custom allocator or pre-sized flat storage. Benchmark (openclaw, 13,867 files): Peak RSS unchanged (3,415MB) — expected, shrink runs after peak Recall: 52/52 for 'handleRequest' — no false negatives An earlier cap approach (MAX_POSTINGS=512) saved 243MB peak but dropped recall to 2/52 — reverted in favor of shrink-only Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Benchmark Regression ReportThreshold: 10.00%
|
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
Add
shrinkPostingLists()to TrigramIndex andshrinkAllocations()to WordIndex. Both release ArrayList over-allocation after initial scan completes, reducing steady-state RSS for long-running MCP servers.What was tried
Peak RSS during cold indexing is unchanged (3,415MB). The peak is dominated by GPA page retention from alloc/free churn during indexing — the shrink runs after the peak. Further peak reduction needs a custom allocator or pre-sized flat storage (tracked in #261).
Test plan
handleRequeston openclaw — no false negatives🤖 Generated with Claude Code