[codex] Cap concurrent plugin probes per batch#499
Conversation
|
Stack note for maintainers/agents: Recommended #487 merge order:
This PR is based on #490 is separate from this stack and can merge anytime. |
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Caps per-batch plugin probe fan-out by introducing a small worker pool (max 4) and an in-batch queue, reducing CPU/thread/process pressure during background refreshes while preserving the existing probe:result and probe:batch-complete event contract.
Changes:
- Add
MAX_CONCURRENT_PROBESandprobe_worker_count()to bound probe concurrency per batch. - Refactor
start_probe_batchto use a sharedVecDequework queue processed by up to 4spawn_blockingworkers. - Add a unit test (
probe_worker_count_is_bounded) validating the worker cap behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
9f6308f to
7d3442f
Compare
Summary
probe:resultandprobe:batch-completeevent flowWhy
This is another small slice of #487. A batch can include many enabled providers, and the previous implementation spawned one blocking task per plugin immediately. That is simple, but it can create avoidable CPU/thread/process pressure when several plugins do filesystem, network, SQLite, keychain, or helper-process work at the same time.
The new queue keeps provider results asynchronous but limits batch fan-out, so background refreshes have a bounded resource profile.
Notes
The cap is intentionally conservative and local to backend batch execution. It does not change polling intervals, provider enablement, manual refresh behavior, or the frontend event contract.
Validation
bun run bundle:pluginscargo test probe_worker_count_is_boundedbun run buildnode ./node_modules/vitest/vitest.mjs runI also ran full
cargo test; Rust compilation and 96 tests passed, but an existing ccusage process-timeout test fails locally while trying to readdescendant.pidbefore it exists. I did not change that unrelated test in this PR.Part of #487.
Summary by cubic
Cap concurrent plugin probes per batch to 4 to bound CPU and thread usage. Results stay async and
probe:result/probe:batch-completeevents are unchanged.probe_worker_count_is_boundedtest to verify the cap.Written for commit 7d3442f. Summary will update on new commits. Review in cubic