Fix tag-based concurrency batching delay#21156
Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Open
Fix tag-based concurrency batching delay#21156devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Conversation
- Lower tag_concurrency_slot_wait_seconds default from 30s to 10s to match nebula/Cloud behavior and reduce batch wait times - Use avg_slot_occupancy_seconds from the most contended V2 limit in server-side delay_transition (capped at max_wait) instead of a fixed delay, so tasks retry proportional to actual slot turnover rather than all waking up simultaneously after a fixed interval Closes OSS-7078 Co-Authored-By: alex.s <[email protected]>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: alex.s <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses a performance issue where tag-based concurrency limits cause tasks to execute in discrete batches instead of a smooth waterfall. When concurrency slots are full, all waiting tasks sleep for the same fixed duration (~30s), then all wake up and compete simultaneously — repeating the pattern and significantly increasing total runtime.
Two changes:
Lower
tag_concurrency_slot_wait_secondsdefault from 30s to 10s — aligns with the value already used in Prefect Cloud (nebula). The 30s default was a major contributor to the batching problem.Use
avg_slot_occupancy_secondsfor server-side delay — instead of always delaying by the fixed setting value, the orchestration rule now uses the most contended V2 limit'savg_slot_occupancy_seconds(capped at the setting max). This makes the delay proportional to actual slot turnover, so tasks retry sooner when slots free up quickly. Falls back to the configured max whenavg_slot_occupancy_secondsis zero (e.g. newly created limits).Note: the V1 concurrency limit path is unchanged since V1 limits don't track
avg_slot_occupancy_seconds.Existing tests were updated to reflect the new 10s default for tag limit decay rates and retry-after bounds.
closes https://linear.app/prefect/issue/OSS-7078/tag-based-concurrency-adds-a-noticeable-delay-with-gcls
Checklist
<link to issue>"mint.json.Things for reviewers to verify
active_slots / limitratio as the heuristic for picking the "most contended" limit — note this will raiseZeroDivisionErrorif a limit haslimit=0, though that should not happen for active V2 limitsavg_slot_occupancy_seconds or max_waituses Python truthiness: a value of0.0(cold start / no samples yet) falls back tomax_wait, which is intentionalSecureTaskConcurrencySlots— existing concurrency tests (80 + 14 integration) all pass, and test expectations were updated where the default changedLink to Devin session: https://app.devin.ai/sessions/f27fc316ae2d4818bce18966344b368b
Requested by: @desertaxle