Skip to content

feat: default --group-concurrency to the usable CPU core count - #109

Merged
amannocci merged 1 commit into
mainfrom
feat/group-concurrency-cpu-default
Oct 21, 2026
Merged

amannocci merged 1 commit into
mainfrom
feat/group-concurrency-cpu-default

Conversation

@amannocci

Copy link
Copy Markdown
Member

🧑‍💻What is the change being made?

  • When --group-concurrency is unset, --strategy parallel now defaults to the number of usable CPU cores (os.process_cpu_count(), falling back to 1). The default lives in ParallelExecutor, so every caller gets it.
  • The --group-concurrency option is now defined once in commands/helpers.py as group_concurrency_option and shared by plan, apply, fmt and validate. Before, there were three copies with different help texts.

❓ Why is the change being made?

With no explicit value, each wave fell back to ThreadPoolExecutor's default of min(32, cpu + 4) workers. Each worker starts its own terraform/opentofu process, so a large wave easily used every core. Capping at one group per usable core fixes that. Unlike os.cpu_count(), os.process_cpu_count() honors CPU affinity, so CI runners and CPU-limited containers aren't oversubscribed either.

✅ How has this been tested?

  • uv run pytest tests/it: 396 passed.
  • ruff check, ruff format --check and basedpyright are clean.
  • Checked through the click runner that plan, apply, fmt and validate all show the same --group-concurrency help text.

📚 How has this been documented?

The --group-concurrency help text and the README's parallel-execution section now say the default is the number of CPU cores, replacing "a sane pool size".

With `--strategy parallel` and no `--group-concurrency`, each wave used
ThreadPoolExecutor's default of min(32, cpu + 4) workers. Each worker
starts a terraform/tofu process, so this oversubscribed the CPUs. The
default is now `os.process_cpu_count()`, which honors CPU affinity.

The `--group-concurrency` option is also defined once in
`commands/helpers.py` and shared by plan, apply, fmt and validate.
@amannocci amannocci self-assigned this Oct 21, 2026
@amannocci
amannocci merged commit 124a698 into main Oct 21, 2026
17 checks passed
@amannocci
amannocci deleted the feat/group-concurrency-cpu-default branch October 21, 2026 09:37
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