-
Notifications
You must be signed in to change notification settings - Fork 9
t321: Derive auto-batch concurrency from CPU cores #1265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13079,13 +13079,22 @@ cmd_auto_pickup() { | |
| log_success "Auto-batch: added $added_count tasks to active batch $active_batch_id" | ||
| fi | ||
| else | ||
| # Create a new auto-batch | ||
| # Create a new auto-batch with resource-aware concurrency | ||
| local auto_batch_name | ||
| auto_batch_name="auto-$(date +%Y%m%d-%H%M%S)" | ||
| local task_csv | ||
| task_csv=$(echo "$unbatched_queued" | tr '\n' ',' | sed 's/,$//') | ||
| # Derive base concurrency from CPU cores (cores / 2, min 2) | ||
| # A 10-core Mac gets 5, a 32-core server gets 16, etc. | ||
| # The adaptive scaling in calculate_adaptive_concurrency() then | ||
| # adjusts up/down from this base depending on actual load. | ||
| local auto_cores="$(get_cpu_cores)" | ||
| local auto_base_concurrency=$((auto_cores / 2)) | ||
| if [[ "$auto_base_concurrency" -lt 2 ]]; then | ||
| auto_base_concurrency=2 | ||
| fi | ||
| local auto_batch_id | ||
| auto_batch_id=$(cmd_batch "$auto_batch_name" --concurrency 3 --tasks "$task_csv" 2>/dev/null) | ||
| auto_batch_id=$(cmd_batch "$auto_batch_name" --concurrency "$auto_base_concurrency" --tasks "$task_csv" 2>/dev/null) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if [[ -n "$auto_batch_id" ]]; then | ||
| log_success "Auto-batch: created '$auto_batch_name' ($auto_batch_id) with $picked_up tasks" | ||
| fi | ||
|
|
@@ -14264,10 +14273,13 @@ Cron Integration & Auto-Pickup (t128.5, t296): | |
| 2. Tasks listed under a "## Dispatch Queue" section header | ||
| Both strategies skip tasks already tracked by the supervisor. | ||
|
|
||
| Auto-batching (t296): When new tasks are picked up, they are automatically | ||
| Auto-batching (t296, t321): When new tasks are picked up, they are automatically | ||
| assigned to a batch. If an active batch exists, tasks are added to it. | ||
| Otherwise, a new batch named 'auto-YYYYMMDD-HHMMSS' is created with | ||
| concurrency 3. This ensures all auto-dispatched tasks get batch-level | ||
| base concurrency derived from CPU cores (cores / 2, min 2). A 10-core | ||
| machine gets base 5, a 32-core server gets 16, etc. The adaptive scaling | ||
| then adjusts up/down from this base depending on actual CPU load. | ||
| This ensures all auto-dispatched tasks get batch-level | ||
| concurrency control, completion tracking, and lifecycle management. | ||
|
|
||
| Cron scheduling runs pulse (which includes auto-pickup) every N minutes: | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and to follow the practice of declaring variables at the top of their scope, it's good to group local variable declarations. You can declare
auto_batch_idhere along withauto_coresandauto_base_concurrencyand remove the separate declaration on line 13097.