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

CI: Consistent Caching #36

Closed
niklasdewally opened this issue Nov 3, 2023 · 13 comments
Closed

CI: Consistent Caching #36

niklasdewally opened this issue Nov 3, 2023 · 13 comments

Comments

@niklasdewally
Copy link
Contributor

niklasdewally commented Nov 3, 2023

Alot of the CI jobs use their own caching mechanism that is hard coded to look at minion, chuffed, minion and chuffed, etc...

I am thinking of a shell script that gets the hash of all submodules from git dynamically, and hashes these, producing a hash that represents all submodule dependencies.

Using this, all caches can then be converted to the form:

nightly-{os}{arch}-gitmodules-{submodules}-cargo-{cargo}
stable-{os}{arch}-gitmodules-{submodules}-cargo-{cargo}

This would make CI easier to update if we get new submodules, and allow more cache to be shared between jobs.

Also the paths to cache could be defined in one place (a script or text file in the repo).

(https://stackoverflow.com/questions/12641469/list-submodules-in-a-git-repository)

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Nov 3, 2023

Another issue is that caches on main should be accessible to PRs but are not currently... (they do a full build of everything which is slow).

I think we need to ensure that all caches are present on every commit to main. At the moment, by the look of the actions panel, not all caches are on main?

I imagine fixing cache to be consistent naming would fix this anyways.

https://stackoverflow.com/questions/69365200/github-actions-how-to-cache-dependencies-between-workflow-runs-of-different-bra
https://stackoverflow.com/questions/66563672/within-what-limits-github-actions-cache-work

@ChrisJefferson
Copy link
Contributor

This might require some more work (particularly with setting up the right compilers), but one option would be https://github.com/marketplace/actions/sccache-action

The idea behind sccache is it hashes files (and all their includes) when they are built, and then later if you build the same thing, it just copies back the result. The advantage is you can just build everything ever time, and it should take very little time, and your cache can't get "out of sync", because if you change any files, they now won't be cached.

I often do this on my own computer, to great success (it speeds up building minion from 3 minutes the first time, to 1.5 seconds the second time). I haven't tried using it on github actions I will admit.

@ChrisJefferson
Copy link
Contributor

If you want to investigate this, at the moment minion doesn't support options to set the c++ compiler used, but I'm happy to add one.

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Nov 3, 2023

I think what we are already doing is fine - I just cache the entire of the minion build directory on github, then minion uses ccache internally. This makes rebuilds really fast.

The problem is that each action uses a slightly different cache key that is calculated in different ways. Things would work better if there was one cache for the whole project, to be used across all actions. This would also have maintainability advantages when more solvers were added, as less files would need to be changed.

I am actually forcing clean builds of minion at the moment on minion update - I imagine this is a holdover from the days where my build.rs were a bit broken and didn't rebuild stuff properly. (I also remember something not rebuilding properly minion side that you fixed?). I fixed this locally a while back, so I could probably remove this from the CI.

@niklasdewally
Copy link
Contributor Author

Todo on completion:

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Nov 3, 2023

Also, for CI generally:

  • Conjure Oxide test and build
  • Rust docs build and deploy.

@niklasdewally
Copy link
Contributor Author

I am actually forcing clean builds of minion at the moment on minion update - I imagine this is a holdover from the days where my build.rs were a bit broken and didn't rebuild stuff properly. (I also remember something not rebuilding properly minion side that you fixed?). I fixed this locally a while back, so I could probably remove this from the CI.

To clarify on this, Rust didn't used to regenerate the bindings if I had changed Minion.

@ozgurakgun
Copy link
Contributor

From Conjure's caching I think as long as you use the right cache-keys they can share the cache.

The only problem is if we are generating a lot of stuff to be cached they can be kicked out of the cache (github gives us 10G). But this much storage should be enough for the most common tasks.

@ChrisJefferson
Copy link
Contributor

I believe Minion should now correctly rebuild -- but let me know if you ever notice it misbehaving (either building too much, or too little)

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Nov 3, 2023

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Nov 3, 2023

  • Probably should fully qualify job names so they should appear good in PRs (it seems to just display job name in places, not workflow_name/job_name as per usual)

@niklasdewally
Copy link
Contributor Author

@niklasdewally
Copy link
Contributor Author

#37

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