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

Improves boot time #4261

Merged
merged 15 commits into from
Mar 26, 2022
Merged

Improves boot time #4261

merged 15 commits into from
Mar 26, 2022

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Mar 24, 2022

What's the problem this PR addresses?

Yarn is currently a little slow to start. Even a yarn --version takes ~280ms on my (slow) machine.

How did you fix it?

This diff implements bundle splitting by adding a --split option to the bundle generator that, when used, causes it to emit a self-extracting file that unpacks the chunks on disk then runs them. In practice it isn't more performant, so it's unlikely to be enabled by default, but having this capability can be useful for experimentation purposes.

A few other runtime speed improvements not directly related to it are also implemented.

  • Reimplemented Tinylogic using Pegjs rather than Chevrotine
  • Changed some of the got import into type imports
  • Removed yup from the modules exposed to plugins (was legacy)
YARN_IGNORE_PATH=1 hyperfine -w 1 "node ./master.cjs --version" "node ./after.cjs --version"
Benchmark 1: node ./master.cjs --version
  Time (mean ± σ):     214.8 ms ±   1.1 ms    [User: 228.5 ms, System: 18.1 ms]
  Range (min … max):   213.4 ms … 216.9 ms    13 runs

Benchmark 2: node ./after.cjs --version
  Time (mean ± σ):     178.0 ms ±   1.3 ms    [User: 189.2 ms, System: 20.0 ms]
  Range (min … max):   175.7 ms … 180.8 ms    16 runs

Summary
  'node ./after.cjs --version' ran
    1.21 ± 0.01 times faster than 'node ./master.cjs --version'

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis arcanis added the major label Mar 24, 2022
@arcanis arcanis requested a review from merceyz March 24, 2022 15:29
Copy link
Member

@merceyz merceyz left a comment

Choose a reason for hiding this comment

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

Moved the builtin patch behind lazy imports
Moved the worker hook behind a lazy import
Moved the PnP hook behind a lazy import

Without bundle splitting these can be reverted as they are just functions

@arcanis arcanis requested a review from merceyz March 25, 2022 16:28
merceyz
merceyz previously approved these changes Mar 25, 2022
@merceyz
Copy link
Member

merceyz commented Mar 25, 2022

I updated the benchmark results to the current state of this PR

@merceyz merceyz merged commit b730176 into master Mar 26, 2022
@merceyz merceyz deleted the mael/bundle-splitting branch March 26, 2022 14:42
@merceyz merceyz added this to the 4.0.0 milestone May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants