manager: limit concurrent housekeeping cgroupfs reads with GOMAXPROCS semaphore - #3932
Open
yunzhao-cf wants to merge 1 commit into
Open
manager: limit concurrent housekeeping cgroupfs reads with GOMAXPROCS semaphore#3932yunzhao-cf wants to merge 1 commit into
yunzhao-cf wants to merge 1 commit into
Conversation
… semaphore Add a process-wide semaphore (sized to GOMAXPROCS) around updateStats() in housekeepingTick() to limit concurrent cgroupfs reads. This prevents kernel lock contention on cgroup_rstat_lock when thousands of per-cgroup housekeeping goroutines flush cgroup stats simultaneously. The semaphore is initialized lazily (via sync.Once) so that it captures the effective GOMAXPROCS after setMaxProcs() / --max_procs has been applied. Also fix setMaxProcs() to respect the GOMAXPROCS environment variable when --max_procs is not explicitly set. Previously, setMaxProcs() unconditionally overrode GOMAXPROCS with runtime.NumCPU(), which on high-core-count machines (e.g. 192 cores) would create an oversized semaphore that provided no throttling. Benchmark on a 192-core host with ~400 cgroups, GOMAXPROCS=2, CPUQuota=200%, ondemand scrape mode, 11 scrapes at 53s intervals: Without semaphore: 75.05s total CPU, 3066ms p50 latency With semaphore: 9.32s total CPU, 363ms p50 latency (0.124x) Reviewed-by: Daniel Dao <dqminh89@gmail.com> Signed-off-by: Yunzhao Li <yunzhao@cloudflare.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a process-wide semaphore (sized to GOMAXPROCS) around updateStats() in housekeepingTick() to limit concurrent cgroupfs reads. This prevents kernel lock contention on cgroup_rstat_lock when thousands of per-cgroup housekeeping goroutines flush cgroup stats simultaneously.
The semaphore is initialized lazily (via sync.Once) so that it captures the effective GOMAXPROCS after setMaxProcs() / --max_procs has been applied.
Also fix setMaxProcs() to respect the GOMAXPROCS environment variable when --max_procs is not explicitly set. Previously, setMaxProcs() unconditionally overrode GOMAXPROCS with runtime.NumCPU(), which on high-core-count machines (e.g. 192 cores) would create an oversized semaphore that provided no throttling.
Benchmark on a 192-core host with ~400 cgroups, GOMAXPROCS=2, CPUQuota=200%, ondemand scrape mode, 11 scrapes at 53s intervals:
Without semaphore: 75.05s total CPU, 3066ms p50 latency
With semaphore: 9.32s total CPU, 363ms p50 latency (0.124x)
Reviewed-by: Daniel Dao dqminh89@gmail.com
Signed-off-by: Yunzhao Li yunzhao@cloudflare.com