diff options
author | Juan José <soyjuanarbol@gmail.com> | 2025-04-22 15:12:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-22 22:12:30 +0200 |
commit | 69d2dfec148af697fa6dd45eb53816dfb4c86ecc (patch) | |
tree | bff200f38548ff6528556d537ebb0e9e37d75dba /src/unix/core.c | |
parent | 47a5c85c4e7c63adc838d8e252fb4859e6cb743d (diff) | |
download | libuv-69d2dfec148af697fa6dd45eb53816dfb4c86ecc.tar.gz libuv-69d2dfec148af697fa6dd45eb53816dfb4c86ecc.zip |
linux: align CPU quota calculation with Rust (#4746)
Align CPU quota calculation with Rust's cgroup heuristics.
Fixes: https://github.com/libuv/libuv/issues/4740
Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
Diffstat (limited to 'src/unix/core.c')
-rw-r--r-- | src/unix/core.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/unix/core.c b/src/unix/core.c index 115cbe69..bd51b69b 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -2046,14 +2046,11 @@ unsigned int uv_available_parallelism(void) { #ifdef __linux__ { - double rc_with_cgroup; - uv__cpu_constraint c = {0, 0, 0.0}; + long long quota = 0; - if (uv__get_constrained_cpu(&c) == 0 && c.period_length > 0) { - rc_with_cgroup = (double)c.quota_per_period / c.period_length * c.proportions; - if (rc_with_cgroup < rc) - rc = (long)rc_with_cgroup; /* Casting is safe since rc_with_cgroup < rc < LONG_MAX */ - } + if (uv__get_constrained_cpu("a) == 0) + if (quota > 0 && quota < rc) + rc = quota; } #endif /* __linux__ */ |