Skip to content

fix(indexer): keep every concurrency slot busy with a worker pool (#204) - #210

Open
MikeBishop wants to merge 1 commit into
obra:mainfrom
MikeBishop:fix/indexer-worker-pool
Open

MikeBishop wants to merge 1 commit into
obra:mainfrom
MikeBishop:fix/indexer-worker-pool

Conversation

@MikeBishop

@MikeBishop MikeBishop commented Nov 8, 2026 •

Copy link
Copy Markdown

Summary

index --cleanup --concurrency N doesn't keep N summarizations running. processBatch() in src/indexer.ts runs fixed batches: it takes N items, awaits Promise.all, and only then starts the next N. One slow item idles the other N−1 slots until it finishes.

In a real backfill with --concurrency 8, one long conversation (hierarchical summary, chunks summarized one after another) held the run at a single summarizer subprocess from 17:12 until about 17:58. The first 5 minutes had produced 39 summaries; that stretch produced none. Details in #204.

Fix

Replace the fixed batches with a worker pool: N workers each pull the next item as soon as their current one finishes.

dist/ is regenerated with npm run build. dist/mcp-server.js doesn't bundle the indexer and isn't included.

This covers part 1 of the proposal in #204, which gets most of the benefit: a long conversation now ties up one slot while the others keep working through the queue. Part 2, running its chunks through the same limit, would only help once it's the last item left, so I've left it out for now.

Test plan

Refs #204.


Drafted with AI assistance (Claude Code). I reviewed the change; the timings are from my own backfill run.

🤖 Generated with Claude Code

…ra#204)

processBatch() ran fixed batches: slice `concurrency` items, await
Promise.all, then start the next slice. One slow item left the other
slots idle until it finished. In a real `index --cleanup --concurrency 8`
backfill, one long conversation (hierarchical summary, chunks run one
after another) held the whole run at a single summarizer subprocess for
over 20 minutes.

Replace it with a worker pool: `concurrency` workers each pull the next
item when their current one finishes. Peak concurrency is unchanged, so
the bound on live summarizer subprocesses from obra#61 still holds. Results
stay in input order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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