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

perf(pnp): lazy initialize libzip #2921

Merged
merged 3 commits into from May 25, 2021
Merged

perf(pnp): lazy initialize libzip #2921

merged 3 commits into from May 25, 2021

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented May 23, 2021

What's the problem this PR addresses?

The PnP runtime always initializes Libzip even when it isn't going to be used, for example when @yarnpkg/core is asking @yarnpkg/plugin-pnp where packages are located.

Ref #2575

How did you fix it?

Lazy initialize libzip

Result

Tested on the Storybook repo using PnP

$ YARN_IGNORE_PATH=1 nodejs before.js && YARN_IGNORE_PATH=1 hyperfine -w 5 "nodejs before.js echo"
Benchmark #1: nodejs before.js echo
  Time (mean ± σ):      1.837 s ±  0.043 s    [User: 1.451 s, System: 0.209 s]
  Range (min … max):    1.804 s …  1.955 s    10 runs

$ YARN_IGNORE_PATH=1 nodejs after.js && YARN_IGNORE_PATH=1 hyperfine -w 5 "nodejs after.js echo"
Benchmark #1: nodejs after.js echo
  Time (mean ± σ):      1.750 s ±  0.010 s    [User: 1.304 s, System: 0.224 s]
  Range (min … max):    1.741 s …  1.775 s    10 runs

Checklist

  • I have read the Contributing Guide.
  • 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
Copy link
Member

arcanis commented May 24, 2021

I tried a little change to avoid storing different value types (object / functions) inside the same class property, as that sometimes can have adverse effects on engine optimizations (and this way each property has a single concern).

@merceyz
Copy link
Member Author

merceyz commented May 24, 2021

Sounds good 👍

@arcanis arcanis merged commit d2e592a into master May 25, 2021
@arcanis arcanis deleted the merceyz/perf/lazy-libzip branch May 25, 2021 08:12
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.

None yet

2 participants