Skip to content

Make DrainableWorker keyed by thread#1955

Closed
ashvinnihalani wants to merge 1 commit intopingdotgg:mainfrom
ashvinnihalani:fix/drainable-worker-thread-keyed
Closed

Make DrainableWorker keyed by thread#1955
ashvinnihalani wants to merge 1 commit intopingdotgg:mainfrom
ashvinnihalani:fix/drainable-worker-thread-keyed

Conversation

@ashvinnihalani
Copy link
Copy Markdown
Contributor

@ashvinnihalani ashvinnihalani commented Apr 12, 2026

Summary

  • make DrainableWorker process items serially per thread key while allowing different keys to run concurrently
  • update the provider command, runtime ingestion, and checkpoint reactors to enqueue work by threadId
  • remove drainKey from DrainableWorker, document that we do not support per-key draining yet, and add regression coverage for blocked-thread isolation

Testing

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test -- src/DrainableWorker.test.ts
  • bun run test -- src/orchestration/Layers/ProviderCommandReactor.test.ts

Note

Key DrainableWorker by thread to allow concurrent cross-thread processing

  • Rewrites DrainableWorker from a single-queue design to a per-key design using TxRef-managed state, where each key gets its own serial queue but different keys run concurrently.
  • Updates enqueue to accept (key, item) and the process function to receive (key, item); drain now waits for all keys' work to complete.
  • Updates CheckpointReactor, ProviderCommandReactor, and ProviderRuntimeIngestion to enqueue with threadId as the key.
  • Behavioral Change: enqueue now requires a key argument at all call sites; work for different threads proceeds concurrently while preserving per-thread ordering.

Macroscope summarized 343bd81.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d702dca7-9ee0-4b9a-8d3a-719865e4e8d0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant