-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Speed up yarn installs in circle builds #19566
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 9ef19ff:
|
233c161
to
3950c18
Compare
3950c18
to
9ef19ff
Compare
- v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }} | ||
- v2-node-{{ arch }}-{{ .Branch }}- | ||
- v2-node-{{ arch }}- | ||
- &run_yarn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this alias because a yarn install should only be necessary in the setup
job.
@@ -7,17 +7,11 @@ aliases: | |||
- &environment | |||
TZ: /usr/share/zoneinfo/America/Los_Angeles | |||
|
|||
- &restore_yarn_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to clarify what this is actually restoring, which is the node_modules
directory now.
# This cache key is per branch, a yarn install in setup is required. | ||
key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-node-modules | ||
paths: | ||
- node_modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're now saving two different caches:
- yarn: This is the global yarn node_module cache to be used only by the
setup
job to speed upyarn install
across all jobs and PRs with the sameyarn.lock
. It's only restored in the setup job. - node_modules: Once the
setup
job installs a node_modules directory, we cachenode_modules
to use in every child job. This means that we only need to runyarn install
once in thesetup
and never for the child jobs.
The node_modules
cache key is per branch just so that it's scoped per PR. Caches in circle are global and immutable so this just prevents unexpected collisions and should not change performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be modified to also save nested node_modules
paths, to avoid causing differences on CI when there are dependency differences between modules (e.g. like the failing tests on #21641).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍 Excellent!
Overview
This PR optimizes the circle config so that we run exactly one
yarn install
across the entire workflow, which is itself cached, and then uses a node_modules cache for all subsequent jobs.Perf wins
In the parallel jobs you can now see that we completely removed the
yarn install
step, which shave 10-60s off each of those, giving feedback up to a minute faster:Before
After
We also improved overall times (there's a lot of variance here, but the trend is accurate):
Before
After