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): reduce work done at runtime #1743

Merged
merged 7 commits into from
Aug 25, 2020
Merged

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented Aug 23, 2020

What's the problem this PR addresses?

The PnP runtime is doing a decent chunk of unnecessary work

How did you fix it?

  • Cache decompression result in ZipFS
  • Cache realPath result in ZipOpenFS
  • throttle refreshApiEntry

Result
When I tested this on #1669 just perf(fslib): get real path from ZipFS in ZipOpenFS alone reduces the build time from 2m28.568s to 1m34.816s (~54 seconds faster) (cc @alubbe)

Tested using

require('./.pnp.js').setup();
const { performance } = require('perf_hooks');

const start = performance.now();
for (let i = 0; i < 10000; i++) {
	require.resolve('typescript');
}
const end = performance.now();

console.log(end - start, 'ms');
time
master 7318ms
perf(fslib): cache decompression result 5235ms
perf(fslib): get real path from ZipFS in ZipOpenFS 2019ms
perf(pnp): throttle refreshApiEntry 1437ms

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I have verified that all automated PR checks pass.

@merceyz merceyz force-pushed the merceyz/perf-node-resolution branch from 16e4c7c to 6100e0e Compare August 23, 2020 14:47
@arcanis arcanis merged commit 6c6e9de into master Aug 25, 2020
@arcanis arcanis deleted the merceyz/perf-node-resolution branch August 25, 2020 08:31
@alubbe
Copy link
Contributor

alubbe commented Aug 26, 2020

Thanks @merceyz - this is awesome!

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.

3 participants