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

Build cache for export step takes ~300s to complete #545

Closed
anthonyma94 opened this issue Jan 24, 2022 · 11 comments
Closed

Build cache for export step takes ~300s to complete #545

anthonyma94 opened this issue Jan 24, 2022 · 11 comments

Comments

@anthonyma94
Copy link

I followed the docs here to use caching in my actions, but my job takes an extremely long time (300s on average) to prepare and export build cache to GitHub. Is there a reason the caching takes so long?

YAML file:

build-api:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: docker/setup-buildx-action@v1

      - name: Login to Github Packages
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push API
        uses: docker/build-push-action@v2
        with:
          context: .
          tags: |
            ghcr.io/<registry_name>/api:${{ github.event.release.tag_name }}
            ghcr.io/<registry_name>/api:latest
          build-args: |
            APP=api
          push: true
          cache-from: type=gha
          cache-to: type=gha,mode=max
@Tirke
Copy link

Tirke commented Jan 24, 2022

+1 trying to have a very fast build on the CI, and currently all time is spent preparing and exporting the cache ...

@crazy-max
Copy link
Member

crazy-max commented Jan 30, 2022

@anthonyma94 @Tirke Hard to tell without a repro. Do you have a link to your repo?

@anthonyma94
Copy link
Author

@crazy-max it's a private repo unfortunately. Maybe @Tirke can help on that front?

@gustavovalverde
Copy link

I have the same issue, but I'm using type=registry, sometimes it just hangs there for over 2 hours. It commonly fluctuates between 3 to 15 minutes.

https://github.com/ZcashFoundation/zebra/runs/5032296281?check_suite_focus=true#step:6:968

@gustavovalverde
Copy link

Related: #259

@barthap
Copy link

barthap commented Feb 6, 2022

Have similar issue, but this might be caused by cache size

Repro repo here, following jobs (clean runs, no previous cache):

I'm using type=gha, mode=max, because all my Dockerfiles are multi-staged.
In case of Web app, the reason is probably a huge yarn cache dir (~1.5 GB) which is copied between stages.
An ideal solution would be to mount this as external volume, since this is actually used in other non-docker workflows too, with actions/cache@v2, but I have no idea if and how it is possible to share a directory between GHA and Dockerfile stages.

@BeyondEvil
Copy link
Contributor

BeyondEvil commented Oct 5, 2022

@barthap This was my thinking too (external volume mount), theoretically that shouldn't be a problem or even difficult, but the question is how to turn off the cache export step.

ETA: We use self-hosted Github Actions runners.

@anthonyma94
Copy link
Author

Bumping this into 2023, not caching anything sucks and makes GHA much slower than just building locally.

@Tirke
Copy link

Tirke commented Feb 1, 2023

By switching to the S3 cache, I solved all my performance issues / cache limitations with Github Actions.

@newdeal123
Copy link

In my case, it worked well to adjust the mode=min or mode=max according to the situation according to the caching hit rate. Since mode=max is not always good, it is recommended that you experiment in both cases and choose a faster one. Also, giving options such as compression=zstd did a little to save time.

@crazy-max
Copy link
Member

Yes you might hit GitHub rate-limit when pushing cache blobs to their backend which we don't control. You might also be interested in using timeout attribute: https://docs.docker.com/build/cache/backends/gha/#synopsis in case the service gets rate-limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants