From e304e601075664fe02f2ea2a38e50afdc19e7dd6 Mon Sep 17 00:00:00 2001 From: Elizabeth Worstell Date: Wed, 29 Apr 2026 14:08:53 -0700 Subject: [PATCH] fix(git): cap default zstd-threads to 4 in server config The git strategy's zstd-threads config defaulted to 0, which expands to runtime.NumCPU() at compression/decompression time. On high-core hosts (e.g. 32-64 vCPU nodes) this means each snapshot subprocess spawns one zstd worker per core, with each worker holding several MB of buffers. cachewd schedules three periodic jobs per warm mirror (snapshot, lfs-snapshot, mirror-snapshot) and they fire concurrently across all mirrors at startup. Combined with all-cores zstd, total transient memory during warm-up scales as repos x 3 x cores, easily reaching tens of GB on a many-mirror server and contributing to OOM kills. Cap the server-side default to 4 threads, which is enough to keep zstd off the critical path without blowing per-process memory. Operators that want the legacy behaviour can still set zstd-threads = 0 explicitly. The CLI's zstd-threads flags (cmd/cachew) keep 0 as their default because CLI invocations are short-lived single operations where using all cores is the right behaviour. Amp-Thread-ID: https://ampcode.com/threads/T-019ddaf9-b3be-7604-90b5-18566c260d1f Co-authored-by: Amp --- internal/strategy/git/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/strategy/git/git.go b/internal/strategy/git/git.go index f678c95..5d76f1c 100644 --- a/internal/strategy/git/git.go +++ b/internal/strategy/git/git.go @@ -39,7 +39,7 @@ type Config struct { SnapshotInterval time.Duration `hcl:"snapshot-interval,optional" help:"How often to generate tar.zstd workstation snapshots. 0 disables snapshots." default:"0"` MirrorSnapshotInterval time.Duration `hcl:"mirror-snapshot-interval,optional" help:"How often to generate mirror snapshots for pod bootstrap. 0 uses snapshot-interval. Defaults to 2h." default:"2h"` RepackInterval time.Duration `hcl:"repack-interval,optional" help:"How often to run full repack. 0 disables." default:"0"` - ZstdThreads int `hcl:"zstd-threads,optional" help:"Threads for zstd compression/decompression (0 = all CPU cores)." default:"0"` + ZstdThreads int `hcl:"zstd-threads,optional" help:"Threads for zstd compression/decompression. 0 = all CPU cores; useful for short-lived CLI invocations but risky on a long-running server where multiple snapshot/restore operations can run concurrently." default:"4"` } type Strategy struct {