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

Speed up multidim-interop test runner #214

Open
MarcoPolo opened this issue Jun 30, 2023 · 7 comments
Open

Speed up multidim-interop test runner #214

MarcoPolo opened this issue Jun 30, 2023 · 7 comments
Labels
good first issue Good issue for new contributors help wanted Seeking public contribution on this issue

Comments

@MarcoPolo
Copy link
Contributor

In CI (using GitHub runners), each test (starting docker compose until it exits) takes about 2s. It’s unclear why this takes so long. My hunch is that it’s not the actual test that takes a while (the handshake and ping time is around 50-300ms), but the cost to setup the cgroups, network namespaces, and other docker specific things. Running the simplest docker image of hello-world takes around 400ms on my machine (time docker run --rm hello-world). There must be something here we can optimize.

Increasing the number of parallel compose stacks does not help (It does however help a bit on bigger machines).

@MarcoPolo MarcoPolo added good first issue Good issue for new contributors help wanted Seeking public contribution on this issue labels Jun 30, 2023
@MarcoPolo
Copy link
Contributor Author

Marking this as "good first issue" since it's pretty isolated.

@thomaseizinger
Copy link
Contributor

Increasing the number of parallel compose stacks does not help (It does however help a bit on bigger machines).

You mean, increasing the number of WORKER_TASKS?

@MarcoPolo
Copy link
Contributor Author

Increasing the number of parallel compose stacks does not help (It does however help a bit on bigger machines).

You mean, increasing the number of WORKER_TASKS?

yep

@thomaseizinger
Copy link
Contributor

I just came across https://depot.dev/ which might be worth looking at for optimising the initial build of containers.

@MarcoPolo
Copy link
Contributor Author

One idea would be to manually unpack the images and manually chroot into them with user namespaces. This should significantly speed things up for our use case.

A quick comparison:

Stock docker:

❯ time docker run  hello-world
// ... output ommited                                                                                                                                                                                                    
docker run hello-world  0.01s user 0.01s system 3% cpu 0.832 total

800ms!

Manually:

❯ time unshare --user --map-root-user chroot ./unpacked /hello                                                                                                                                                                                                
// ... output ommited
unshare --user --map-root-user chroot ./all /hello  0.00s user 0.00s system 58% cpu 0.007 total

7ms. 100x faster!

Of course this isn't everything Docker does, but it might be enough for our use case.

@thomaseizinger
Copy link
Contributor

7ms. 100x faster!

Of course this isn't everything Docker does, but it might be enough for our use case.

Wow, that is insane! For the ping example, all we need is to run binaries right? How long does it take to unpack the images though? I wouldn't be surprised if tar is consuming a fair amount of those 800ms.

@MarcoPolo
Copy link
Contributor Author

I wouldn't be surprised if tar is consuming a fair amount of those 800ms.

Yeah, although even after creating the container (which should cause the untarring) this still takes a bit more time.


I think before going to full manual route, we should explore managing the containers manually with docker directly instead of with compose. This would let us re-use the containers and only pay for container creation once for each implementation. This would greatly speed up tests that involve js-libp2p since those are pretty big containers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good issue for new contributors help wanted Seeking public contribution on this issue
Projects
None yet
Development

No branches or pull requests

2 participants