1892: feat: allow an external semaphore for executor task concurrency - #80
1892: feat: allow an external semaphore for executor task concurrency#80martin-augment wants to merge 3 commits into
Conversation
Adds an optional available_task_slots: Option<Arc<Semaphore>> parameter to the executor poll_loop. When provided, the caller supplies the semaphore that bounds concurrent task execution; this enables sharing it across poll loops connected to different schedulers and observing executor busy state via available_permits(). When None, the loop creates one internally sized to the executor's task slots (unchanged behavior). Ported from spiceai#14 for upstreaming. Note: layers on the poll_loop signature; if landed after #12 (poll_now_notify) it needs a trivial rebase to add both parameters.
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces an optional available_task_slots semaphore parameter to the poll_loop function in the Ballista executor, allowing callers to share or monitor task concurrency limits. Call sites in executor_process.rs, standalone.rs, and mtls-cluster.rs have been updated to pass None by default. Additionally, AI agent rules and configuration files (.cursor/rules.md, AGENTS.md, and CLAUDE.md) were added. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
🤖 Augment PR SummarySummary: This PR extends the executor pull-based polling loop to optionally use a caller-provided semaphore for task concurrency. Changes:
Technical Notes: This enables sharing/observing task-slot permits externally (e.g., for cross-loop coordination or busy-state visibility). 🤖 Was this summary useful? React with 👍 or 👎 |
| mut scheduler: SchedulerGrpcClient<C>, | ||
| executor: Arc<Executor>, | ||
| codec: BallistaCodec<T, U>, | ||
| available_task_slots: Option<Arc<Semaphore>>, |
There was a problem hiding this comment.
ballista/executor/src/execution_loop.rs:69 — Now that available_task_slots can be provided externally, the later acquire().await.unwrap() / acquire_owned().await.unwrap() calls can panic if the semaphore is closed by the caller. Consider handling AcquireError and exiting (or retrying) gracefully to avoid crashing the executor.
Severity: medium
Other Locations
ballista/executor/src/execution_loop.rs:97ballista/executor/src/execution_loop.rs:144
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| /// ensuring no more than the configured number of tasks run simultaneously. | ||
| /// | ||
| /// `available_task_slots`, when provided, lets the caller supply the semaphore | ||
| /// controlling task concurrency (e.g. to share it across poll loops or to |
There was a problem hiding this comment.
ballista/executor/src/execution_loop.rs:62 — The docs mention sharing this semaphore "across poll loops"; if multiple loops run concurrently, each loop will independently report num_free_slots based on available_permits(), which can lead to the scheduler over-assigning tasks relative to real capacity. It may be worth clarifying in the doc comment what coordination is expected to avoid double-counting free slots.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Code ReviewThis PR adds an Findings (most severe first)
The At minimum, add a debug assertion or return an error if the supplied semaphore's initial permits differ from
Both // line 97
let permit = available_task_slots.acquire().await
.map_err(|_| BallistaError::Internal("task slot semaphore closed".into()))?;
// line 144
let permit = available_task_slots.clone().acquire_owned().await
.map_err(|_| BallistaError::Internal("task slot semaphore closed".into()))?;
If a caller passes assert!(available_task_slots.available_permits() > 0 || ..., "semaphore must have > 0 permits");Minor cleanup
let slots = Arc::clone(&available_task_slots);
// ... inside loop:
let permit = Arc::clone(&slots).acquire_owned().await ...; |
1892: To review by AI