topology-tool-kit / ttk

TTK - Topological Data Analysis and Visualization - Source Code
https://topology-tool-kit.github.io/
Other
415 stars 124 forks source link

About ccache and cache storage #1023

Open mwestphal opened 5 months ago

mwestphal commented 5 months ago

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 commented 5 months ago

@CharlesGueunet

julien-tierny commented 5 months ago

@pierre-guillou

pierre-guillou commented 5 months ago

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:

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 commented 5 months ago

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 commented 5 months ago

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.