Skip to content

feat: add maxParallel option to limit workspace build concurrency#1

Closed
jpzwarte wants to merge 4 commits into
mainfrom
fix/issue-929-max-parallel
Closed

feat: add maxParallel option to limit workspace build concurrency#1
jpzwarte wants to merge 4 commits into
mainfrom
fix/issue-929-max-parallel

Conversation

@jpzwarte

@jpzwarte jpzwarte commented May 9, 2026

Copy link
Copy Markdown
Owner

Superseded by rolldown#940.

jpzwarte and others added 4 commits May 9, 2026 11:45
Fixes rolldown#929 by introducing a `maxParallel` config option that limits how
many workspace package builds can run concurrently.

Without a limit, `buildWithConfigs` uses `Promise.all()` which starts
all workspace builds simultaneously. When combined with `dts.tsgo: true`,
each package spawns a `tsgo` subprocess, which can result in dozens of
concurrent native processes and exhaust system resources.

When `maxParallel` is set to a positive integer, at most that many builds
run at the same time via a simple worker-pool implementation. When omitted,
existing unbounded concurrent behavior is preserved.

Changes:
- Add `maxParallel?: number` to `UserConfig` and keep it optional in
  `ResolvedConfig` (added to `MarkPartial` keys)
- Add `--max-parallel <number>` CLI flag; parse it as a number in the
  action handler so the string from argv is correctly coerced
- Add `normalizeMaxParallel`, `resolveMaxParallel`, and
  `mapWithConcurrency` helpers in `src/build.ts`
- Update `buildWithConfigs` to use the concurrency-limited pool when
  `maxParallel` is specified

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The per-option validation (positive integer check) belongs in
options.ts alongside all other single-config validation, not in
build.ts. build.ts still owns the cross-config resolveMaxParallel
and the mapWithConcurrency utility since those operate on the
already-resolved config array.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
maxParallel is a root-level option; workspace merging ensures all
resolved configs have the same value. Reading configs[0].maxParallel
is sufficient and simpler.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jpzwarte jpzwarte closed this May 9, 2026
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