Skip to content

CI: experiment state cache for incremental build #7360

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

Merged
merged 6 commits into from
Mar 24, 2025

Conversation

cometkim
Copy link
Member

@cometkim cometkim commented Mar 23, 2025

The compiler build takes up half of the entire CI workflow, and build speed is a huge bottleneck, especially on the Windows runner.

Idea

OCaml has a great incremental build experience. There's no reason why CI can't leverage this too.

In real tests, actions with a _build directory cache can be completely omitted if there are no changes. Even if there are some changes, the load is greatly reduced because only minimal work is done along the dependency tree.

The build state almost always changes. Therefore, it is important to update it infrequently to find a reasonable hit rate.

We can optionally perform cache writes only on master push events. We can even create a "warming job" that updates the shared cache entry once every day or two.

@cometkim cometkim changed the title experiment state cache for incremental build CI: experiment state cache for incremental build Mar 23, 2025
@cometkim cometkim requested a review from cknitt March 23, 2025 15:19
@cometkim cometkim force-pushed the ci-incremental-build branch from 36abebb to 378de02 Compare March 23, 2025 15:20
@cometkim
Copy link
Member Author

Well, there is less boosting than I expected. I may have missed a critical path that stores shared cache..

speed test 2
@cometkim cometkim force-pushed the ci-incremental-build branch from 378de02 to 3e8392c Compare March 23, 2025 15:30
speed test 1
@cometkim cometkim force-pushed the ci-incremental-build branch from fe29cef to 0f4c76c Compare March 23, 2025 15:54
@cometkim
Copy link
Member Author

Only 15~20% faster with no changes, not so incremental

@cknitt
Copy link
Member

cknitt commented Mar 23, 2025

Only 15~20% faster with no changes, not so incremental

Question is if it is worth it then?

Also, does it not depend on our opam cache, too? If the opam cache cannot be restored, it could be that we get a newer version of dune and so things might break?

@cometkim
Copy link
Member Author

Question is if it is worth it then?

before

image

after

image

It is 30s~50s on Windows runner so I guess so? It's a pretty nice one that was made in a few steps without much complexity.

Each cache entry is around 100 MiB, so, no storage pressure.

@cknitt
Copy link
Member

cknitt commented Mar 23, 2025

Yes, it's still a noticeable speedup 👍, I meant "worth it" in terms of CI build issues it might cause.

@cometkim
Copy link
Member Author

Yes, it's still a noticeable speedup 👍, I meant "worth it" in terms of CI build issues it might cause.

Let's see, this should be easy to revert anyway.

I'll make it cache based on the master merge.

@cknitt
Copy link
Member

cknitt commented Mar 23, 2025

Ok, let's go ahead then!

@cometkim cometkim marked this pull request as ready for review March 24, 2025 00:44
@cometkim cometkim merged commit 1696dda into rescript-lang:master Mar 24, 2025
20 checks passed
@cometkim cometkim deleted the ci-incremental-build branch March 24, 2025 00:55
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