Size active queried series worker pool from GOMAXPROCS#7671
Open
anxkhn wants to merge 1 commit into
Open
Conversation
The active queried series service sized its worker pool with runtime.NumCPU(), which returns the host's logical CPU count and ignores the CPU cgroup quota. Cortex imports go.uber.org/automaxprocs so that GOMAXPROCS matches the container's CPU limit, and reads container-aware parallelism via runtime.GOMAXPROCS(0) elsewhere (for example the resource monitor's CPU limit and the engine's decoding concurrency default). This one call site was inconsistent: in a CPU-limited container on a many-core host it sized the pool off the host cores instead of the CPU budget. Use runtime.GOMAXPROCS(0) so the pool follows the container CPU quota, matching the rest of the codebase. The min(..., 4) cap is unchanged. Add a regression test asserting the worker count follows GOMAXPROCS. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
e5c4b2b to
5917b6e
Compare
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.
What this PR does:
The active queried series service sizes its worker pool with
runtime.NumCPU(), which reports host logical CPUs and does not account for a container CPU quota. Cortex importsgo.uber.org/automaxprocssoGOMAXPROCSreflects that quota, and other concurrency defaults already useruntime.GOMAXPROCS(0).This switches the worker calculation to
runtime.GOMAXPROCS(0), preserving the existing minimum of one and maximum of four workers. A table-driven regression test verifies the calculation across severalGOMAXPROCSvalues.Which issue(s) this PR fixes:
No open issue; this is a small self-contained correctness fix.
Checklist
CHANGELOG.mdupdateddocs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags (n/a: no flags)This change was prepared with AI assistance per the project policy. I reviewed every line and validated the behavior and regression test.