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

Using a base image for CI jobs #2927

Merged
merged 16 commits into from
May 15, 2023
Merged

Conversation

mtzguido
Copy link
Member

This PR makes CI jobs (only the regular CI workflow on Linux; releases and others are unaffected) start from a base docker image instead of from scratch. This saves time as we don't have to install dependencies (which includes building Z3) on every push.

This change is rather annoying to make as there is no (to my knowledge) way of doing this kind of thing with buildx, especially if we need to avoid this. So, this PR changes the workflow to not use buildx for normal CI jobs. Other workflows still can use it.

The main benefit we got from buildx is safely passing a secret while the image is being built, which we use for the github token so we can advance hints. I've worked around that by building the image without any such secret nor advancing hints, and using docker run, which runs a container from an image, after the fact (passing the secret) to push to github. This container is not published anywhere.

The base image is rebuilt nightly (2AM UTC) and, if F* CI passes on it, it is tagged. If CI fails we do not tag, so CI jobs can still run, but we get a notification in Slack so we can fix the base. This is intended to not block people when some upstream dependency breaks.

Note that this slightly relies on the fact that we run all CI jobs on the same machine. The image rebuilding workflow affects the state of the docker installation on the machine so it can be taken by other workflows. If we have more than one machine runner, we would have to run this job once for every machine. Perhaps a cron job is more appropriate.

This also supersedes #2919. However the numbers we are getting vary quite wildly, so maybe we should disable it for now.

I've been testing this on a local runner and CI time reduces by about 50%.

@mtzguido
Copy link
Member Author

See the logs here https://github.com/FStarLang/FStar/actions/runs/4973169264/jobs/8898832659. Building the base took 8m28s and running CI took 9m7s. We didn't get a Slack message, since apparently this ran without the secret.

This enables performance monitoring (as in building with
`RESOURCEMONITOR=1`) for CI builds.

It is conditioned by the `FSTAR_CI_RESOURCEMONITOR` variable. It must be
set to `1` in the variables for the repository (Settings -> Secrets and
variables -> Actions -> Variables) for the monitoring to be enabled. It
is currently already enabled even without this PR.

In detail:
0) The workflow will pass the RESOURCEMONITOR=1 file to the Docker
   build command, this will cause our Makefiles to create .runlim
   files everywhere.
1) build-standalone.sh will, after running CI, create an `rmon/`
   directory and place relevant information there, including the summary
   generated by `.scripts/res_summary.sh` as well as all of the
   individual `.runlim` files ordered by path.
2) The workflow picks this directory up, and uploads two Github build
   artifacts, one with the summary and one with the tarball of all .runlim
   files.
3) Two lines added to the Slack message with total CPU and memory usage
   (to be seen how robust this measurement will be). Plus, a link to the
   resource summary pasted into sprunge.us, for a one-click view.

Github makes a .zip archive of an artifact when one tries to download
it (even if it contains a single file), which is annoying, but I don't
think there's an alternative currently.

Also, zipping seems to be slow, and can add minutes(!) to the build.
So we make a compressed tarball of the .runlim files first, and upload
that.
@mtzguido mtzguido merged commit 5704ae0 into FStarLang:master May 15, 2023
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.

1 participant