fix(core): respect --parallel limit for discrete task concurrency#34721
Merged
AgentEnder merged 1 commit intomasterfrom Mar 21, 2026
Merged
fix(core): respect --parallel limit for discrete task concurrency#34721AgentEnder merged 1 commit intomasterfrom
AgentEnder merged 1 commit intomasterfrom
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit 53ed28a
☁️ Nx Cloud last updated this comment at |
…s tasks exist Split the unified thread pool into discrete and continuous pools so that --parallel only caps discrete task concurrency. Continuous tasks get dedicated threads that don't inflate the discrete limit.
Contributor
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx create-nx-workspace@22.6.0-pr.34721.53ed28a my-workspaceOr just copy this version and use it in your own command: 22.6.0-pr.34721.53ed28a
To request a new release for this pull request, mention someone from the Nx team or the |
Closed
4 tasks
AgentEnder
approved these changes
Mar 21, 2026
FrozenPandaz
pushed a commit
that referenced
this pull request
Mar 26, 2026
…4721) ## Current Behavior `--parallel=N` doesn't cap discrete task concurrency when continuous tasks exist. `getThreadCount` inflates the thread count to `N + continuousCount`, and all threads are fungible — any thread picks up any task. With `--parallel=1` and 2 continuous tasks, 3 threads run, allowing up to 3 discrete tasks concurrently. ## Expected Behavior `--parallel=N` caps discrete task concurrency to N. Continuous tasks get dedicated threads that don't inflate the discrete limit. ### Changes - **Two-pool thread model**: Split the unified thread pool into discrete and continuous pools. Each pool runs its own loop and only picks up matching tasks. - **`getThreadPoolSize`** (renamed from `getThreadCount`): Returns `{ discrete, continuous, total }`. Discrete pool = `options.parallel`, continuous pool = number of continuous tasks. - **`executeDiscreteTaskLoop`**: Handles batches + discrete tasks only. Uses slot-based groupIds via `closeGroup`/`openGroup`. - **`executeContinuousTaskLoop`**: Handles continuous tasks only. Uses counter-based groupIds (`parallel + n++`). Exits once all continuous tasks have been started. - **`nextTask(filter?)`** on `TasksSchedule`: Optional filter param to dequeue only matching tasks. Scheduler stays unaware of pools/limits. ## Related Issue(s) Fixes #34117 Fixes #31494 (cherry picked from commit e0b7f12)
Contributor
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Current Behavior
--parallel=Ndoesn't cap discrete task concurrency when continuous tasks exist.getThreadCountinflates the thread count toN + continuousCount, and all threads are fungible — any thread picks up any task. With--parallel=1and 2 continuous tasks, 3 threads run, allowing up to 3 discrete tasks concurrently.Expected Behavior
--parallel=Ncaps discrete task concurrency to N. Continuous tasks get dedicated threads that don't inflate the discrete limit.Changes
getThreadPoolSize(renamed fromgetThreadCount): Returns{ discrete, continuous, total }. Discrete pool =options.parallel, continuous pool = number of continuous tasks.executeDiscreteTaskLoop: Handles batches + discrete tasks only. Uses slot-based groupIds viacloseGroup/openGroup.executeContinuousTaskLoop: Handles continuous tasks only. Uses counter-based groupIds (parallel + n++). Exits once all continuous tasks have been started.nextTask(filter?)onTasksSchedule: Optional filter param to dequeue only matching tasks. Scheduler stays unaware of pools/limits.Related Issue(s)
Fixes #34117
Fixes #31494