Skip to content

linux: fix uv_available_parallelism using cgroup #4278

Merged
bnoordhuis merged 20 commits intolibuv:v1.xfrom
Ludo171:fix/uv_available_parallelism_cgroup
Feb 28, 2024
Merged

linux: fix uv_available_parallelism using cgroup #4278
bnoordhuis merged 20 commits intolibuv:v1.xfrom
Ludo171:fix/uv_available_parallelism_cgroup

Conversation

@waltoss
Copy link
Copy Markdown
Contributor

@waltoss waltoss commented Jan 9, 2024

PR to fix #4146

@waltoss
Copy link
Copy Markdown
Contributor Author

waltoss commented Jan 9, 2024

Any idea why the ASAN build is failing ?

Copy link
Copy Markdown
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I pointed out single instances of style issues but please fix them all.

The ASAN buildbot is known to be problematic at the moment. You can just ignore it.

@vtjnash vtjnash mentioned this pull request Jan 12, 2024
@waltoss
Copy link
Copy Markdown
Contributor Author

waltoss commented Jan 25, 2024

@bnoordhuis I fixed styling issues and added tests directly in test-platform-output.c. It might be a bit ugly though, happy to have your feedback on it

To test it manually I built it with the following Dockerfile

# Use the official Ubuntu base image
FROM ubuntu:20.04

# Update the package list
RUN apt-get update

# Install cmake and other build dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y cmake libtool autoconf build-essential

# Fix : for some reason cmake is looking for gmake instead of make
RUN ln -s /usr/bin/make /usr/bin/gmake

# Set the working directory inside the container
WORKDIR /workspace

# Create a user 'libuv' and give ownership of /workspace to 'libuv'
RUN useradd -m libuv && chown -R libuv:libuv /workspace

# Switch to the 'libuv' user
USER libuv

# Copy the current directory contents into the container at /workspace
COPY --chown=libuv:libuv ./ /workspace/

# Run the build steps as 'libuv' user
RUN mkdir -p build
RUN (cd build && cmake .. -DBUILD_TESTING=ON)
RUN cmake --build build

# By default, run a shell
CMD ["/bin/sh", "-c", "/workspace/build/uv_run_tests platform_output"]

And following commands

$ docker build . libuv-test-cgroup
$ docker run --cpus="2" libuv-test-cgroup | grep available 

It correctly outputs 2 available cpus

image

@waltoss
Copy link
Copy Markdown
Contributor Author

waltoss commented Jan 30, 2024

@bnoordhuis have you other feedbacks ?

@bnoordhuis
Copy link
Copy Markdown
Member

Can you rebase on top of the v1.x branch? It looks like you're a few commits behind.

@waltoss waltoss force-pushed the fix/uv_available_parallelism_cgroup branch from f5bf3c6 to deda40d Compare February 4, 2024 14:19
@waltoss waltoss changed the base branch from master to v1.x February 4, 2024 14:20
@waltoss
Copy link
Copy Markdown
Contributor Author

waltoss commented Feb 4, 2024

Can you rebase on top of the v1.x branch? It looks like you're a few commits behind.

@waltoss waltoss force-pushed the fix/uv_available_parallelism_cgroup branch from deda40d to dd4d126 Compare February 11, 2024 09:39
@waltoss
Copy link
Copy Markdown
Contributor Author

waltoss commented Feb 11, 2024

@bnoordhuis I rebased on v1.x

Copy link
Copy Markdown
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@libuv/collaborators can one of you give this a quick high-level look-over?

Copy link
Copy Markdown
Member

@santigimeno santigimeno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple of comments.

@waltoss
Copy link
Copy Markdown
Contributor Author

waltoss commented Feb 27, 2024

@santigimeno @bnoordhuis any idea when this can be merged ?

@bnoordhuis
Copy link
Copy Markdown
Member

I'll go ahead and merge it. Thanks for the pull request.

@bnoordhuis bnoordhuis merged commit 6b56200 into libuv:v1.x Feb 28, 2024
giordano pushed a commit to JuliaLang/libuv that referenced this pull request Aug 26, 2024
uv_available_parallelism does not handle container cpu limit
set by systems like Docker or Kubernetes. This patch fixes
this limitation by comparing the amount of available cpus
returned by syscall with the quota of cpus available defined
in the cgroup.

Fixes: libuv#4146
(cherry picked from commit 6b56200)
giordano pushed a commit to JuliaLang/libuv that referenced this pull request Aug 31, 2024
uv_available_parallelism does not handle container cpu limit
set by systems like Docker or Kubernetes. This patch fixes
this limitation by comparing the amount of available cpus
returned by syscall with the quota of cpus available defined
in the cgroup.

Fixes: libuv#4146
(cherry picked from commit 6b56200)
giordano added a commit to giordano/Yggdrasil that referenced this pull request Aug 31, 2024
giordano added a commit to giordano/Yggdrasil that referenced this pull request Aug 31, 2024
giordano added a commit to JuliaPackaging/Yggdrasil that referenced this pull request Aug 31, 2024
giordano added a commit to JuliaLang/julia that referenced this pull request Aug 31, 2024
Corresponding PR to Yggdrasil:
JuliaPackaging/Yggdrasil#9337.

This build includes backports of
libuv/libuv#4278 (useful for for #46226) and
libuv/libuv#4521 (useful for #55592)
KristofferC pushed a commit to JuliaLang/julia that referenced this pull request Sep 12, 2024
Corresponding PR to Yggdrasil:
JuliaPackaging/Yggdrasil#9337.

This build includes backports of
libuv/libuv#4278 (useful for for #46226) and
libuv/libuv#4521 (useful for #55592)
kshyatt pushed a commit to JuliaLang/julia that referenced this pull request Sep 12, 2024
Corresponding PR to Yggdrasil:
JuliaPackaging/Yggdrasil#9337.

This build includes backports of
libuv/libuv#4278 (useful for for #46226) and
libuv/libuv#4521 (useful for #55592)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] - unix available_parallelism does not handle container cpu limits

3 participants