Use ccache in CI (#11311)

This connects our CMake builds to a [ccache](https://ccache.dev/)
hosted in a GCS bucket. `ccache` newly (ish) supports using remote
storage for the cache! Currently it only supports Redis, FTP, and HTTP.
HTTPS is *not* supported right now, but there are plans to add an HTTPS
backend, as well as potentially a direct GCS backend (see
https://github.com/ccache/ccache/issues/1214).

I think this adds a little bit of overhead for the network requests,
potentially increasing the time for building with a completely cold 
cache. 

An example `build_all` job with a completely cold cache took 13.2
minutes for the entire job, 10 minutes for just the build step, of
which 6.1 minutes was spent in the actual `cmake --build` command (not
including builds of the `install` or `iree-test-deps` targets, which
don't involve building C++):
https://github.com/iree-org/iree/actions/runs/3562697821/jobs/5984663663

Going through that commit's ancestors on the main branch, this looks
like it's adding about 30±30 seconds to the build, using the
statistical technique of "eyeballing".

We get wins on the flip side though, where with a fully cached build,
the times are 6.3m, 3.8m, 1.6m.

The impact is even bigger with asan, where we see the same ~50%
improvement on the already-slower build.

Unfortunately, since ccache is a language-specific cache, we can't
do the same trick with all the test artifacts.

The lack of HTTPS support does present somewhat of a problem because
GCP doesn't allow using unsecured HTTP for many API access scopes. I
ran into trouble with this when trying to get things to work locally
because the local gcloud credentials for a user account usually have
very broad scope (see discussion in
https://github.com/ccache/ccache/pull/1001). But it *does* work fine on
our GCP VMs since those service accounts have much more limited
permissions. Luckily, we don't actually want users writing to the
cache, so this mostly just impacted me setting it up.

I also tried
[sccache](https://github.com/mozilla/sccache), which has a GCS backend,
but configuring the backend locally was pretty janky (see
https://github.com/mozilla/sccache/issues/144#issuecomment-1307997283).
I ultimately went with ccache since it's the much more established
project and it seems like there's quite a bit of design work going in
to making it work well.

ccache also supports two caching layers (indeed this is the standard
setup), so devs could make use of the remote cache by setting a
single config/env variable to point at it and continue using their
local ccache as well. This will of course only work as long as their
local machine is sufficiently similar to the docker containers or they
choose to build within docker containers.

Co-authored-by: Scott Todd <scotttodd@google.com>
40 files changed
tree: 1977b4ea0da66a5099a9b9632cc04c1d9a01a4c9
  1. .github/
  2. benchmarks/
  3. build_tools/
  4. compiler/
  5. docs/
  6. experimental/
  7. integrations/
  8. llvm-external-projects/
  9. runtime/
  10. samples/
  11. tests/
  12. third_party/
  13. tools/
  14. .bazelignore
  15. .bazelrc
  16. .bazelversion
  17. .clang-format
  18. .dockerignore
  19. .gitignore
  20. .gitmodules
  21. .pylintrc
  22. .style.yapf
  23. .yamllint.yml
  24. AUTHORS
  25. BUILD.bazel
  26. CITATION.cff
  27. CMakeLists.txt
  28. configure_bazel.py
  29. CONTRIBUTING.md
  30. LICENSE
  31. README.md
  32. WORKSPACE
README.md

IREE: Intermediate Representation Execution Environment

IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler and runtime that lowers Machine Learning (ML) models to a unified IR that scales up to meet the needs of the datacenter and down to satisfy the constraints and special considerations of mobile and edge deployments.

See our website for project details, user guides, and instructions on building from source.

CI Status

Project Status

IREE is still in its early phase. We have settled down on the overarching infrastructure and are actively improving various software components as well as project logistics. It is still quite far from ready for everyday use and is made available without any support at the moment. With that said, we welcome any kind of feedback on any communication channels!

Communication Channels

Related Project Channels

  • MLIR topic within LLVM Discourse: IREE is enabled by and heavily relies on MLIR. IREE sometimes is referred to in certain MLIR discussions. Useful if you are also interested in MLIR evolution.

Architecture Overview

IREE Architecture IREE Architecture

See our website for more information.

Presentations and Talks

  • 2021-06-09: IREE Runtime Design Tech Talk (recording and slides)
  • 2020-08-20: IREE CodeGen: MLIR Open Design Meeting Presentation (recording and slides)
  • 2020-03-18: Interactive HAL IR Walkthrough (recording)
  • 2020-01-31: End-to-end MLIR Workflow in IREE: MLIR Open Design Meeting Presentation (recording and slides)

License

IREE is licensed under the terms of the Apache 2.0 License with LLVM Exceptions. See LICENSE for more information.