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

Speed up yarn installs in circle builds #19566

Merged
merged 1 commit into from
Aug 11, 2020

Conversation

rickhanlonii
Copy link
Member

@rickhanlonii rickhanlonii commented Aug 9, 2020

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

Screen Shot 2020-08-09 at 11 45 09 AM

After

Screen Shot 2020-08-09 at 11 45 25 AM

We also improved overall times (there's a lot of variance here, but the trend is accurate):

Before

Screen Shot 2020-08-09 at 11 42 17 AM

After

Screen Shot 2020-08-09 at 11 47 07 AM

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Aug 9, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 9, 2020

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:

Sandbox Source
React Configuration

@sizebot
Copy link

sizebot commented Aug 9, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against 9ef19ff

@sizebot
Copy link

sizebot commented Aug 9, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against 9ef19ff

- v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v2-node-{{ arch }}-{{ .Branch }}-
- v2-node-{{ arch }}-
- &run_yarn
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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 up yarn install across all jobs and PRs with the same yarn.lock. It's only restored in the setup job.
  • node_modules: Once the setup job installs a node_modules directory, we cache node_modules to use in every child job. This means that we only need to run yarn install once in the setup 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.

Copy link
Contributor

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).

@rickhanlonii rickhanlonii changed the title [WIP] Speed up circle builds with yarn [WIP] Speed up yarn installs in circle builds Aug 9, 2020
@rickhanlonii rickhanlonii changed the title [WIP] Speed up yarn installs in circle builds Speed up yarn installs in circle builds Aug 9, 2020
@rickhanlonii rickhanlonii requested a review from acdlite August 9, 2020 15:47
@rickhanlonii rickhanlonii marked this pull request as ready for review August 9, 2020 15:47
Copy link
Contributor

@acdlite acdlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍 Excellent!

@rickhanlonii rickhanlonii merged commit c8d9b88 into facebook:master Aug 11, 2020
@rickhanlonii rickhanlonii deleted the rh-circle-yarn branch August 11, 2020 18:05
koto pushed a commit to koto/react that referenced this pull request Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants