Skip to content

fix: use GOMAXPROCS instead of NumCPU for child process thread counts#279

Open
joshfriend wants to merge 1 commit intomainfrom
fix/use-gomaxprocs-for-thread-counts
Open

fix: use GOMAXPROCS instead of NumCPU for child process thread counts#279
joshfriend wants to merge 1 commit intomainfrom
fix/use-gomaxprocs-for-thread-counts

Conversation

@joshfriend
Copy link
Copy Markdown
Contributor

runtime.NumCPU() returns the node's CPU count (e.g. 64 on m5d.16xlarge), ignoring the cgroup CPU limit. This causes zstd (-T64) and git pack operations to spawn more threads than the CFS quota allows, resulting in constant CPU throttling despite low average utilization.

Uses runtime.GOMAXPROCS(0) which reflects the cgroup-aware effective CPU count, matching the container's actual CPU limit.

runtime.NumCPU() returns the node's CPU count (e.g. 64 on m5d.16xlarge),
ignoring the cgroup CPU limit. This causes zstd and git pack operations
to spawn more threads than the CFS quota allows, resulting in constant
CPU throttling despite low average utilization.

Use runtime.GOMAXPROCS(0) which reflects the cgroup-aware effective CPU
count, matching the container's actual CPU limit.
@joshfriend joshfriend marked this pull request as ready for review April 29, 2026 19:55
@joshfriend joshfriend requested a review from a team as a code owner April 29, 2026 19:55
@joshfriend joshfriend requested review from inez and removed request for a team April 29, 2026 19:55
@joshfriend joshfriend enabled auto-merge (squash) April 29, 2026 19:55
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.

3 participants