Repository navigation
feat: default --group-concurrency to the usable CPU core count - #109
Merged
Merged
Conversation
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.
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.
🧑💻What is the change being made?
--group-concurrencyis unset,--strategy parallelnow defaults to the number of usable CPU cores (os.process_cpu_count(), falling back to 1). The default lives inParallelExecutor, so every caller gets it.--group-concurrencyoption is now defined once incommands/helpers.pyasgroup_concurrency_optionand shared byplan,apply,fmtandvalidate. 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 ofmin(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. Unlikeos.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 --checkandbasedpyrightare clean.plan,apply,fmtandvalidateall show the same--group-concurrencyhelp text.📚 How has this been documented?
The
--group-concurrencyhelp text and the README's parallel-execution section now say the default is the number of CPU cores, replacing "a sane pool size".