Skip to content

Add concurrent job queue support#10

Open
hannahsmith-rh wants to merge 2 commits into
mainfrom
concurrent-job-queue
Open

Add concurrent job queue support#10
hannahsmith-rh wants to merge 2 commits into
mainfrom
concurrent-job-queue

Conversation

@hannahsmith-rh

Copy link
Copy Markdown
Collaborator

Summary

  • The job queue now runs up to MAX_CONCURRENT_JOBS (default 3) benchmark jobs in parallel instead of one at a time
  • Uses an asyncio.Semaphore to gate concurrent jobs, with an env var to tune the limit
  • Allows running benchmarks for multiple models simultaneously when each targets a different vLLM endpoint on separate Brev instances

Changes

  • Replaced single _active_job tuple with _active_jobs dict keyed by job_id
  • Worker dispatches jobs via asyncio.create_task() instead of await, so it doesn't block on one job
  • Semaphore limits how many jobs actually run on OpenShift at once
  • Cancel and shutdown logic updated to handle multiple active jobs
  • Handles cancellation both during semaphore wait and during job execution

Related

Depends on taagarwa-rh/harbor#1 — adds resource requests to Harbor's OpenShift build pods so the scheduler spreads them across nodes instead of stacking them on one. Without that fix, running multiple concurrent jobs could cause disk pressure from accumulated build images. With both changes together, 2-3 parallel benchmark jobs should run safely.

Test plan

  • Deploy to OpenShift and submit 2-3 jobs with different server_url values
  • Confirm multiple jobs show as "running" simultaneously in /ui
  • Cancel one job, confirm the others continue
  • Verify completed jobs upload results to MinIO correctly
  • Monitor for disk pressure (oc get events --field-selector reason=Evicted)

cc @taagarwa-rh @rounakbende10

The job queue now runs up to MAX_CONCURRENT_JOBS (default 3)
benchmark jobs in parallel instead of one at a time. This allows
running benchmarks for multiple models simultaneously when each
targets a different vLLM endpoint on separate Brev instances.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hannahsmith-rh, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 6e95c191-811f-4e44-a684-2af928f538cd

📥 Commits

Reviewing files that changed from the base of the PR and between 4ae448b and 5f5fe45.

📒 Files selected for processing (1)
  • src/coding_agent_bench/api.py
📝 Walkthrough

Walkthrough

Changes

Concurrent job execution

Layer / File(s) Summary
Bounded multi-job execution
src/coding_agent_bench/api.py
Job tasks are tracked per ID, launched asynchronously by the worker, and limited by the configured semaphore.
Shutdown and targeted cancellation
src/coding_agent_bench/api.py
Shutdown cancels all active jobs, while deletion cancels only the requested job task.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: taagarwa-rh

Sequence Diagram(s)

sequenceDiagram
  participant JobWorker
  participant asyncio.create_task
  participant _run_job
  participant _job_semaphore
  participant _active_jobs
  JobWorker->>asyncio.create_task: Spawn _run_job for queued job
  asyncio.create_task->>_run_job: Start job task
  _run_job->>_active_jobs: Register job_id task
  _run_job->>_job_semaphore: Acquire execution slot
  _job_semaphore-->>_run_job: Permit bounded execution
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding concurrent job queue support.
Description check ✅ Passed The description is clearly aligned with the concurrent job queue and cancellation changes in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch concurrent-job-queue

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/coding_agent_bench/api.py`:
- Around line 29-30: Update the MAX_CONCURRENT_JOBS initialization and
_job_semaphore setup to parse the environment value with a clear configuration
error for non-integer input, and reject values below 1 before creating the
semaphore. Ensure invalid settings fail explicitly at startup rather than
causing runtime blocking or an unhandled conversion error.
- Around line 293-300: Update the _shutting_down branch of the
asyncio.CancelledError handler to invoke job cleanup with signal=True, ensuring
shutdown cleanup signals the job pod and does not leave child task pods
orphaned. Preserve the existing error construction, status update, and
cancellation propagation.
- Line 333: Update the job-draining logic around _run_job so it does not create
one asyncio Task for every queued job before capacity is available. Use a
bounded worker-pool pattern or acquire a concurrency slot before spawning each
task, and ensure _active_jobs registration and shutdown cancellation remain
consistent for jobs still waiting in the backlog.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 64bc4fb7-05b7-428b-ab65-22e5dd34c037

📥 Commits

Reviewing files that changed from the base of the PR and between ed649ed and 4ae448b.

📒 Files selected for processing (1)
  • src/coding_agent_bench/api.py

Comment thread src/coding_agent_bench/api.py Outdated
Comment thread src/coding_agent_bench/api.py
Comment thread src/coding_agent_bench/api.py Outdated
- Validate MAX_CONCURRENT_JOBS env var at startup (reject non-int and < 1)
- Pass signal=True during shutdown cleanup to avoid orphaned task pods
- Track background tasks in a set to prevent GC and satisfy RUF006
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