From 1e5bf16e7fbc0bd97133f440a58e4eb5b3b35df0 Mon Sep 17 00:00:00 2001 From: Neha Sherpa Date: Wed, 25 Feb 2026 15:54:16 -0800 Subject: [PATCH 1/2] fix: bound CPU parallelism for zstd and git pack operations zstd was using -T0 (all cores) and git pack.threads was set to 0 (all cores), causing sustained CPU throttling in both staging and production. Limit both to 4 threads to stay within pod CPU limits. Co-Authored-By: Claude Sonnet 4.6 --- internal/gitclone/manager.go | 2 +- internal/snapshot/snapshot.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/gitclone/manager.go b/internal/gitclone/manager.go index 49d0ba7..790e5e3 100644 --- a/internal/gitclone/manager.go +++ b/internal/gitclone/manager.go @@ -366,7 +366,7 @@ func mirrorConfigSettings() [][2]string { // Disable auto GC {"gc.auto", "0"}, // Pack performance - {"pack.threads", "0"}, + {"pack.threads", "4"}, {"pack.deltaCacheSize", "512m"}, {"pack.windowMemory", "1g"}, } diff --git a/internal/snapshot/snapshot.go b/internal/snapshot/snapshot.go index 2e8f5bb..58fa8da 100644 --- a/internal/snapshot/snapshot.go +++ b/internal/snapshot/snapshot.go @@ -45,7 +45,7 @@ func Create(ctx context.Context, remote cache.Cache, key cache.Key, directory st tarArgs = append(tarArgs, ".") tarCmd := exec.CommandContext(ctx, "tar", tarArgs...) - zstdCmd := exec.CommandContext(ctx, "zstd", "-c", "-T0") + zstdCmd := exec.CommandContext(ctx, "zstd", "-c", "-T4") tarStdout, err := tarCmd.StdoutPipe() if err != nil { @@ -102,7 +102,7 @@ func Restore(ctx context.Context, remote cache.Cache, key cache.Key, directory s return errors.Wrap(err, "failed to create target directory") } - zstdCmd := exec.CommandContext(ctx, "zstd", "-dc", "-T0") + zstdCmd := exec.CommandContext(ctx, "zstd", "-dc", "-T4") tarCmd := exec.CommandContext(ctx, "tar", "-xpf", "-", "-C", directory) zstdCmd.Stdin = rc From 7279bce0aeebbfe323b8ad7452b44f96d0febd80 Mon Sep 17 00:00:00 2001 From: Neha Sherpa Date: Wed, 25 Feb 2026 16:09:23 -0800 Subject: [PATCH 2/2] fix: reduce default scheduler concurrency from NumCPU to 4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With zstd capped at 4 threads, running NumCPU concurrent snapshot jobs simultaneously still saturates the CPU limit (8 cores × 4 threads = 32). Capping concurrency at 4 limits simultaneous CPU-intensive jobs to 4 × 4 = 16 zstd threads, staying within the pod's 8–10 core budget. Co-Authored-By: Claude Sonnet 4.6 --- internal/jobscheduler/jobs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/jobscheduler/jobs.go b/internal/jobscheduler/jobs.go index 3db0e6c..501db28 100644 --- a/internal/jobscheduler/jobs.go +++ b/internal/jobscheduler/jobs.go @@ -13,7 +13,7 @@ import ( ) type Config struct { - Concurrency int `hcl:"concurrency" help:"The maximum number of concurrent jobs to run (0 means number of cores)." default:"0"` + Concurrency int `hcl:"concurrency" help:"The maximum number of concurrent jobs to run (0 means number of cores)." default:"4"` SchedulerDB string `hcl:"scheduler-db" help:"Path to the scheduler state database." default:"${CACHEW_STATE}/scheduler.db"` }