Skip to content

Bazel caching for GitHub Actions workflows #1236

Open

Description

@wchargin

It looks like your CI jobs build from scratch on every build, and thus
take many hours of workflow time (e.g., 7 hours for this workflow).
These cause builds for the entire TF organization to queue.

Bazel has built-in support for incremental remote caching. This is
not a Travis-style giant opaque cache that needs to be sent to and from
the VM on each run. Instead, it’s a fine-grained key-value store that
stores the results for individual actions on a remote server. It has
transparent integration with GCS and can be used with just a backing
bucket.

Could you please investigate using this? It would make you happy, and it
would make us and everyone else happy.

We use this on TensorBoard. It speeds up our builds from ~75 minutes
(clean slate) to ~4 minutes (no-op). You can look at our workflow file
and our bazelrc for guidance.

Activity

  1. yongtang commented on Dec 17, 2020

    @yongtang
    Member

    @wchargin We will be happy to use bazel cache as this will help speed up our CI process as well. At the moment the biggest blocker is that we don't have a GCS account/credential.

    @angerson @ewilderj @martinwicke Wondering if you can help with GCS account/credential to speed up the build?

  2. angerson commented on Dec 22, 2020

    @angerson

    FYI @theadactyl as well. I'm looking into the technical setup for a TF sub-project for this kind of thing.

  3. angerson commented on Dec 22, 2020

    @angerson

    @yongtang I started our internal "official" process for setting up a new GCP project to contain a bucket for SIGs to use, but unfortunately there's a production freeze and my request won't be processed until the 5th of January. This should cover due-diligence for any privacy/security related policy problems, although it's still possible we'll run into other nontechnical issues.

    FYI @perfinion

  4. yongtang commented on Dec 22, 2020

    @yongtang
    Member

    @angerson Thanks for the update 👍

  5. angerson commented on Jan 11, 2021

    @angerson

    I'm still working on this. It's going slow because there's a complex internal approval process for things like the ability to export service account credentials for bazel.

  6. angerson commented on Jan 19, 2021

    @angerson

    Another update: I've been working on this with the following assumptions:

    1. bazel build can only cache via a GCP service account credential file
    2. There is no method that doesn't require a service account credential file

    Our company security team can grant an exception allowing us to export service account keys, but they must have a prohibitively short lifespan. I'm now looking at whether or not I can automate a process that generates new keys regularly and automatically pushes them to a GitHub Actions secret.

  7. kvignesh1420 commented on Jan 21, 2021

    @kvignesh1420
    Member

    Thanks @angerson !

  8. yongtang commented on Jan 29, 2021

    @yongtang
    Member

    Added a PR #1287 as a first step to introduce the bazel cache. The PR only adds support for git push commit. The forked PR by outside contributors still do not have access yet. We will see if we can address it later.

  9. yongtang commented on Jan 29, 2021

    @yongtang
    Member
  10. ewilderj commented on Jan 29, 2021

    @ewilderj

    That's pretty cool!

  11. wchargin commented on Jan 29, 2021

    @wchargin
    Author

    That’s awesome—thanks very much to @angerson for setting this all up!

  12. angerson commented on Jan 29, 2021

    @angerson

    Great!

    We're still working on allowing PRs to use the cache, which depends on another policy exemption I'm requesting.

  13. kvignesh1420 commented on Jan 29, 2021

    @kvignesh1420
    Member

    That would be great! thanks a lot, @angerson.

  14. yongtang commented on Feb 3, 2021

    @yongtang
    Member

    The read-only bazel cache has been enabled for forked PRs as well now (see PR #1294). We see immediate speedup in all PRs (with macOS build reducing from 1hour20min to 15min).

    Thanks a lot to @angerson for the great work, and thanks a lot to tensowflow team, tensorflow community, and google for the support 👍 🎉 🎆 !

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions