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

About ccache and cache storage #1023

Open
mwestphal opened this issue Apr 24, 2024 · 5 comments
Open

About ccache and cache storage #1023

mwestphal opened this issue Apr 24, 2024 · 5 comments

Comments

@mwestphal
Copy link
Contributor

Hi TTK!

I see that your CI is starting to use ccache, that's great!
However, I see that you started using release to store the caches themselves, I dont think this is the easiest nor the most efficient way to it.

Also, ccache is linux specific, while sccache supports all OSes.

Over at F3D we are using sccache and cache github actions to handle our cache with success and great compilation speedup.

It is done like this:


  - name: Initialize sccache environnement
    shell: bash
    run: |
      sccache --start-server
      echo SCCACHE_CACHE=$(sccache --show-stats | grep Local | cut -d '"' -f2) >> $GITHUB_ENV
      echo DATE_STRING=$(date +'%Y%m%d') >> $GITHUB_ENV
      sccache --stop-server

  - name: Recover sccache cache
    uses: actions/cache@v4
    with:
      path: ${{env.SCCACHE_CACHE}}
      key: sccache-cache-${{inputs.raytracing_label}}-${{runner.os}}-${{ runner.os == 'macOS' && env.CMAKE_OSX_ARCHITECTURES || 'x86_64' }}-0-${{env.DATE_STRING}}
      restore-keys: sccache-cache-${{inputs.raytracing_label}}-${{runner.os}}-${{ runner.os == 'macOS' && env.CMAKE_OSX_ARCHITECTURES || 'x86_64' }}-0

  - name: Start sccache
    shell: bash
    working-directory: ${{github.workspace}}
    run: sccache --start-server

Full CI is here: https://github.com/f3d-app/f3d-superbuild/blob/main/.github/actions/f3d-superbuild/action.yml#L46

I dont have enough bandwidth to take care of this myself but I'd be happy to explain how it works and why I think this would provide better feature than the solution currently being implemented :)

hth

@mwestphal
Copy link
Contributor Author

@CharlesGueunet

@julien-tierny
Copy link
Collaborator

@pierre-guillou

@pierre-guillou
Copy link
Contributor

Hi @mwestphal,

I'm the one that put these workflows into place. I used ccache on Ubuntu & macOS because at that time (3 years ago) I thought it was the simplest solution.

Note that we use sccache on Windows (it was quite a pain to make it work with CMake + clang-cl for OpenMP…). We stuck to an old version of sccache there to avoid a bug but I haven't tried with newer versions yet.

I decided to use GitHub releases to store ccache/sccache data for several reasons:

  • I didn't want PRs have a write access to the cache, only a read access
  • I wanted a centralized cache accessible to other repositories, in case developpers want to test their code in their fork without creating a PR to the main TTK repository
  • GitHub cache action did not seem to work well across different branches/PRs.

So I came up (in several iterations) with the current system that (mis)uses GitHub Releases to store ccache/sccache data at every commit / PR merge in the main repository.

Do you think the current action/cache supports these uses-cases?

We can switch from ccache to sccache in the Ubuntu & macOS jobs but sccache seems a bit more intrusive with its --start-server & --stop-server invocations. Is there any sccache feature that makes it more attractive than ccache?

@mwestphal
Copy link
Contributor Author

Thanks for your answer.

I didn't want PRs have a write access to the cache, only a read access

Great, github cache behave the same

I wanted a centralized cache accessible to other repositories, in case developpers want to test their code in their fork without creating a PR to the main TTK repository

Great github cache behave the same

GitHub cache action did not seem to work well across different branches/PRs.

It works perfectly actions branches, forks and PRs.
It is designed by github for github users to do exactly that.

Do you think the current action/cache supports these uses-cases?

Yes

Is there any sccache feature that makes it more attractive than ccache?

Windows support

I hope that answers your questions. I cann explain how it works in F3D ci if needed. Maybe I'm missing something regarding TTK needs but so far I do really thing that github cacches + sccache works wonders.

@mwestphal
Copy link
Contributor Author

BTW I'm thinking of adding a sccache github action that could be used out of the box, I'll let you know If I do that.

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

No branches or pull requests

3 participants