Skip to content

perf: page_allocator for worker arenas + eager free + index shrink (#261)#263

Merged
justrach merged 1 commit intorelease/v0.2.57from
perf/261-trigram-rss
Apr 13, 2026
Merged

perf: page_allocator for worker arenas + eager free + index shrink (#261)#263
justrach merged 1 commit intorelease/v0.2.57from
perf/261-trigram-rss

Conversation

@justrach
Copy link
Copy Markdown
Owner

Summary

Three optimizations to reduce RSS during and after cold indexing:

  1. page_allocator for worker arenas — mmap pages returned to OS immediately on arena deinit, no GPA page retention
  2. Eager worker free — each worker's arena is freed right after committing its results, instead of holding all workers' data simultaneously
  3. Index shrink after scanshrinkPostingLists() and shrinkAllocations() release ArrayList over-allocation on trigram and word indexes

Benchmark (openclaw, 13,867 files, cold search)

Version Time Peak RSS Delta vs baseline
v0.2.56 baseline 5.82s 3,678MB
PR#260 (content limit) 5.26s 3,415MB -7.2%
This PR 5.64s 3,361MB -8.6%

Recall: 52/52 for handleRequest — no false negatives.

The remaining ~3.3GB is genuinely live index data. Further reduction tracked in #261 (needs flat array storage or compressed postings).

Test plan

  • All tests pass
  • Benchmarked on openclaw — 3,361MB, recall intact
  • No double-free (workers_committed counter guards error path)

🤖 Generated with Claude Code

Three changes to reduce RSS:

1. Back worker arenas with page_allocator instead of GPA — mmap pages
   are returned to OS immediately on arena deinit (no GPA retention)
2. Free each worker's arena right after committing its results instead
   of holding all workers' data simultaneously
3. shrinkPostingLists/shrinkAllocations on trigram + word indexes after
   scan to release ArrayList over-allocation

Benchmark (openclaw, 13,867 files, cold search):
  v0.2.56 baseline:    3,678MB  5.82s
  PR#260 (content):    3,415MB  5.26s
  This PR:             3,361MB  5.64s  (-8.6% RSS vs baseline)
  Recall: 52/52 — no false negatives

The remaining ~3.3GB is genuinely live index data (trigram posting
lists + word index hits). Further reduction needs flat array storage
or compressed postings (tracked in #261).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@justrach justrach merged commit a3d9a57 into release/v0.2.57 Apr 13, 2026
@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Threshold: 10.00%

Tool Base (ns) Head (ns) Delta Status
codedb_bundle 653278 645572 -1.18% OK
codedb_changes 110001 109176 -0.75% OK
codedb_deps 32340 29217 -9.66% OK
codedb_edit 22746 22985 +1.05% OK
codedb_find 138290 137955 -0.24% OK
codedb_hot 148822 159364 +7.08% OK
codedb_outline 434911 427056 -1.81% OK
codedb_read 141379 142284 +0.64% OK
codedb_search 283303 277201 -2.15% OK
codedb_snapshot 4491934 4504874 +0.29% OK
codedb_status 256941 253820 -1.21% OK
codedb_symbol 64174 62995 -1.84% OK
codedb_tree 92745 92981 +0.25% OK
codedb_word 90329 91068 +0.82% OK

justrach added a commit that referenced this pull request Apr 13, 2026
perf: page_allocator for worker arenas + eager free + index shrink (#261)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant