↓ Skip to main content

“This means if you have a 16 core machine the Go runtime will create 16 OS threads - regardless of any CGroup CPU Limits.”

River Phillipsriverphillips.dev ↗

Give a Go service four CPUs of quota on a 16-core host and the runtime still plans for 16. The scheduler throttles the extra threads, and garbage collection stalls waiting for them to stop. Setting GOMAXPROCS to match the quota cut the stop-the-world pause to 26 microseconds, about a tenth of the default. The fix is one environment variable, and Go still doesn’t set it for you.