Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: fix uv_available_parallelism using cgroup #4278

Merged
merged 20 commits into from Feb 28, 2024

Conversation

waltoss
Copy link
Contributor

@waltoss waltoss commented Jan 9, 2024

PR to fix #4146

@waltoss
Copy link
Contributor Author

waltoss commented Jan 9, 2024

Any idea why the ASAN build is failing ?

Copy link
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.

include/uv.h Outdated Show resolved Hide resolved
src/unix/core.c Outdated Show resolved Hide resolved
src/unix/core.c Outdated Show resolved Hide resolved
src/unix/core.c Outdated Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
@vtjnash vtjnash mentioned this pull request Jan 12, 2024
@waltoss
Copy link
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

src/unix/core.c Outdated Show resolved Hide resolved
src/unix/core.c Outdated Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
src/unix/linux.c Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
test/test-platform-output.c Outdated Show resolved Hide resolved
test/test-platform-output.c Outdated Show resolved Hide resolved
test/test-platform-output.c Outdated Show resolved Hide resolved
test/test-platform-output.c Show resolved Hide resolved
test/test-platform-output.c Outdated Show resolved Hide resolved
@waltoss
Copy link
Contributor Author

waltoss commented Jan 30, 2024

@bnoordhuis have you other feedbacks ?

@bnoordhuis
Copy link
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
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
Contributor Author

waltoss commented Feb 11, 2024

@bnoordhuis I rebased on v1.x

Copy link
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
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.

src/unix/linux.c Outdated Show resolved Hide resolved
src/unix/linux.c Show resolved Hide resolved
src/unix/linux.c Outdated Show resolved Hide resolved
@waltoss
Copy link
Contributor Author

waltoss commented Feb 27, 2024

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

@bnoordhuis
Copy link
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
37 checks passed
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