Skip to content

Respect cgroup CPU quotas for default threads - #139

Open
dylanrb123 wants to merge 5 commits into
mainfrom
dbannon/cgroup-aware-cpu-count
Open

dylanrb123 wants to merge 5 commits into
mainfrom
dbannon/cgroup-aware-cpu-count

Conversation

@dylanrb123

@dylanrb123 dylanrb123 commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • derive the default worker count from hardware concurrency, Linux CPU affinity, and cgroup CPU quotas
  • support cgroup v1, cgroup v2, nested limits, hybrid layouts, and cgroup namespaces
  • retain existing behavior on non-Linux platforms and preserve explicit thread-count overrides

Testing

  • make test (11 tests passed)
  • tox -e check-formatting
  • clang-format dry-run
  • git diff --check

Linux container validation

Compiled the CPU detector from this branch inside an Ubuntu 24.04 container and exercised it with real Docker cgroup limits. All assertions passed.

Docker limits hardware_concurrency Affinity CPUs Quota CPUs Voyager default
--cpus=0.5 18 18 1 1
--cpus=1.5 18 18 2 2
--cpus=3 18 18 3 3
--cpuset-cpus=0-1 18 2 unlimited 2
--cpuset-cpus=0-3 and --cpus=1.5 18 4 2 2

This verifies that the default uses the minimum of hardware concurrency, affinity, and the rounded-up cgroup quota instead of the host CPU count.

Generated with Codex.

dylanrb123 and others added 5 commits September 17, 2026 09:57
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@dylanrb123
dylanrb123 marked this pull request as ready for review September 17, 2026 17:16

This branch has not been deployed

No deployments
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