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

Enable SCCACHE_CACHE_MULTIARCH env variable for macOS caching #115

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

moechaieb
Copy link
Contributor

Problem
On macOS builds, sccache was previously not caching anything from the CMake build:

Compile requests                    132
Compile requests executed             0
Cache hits                            0
Cache misses                          0
Cache timeouts                        0
Cache read errors                     0
Forced recaches                       0
Cache write errors                    0
Compilation failures                  0
Cache errors                          0
Non-cacheable compilations            0
Non-cacheable calls                 132
Non-compilation calls                 0
Unsupported compiler calls            0
Average cache write               0.000 s
Average compiler                  0.000 s
Average cache read hit            0.000 s
Failed distributed compilations       0

Non-cacheable reasons:
multiple different -arch, and SCCACHE_CACHE_MULTIARCH not set     132

Cache location                  ghac, name: sccache-v0.8.1, prefix: /sccache/
Version (client)                0.8.1

From checking the source code of sccache, we can see this is due to sccache defaulting to not caching builds when it detects multiple target architectures, which is the case for our macOS builds (source)

Solution
Set the SCCACHE_CACHE_MULTIARCH variable. On my first build setting this, we no longer see any non-cacheable calls:

Compile requests                    132
Compile requests executed           132
Cache hits                            0
Cache misses                        132
Cache misses (C/C++)                132
Cache timeouts                        0
Cache read errors                     0
Forced recaches                       0
Cache write errors                    0
Compilation failures                  0
Cache errors                          0
Non-cacheable compilations            0
Non-cacheable calls                   0
Non-compilation calls                 0
Unsupported compiler calls            0
Average cache write               0.188 s
Average compiler                  3.094 s
Average cache read hit            0.000 s
Failed distributed compilations       0
Cache location                  ghac, name: sccache-v0.8.1, prefix: /sccache/
Version (client)                0.8.1

__Problem__
On macOS builds, sccache was previously not caching anything from the CMake build:

```
Compile requests                    132
Compile requests executed             0
Cache hits                            0
Cache misses                          0
Cache timeouts                        0
Cache read errors                     0
Forced recaches                       0
Cache write errors                    0
Compilation failures                  0
Cache errors                          0
Non-cacheable compilations            0
Non-cacheable calls                 132
Non-compilation calls                 0
Unsupported compiler calls            0
Average cache write               0.000 s
Average compiler                  0.000 s
Average cache read hit            0.000 s
Failed distributed compilations       0

Non-cacheable reasons:
multiple different -arch, and SCCACHE_CACHE_MULTIARCH not set     132

Cache location                  ghac, name: sccache-v0.8.1, prefix: /sccache/
Version (client)                0.8.1
```

From checking the source code of sccache, we can see this is due to sccache defaulting to not caching builds when it detects multiple target architectures, which is the case for our macOS builds ([source](https://github.com/mozilla/sccache/blob/main/src/compiler/gcc.rs#L286))

__Solution__
Set the SCCACHE_CACHE_MULTIARCH variable. On my first build setting this, we no longer see any non-cacheable calls:


```
Compile requests                    132
Compile requests executed           132
Cache hits                            0
Cache misses                        132
Cache misses (C/C++)                132
Cache timeouts                        0
Cache read errors                     0
Forced recaches                       0
Cache write errors                    0
Compilation failures                  0
Cache errors                          0
Non-cacheable compilations            0
Non-cacheable calls                   0
Non-compilation calls                 0
Unsupported compiler calls            0
Average cache write               0.188 s
Average compiler                  3.094 s
Average cache read hit            0.000 s
Failed distributed compilations       0
Cache location                  ghac, name: sccache-v0.8.1, prefix: /sccache/
Version (client)                0.8.1
```
@moechaieb
Copy link
Contributor Author

On follow-up macOS builds, we see cache hits as expected:

Current runner version: '2.319.1'
Operating System
  macOS
  14.6.1
  23G93
Runner Image
  Image: macos-14-arm64
  Version: 20240922.1
  Included Software: https://github.com/actions/runner-images/blob/macos-14-arm64/20240922.1/images/macos/macos-14-arm64-Readme.md
  Image Release: https://github.com/actions/runner-images/releases/tag/macos-14-arm64%2F20240922.1

...

Full human-readable stats:
Compile requests                    132
Compile requests executed           132
Cache hits                          131
Cache hits (C/C++)                  131
Cache misses                          1
Cache misses (C/C++)                  1
Cache timeouts                        0
Cache read errors                     0
Forced recaches                       0
Cache write errors                    0
Compilation failures                  0
Cache errors                          0
Non-cacheable compilations            0
Non-cacheable calls                   0
Non-compilation calls                 0
Unsupported compiler calls            0
Average cache write               0.198 s
Average compiler                  0.053 s
Average cache read hit            0.169 s
Failed distributed compilations       0
Cache location                  ghac, name: sccache-v0.8.1, prefix: /sccache/
Version (client)                0.8.1

@sudara
Copy link
Owner

sudara commented Sep 26, 2024

Thanks for saving all of us time and money! Super appreciated — fwiw failing tests have to do with workflow secrets not being shared on forks.

@sudara sudara merged commit ab5e18a into sudara:main Sep 26, 2024
2 of 4 checks passed
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.

2 participants