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 image building in CI by exporting and importing mount cache #45314

Merged

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Dec 31, 2024

During the build, cache of uv and pip is stored in a separate "cache mount" volum that is mounted during the build. This cache mount volume is preserved between builds and can be exported and imported to speed up the build process in CI - where cache is stored as artifact and can be imported in the next build.

This PR implements it:

  • export and import commands are added to breeze to export/import cache mount content

  • the cache mount content is stashed as artifact in the build after image is built and it is restored before the image is built


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@potiuk
Copy link
Member Author

potiuk commented Dec 31, 2024

And here is caching of the "cache-mount" as well cc: @gopidesupavan

@potiuk
Copy link
Member Author

potiuk commented Dec 31, 2024

First tests show that we can go down to < 2 minutes from ~6 minutes to build the image

@potiuk potiuk force-pushed the export-import-mount-cache-to-speed-up-builds branch from 7b1ebeb to d6c758a Compare December 31, 2024 17:34
@potiuk potiuk requested a review from jscheffl December 31, 2024 17:41
@potiuk potiuk force-pushed the export-import-mount-cache-to-speed-up-builds branch from d6c758a to 96ca5fa Compare December 31, 2024 17:49
@potiuk potiuk force-pushed the export-import-mount-cache-to-speed-up-builds branch from 96ca5fa to 1417d17 Compare December 31, 2024 18:01
Copy link
Member

@gopidesupavan gopidesupavan left a comment

Choose a reason for hiding this comment

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

LGTM , useful with breeze commands

@gopidesupavan
Copy link
Member

First tests show that we can go down to < 2 minutes from ~6 minutes to build the image

Nice improvement :)

@potiuk potiuk force-pushed the export-import-mount-cache-to-speed-up-builds branch 13 times, most recently from 7504d5f to f4cd2ba Compare January 1, 2025 00:16
@potiuk potiuk force-pushed the export-import-mount-cache-to-speed-up-builds branch from f4cd2ba to e7987e1 Compare January 1, 2025 01:07
During the build, cache of ``uv`` and ``pip`` is stored in a separate
"cache mount" volum that is mounted during the build. This cache mount
volume is preserved between builds and can be exported and imported to
speed up the build process in CI - where cache is stored as artifact and
can be imported in the next build.

This PR implements it:

* export and import commands are added to breeze to export/import cache
  mount content

* the cache mount content is stashed as artifact in the build
  after image is built and it is restored before the image is built
@potiuk potiuk force-pushed the export-import-mount-cache-to-speed-up-builds branch from e7987e1 to 7d411b1 Compare January 1, 2025 01:31
@potiuk
Copy link
Member Author

potiuk commented Jan 1, 2025

Finally: 3m30 s. to build the image instead of 5m47. Not as fast as the fastest "registry" build we had (1m20s or so ) but "fast enough"

@potiuk potiuk merged commit 465c4a2 into apache:main Jan 1, 2025
91 checks passed
@potiuk potiuk deleted the export-import-mount-cache-to-speed-up-builds branch January 1, 2025 02:56
potiuk added a commit to potiuk/airflow that referenced this pull request Jan 2, 2025
The apache#45314 introduced the bug where image artifacts were not
uploaded alongside cache mount artifacts. It caused all PRs to be
tested with "main" version of code.
potiuk added a commit that referenced this pull request Jan 2, 2025
The #45314 introduced the bug where image artifacts were not
uploaded alongside cache mount artifacts. It caused all PRs to be
tested with "main" version of code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants