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

ci: warm-up docker images #2099

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

ci: warm-up docker images #2099

wants to merge 6 commits into from

Conversation

mayeut
Copy link
Member

@mayeut mayeut commented Nov 25, 2024

Let's see if we can speed-up linux CI by warming-up docker images.
This helps locally but I have a very slow Internet connection so it might not apply here.

@mayeut
Copy link
Member Author

mayeut commented Nov 25, 2024

That's roughly 4/5 minutes less in the GHA build on x86_64, doesn't change a thing on qemu builds except for aarch64 where it's slower (probably because graalpy also gets installed).
Slower on CircleCI.
15 minutes less on Azure
The queue is still long on Travis CI...

@henryiii
Copy link
Contributor

How much slower? Seems like an overall win?

@mayeut
Copy link
Member Author

mayeut commented Nov 28, 2024

It seems like an overall win, I will do a proper sum-up this week-end once a couple things are fixed like the emulation run on GHA.
TravisCI has ran now and it's 25 minutes less on x64 / 10 minutes less on aarch64

@mayeut
Copy link
Member Author

mayeut commented Nov 30, 2024

Here's a sum-up, with last commits:

Job before after comment
GHA x86_64 3.13 46m 16s 36m 57s
GHA x86_64 3.8 45m 45s 39m 40s
GHA aarch64 26m 58s 26m 51s should not change
GHA armv7l 15m 50s 16m 23s should not change
GHA ppc64le 17m 24s 17m 47s should not change
GHA s390x 20m 19s 19m 22s should not change
Azure x86_64 1h 10m 8s 1h 2m 6s
CircleCI x86_64 10m 17s 9m 40s
CircleCI aarch64 6m 9s 5m 45s
TravisCI x86_64 1h 20m 0s 1h 4m 10s
TravisCI aarch64 39m 33s 28m 41s
TravisCI ppc64le fail fail fail
TravisCI s390x 43m 57s 33m 14s should be slower
GitLab CI x86_64 16m 46s 16m 10s
CirrusCI x86_64 19m 18s no credits (old run)
CirrusCI aarch64 19m 57s no credits (old run)

@mayeut mayeut marked this pull request as ready for review November 30, 2024 09:29
Copy link
Contributor

@joerick joerick left a comment

Choose a reason for hiding this comment

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

A decent improvement! Thanks! Anything we can do to speed up the tests is good for productivity.

test/conftest.py Outdated
Comment on lines 70 to 73
if exit_code == "0":
subprocess.run(
["docker", "commit", container_id, image], check=True, stdout=subprocess.DEVNULL
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we print an error or fail if the command doesn't succeed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. should we print or fail ?
Maybe we should just fail here. I will add a commit doing that (& revert if we decide not to fail but print).

test/conftest.py Outdated
Comment on lines 90 to 93
if worker_id == "master":
# not executing with multiple workers
return docker_warmup(request)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this early return needed? I can't see the downside of the locking in the single-worker case?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was taken from https://pytest-xdist.readthedocs.io/en/stable/how-to.html#making-session-scoped-fixtures-execute-only-once

I asked myself the same question but did not add a comment.
I can't see the downside of the locking but I can see one in writing to tmp_path_factory.getbasetemp().parent which might not be so temporary anymore in single worker mode.

subprocess.run(
["docker", "commit", container_id, image], check=True, stdout=subprocess.DEVNULL
)
subprocess.run(["docker", "rm", container_id], check=True, stdout=subprocess.DEVNULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be polite to run this in a finally: block

Copy link
Member Author

@mayeut mayeut Nov 30, 2024

Choose a reason for hiding this comment

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

Done in the commit that enforce the warm-up does not fail
As it's only done in CI, being polite is not required but when considering failure now, it's easy enough to change this (would require nesting 2 try/except/finally in the commit before that)

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.

4 participants