Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/cachew/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ type CLI struct {
}

func main() {
// Override GOMAXPROCS: container environments may set it to a low value
// (e.g. 2) based on cgroup CPU limits. With few OS threads available, the
// Go scheduler can't run the zstd decoder, tar reader, and file-write
// goroutines concurrently — they time-slice, and the pipeline stalls.
// Using all available CPUs lets all goroutines actually run in parallel.
runtime.GOMAXPROCS(runtime.NumCPU())

cli := CLI{}
kctx := kong.Parse(&cli, kong.UsageOnError(), kong.HelpOptions{Compact: true}, kong.DefaultEnvars("CACHEW"), kong.Bind(&cli))
ctx := context.Background()
Expand Down
8 changes: 8 additions & 0 deletions cmd/cachewd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
_ "net/http/pprof" //nolint:gosec
"os"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -53,6 +54,13 @@ type CLI struct {
}

func main() {
// Override GOMAXPROCS: container environments may set it to a low value
// (e.g. 2) based on cgroup CPU limits. With few OS threads available, the
// Go scheduler can't run the zstd decoder, tar reader, and file-write
// goroutines concurrently — they time-slice, and the pipeline stalls.
// Using all available CPUs lets all goroutines actually run in parallel.
runtime.GOMAXPROCS(runtime.NumCPU())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid bypassing quota-aware GOMAXPROCS defaults

Calling runtime.GOMAXPROCS(runtime.NumCPU()) here overrides both Go 1.25’s container-aware default and any operator-provided GOMAXPROCS value, which can over-subscribe CPU in quota-limited containers (for example, a pod limited to 2 CPUs on a 64-core node) and cause cgroup throttling/latency regressions under load; the same pattern is also introduced in cmd/cachew/main.go. Please keep the runtime default (or gate this behind an explicit opt-in) so deployments that rely on CPU limits are not penalized.

Useful? React with 👍 / 👎.


var cli CLI
kctx := kong.Parse(&cli, kong.DefaultEnvars("CACHEW"))

Expand Down