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

Improve resolver performance #6328

Merged
merged 1 commit into from May 21, 2021
Merged

Improve resolver performance #6328

merged 1 commit into from May 21, 2021

Conversation

devongovett
Copy link
Member

Utilizes the config loading mechanism used by other stuff for loading package.json files in the resolver, which has a per-build cache. Improves perf on the esbuild benchmark by ~8% for me.

@height
Copy link

height bot commented May 21, 2021

Link Height tasks by mentioning a task ID in the pull request title or description, commit messages, or comments.

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@@ -798,18 +803,27 @@ export default class NodeResolver {
return null;
}

let pkgKeys = ['source', 'alias'];
if (env.isBrowser()) pkgKeys.push('browser');
if (pkg.source && !Array.isArray(pkg.source)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Making this function use static references rather than dynamic property accesses seems to improve performance quite a bit

@@ -87,7 +88,7 @@ export async function loadConfig(
if (parse === false) {
config = configContent;
} else {
let parse = getParser(extname);
let parse = opts?.parser ?? getParser(extname);
Copy link
Member

Choose a reason for hiding this comment

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

That isn't part of the configCache cache key. But I also can't think of a case where you would want to parse a single file with 2 different parsers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, let's hope not 😉

@parcel-benchmark
Copy link

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.76s -63.00ms
Cached 401.00ms +5.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/index.0aef9bfa.js 2.00kb +0.00b 595.00ms -411.00ms 🚀
dist/modern/index.f9ed9bd6.js 2.00kb +0.00b 595.00ms -411.00ms 🚀
dist/modern/index.html 701.00b +0.00b 589.00ms +31.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.d5807e82.webp 102.94kb +0.00b 58.00ms +5.00ms ⚠️

React HackerNews ✅

Timings

Description Time Difference
Cold 10.90s -65.00ms
Cached 668.00ms -29.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

Bundle Size Difference Time Difference
dist/logo.24c8bf9e.png 274.00b +0.00b 60.00ms -3.00ms

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.25m -2.02s
Cached 2.89s -4.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.ebeb1fa8.js 2.60mb +8.00b ⚠️ 58.38s -939.00ms
dist/pdfRenderer.4dcd091a.js 411.56kb +0.00b 13.65s -2.06s 🚀
dist/media-viewer.1a792a5b.js 74.99kb +0.00b 12.65s +4.83s ⚠️
dist/card.d7dadce6.js 62.67kb +0.00b 12.64s +4.82s ⚠️
dist/Modal.2515e178.js 45.33kb -15.00b 🚀 3.12s -143.00ms
dist/esm.fb021904.js 33.24kb +0.00b 12.64s +4.82s ⚠️
dist/component.9e1648d9.js 6.82kb +0.00b 3.11s -160.00ms 🚀
dist/png-chunks-extract.26a58e9e.js 3.58kb +0.00b 3.11s -160.00ms 🚀
dist/date.13837189.js 1.86kb +0.00b 3.45s -184.00ms 🚀
dist/images.a51e31c2.js 1.80kb +0.00b 3.45s -184.00ms 🚀
dist/16.b8c83009.js 1.75kb +0.00b 3.10s -161.00ms 🚀
dist/16.f48613ba.js 1.68kb +0.00b 3.11s -160.00ms 🚀
dist/workerHasher.a70276d4.js 1.63kb +0.00b 13.47s +698.00ms ⚠️
dist/list-number.494da4e7.js 1.59kb +0.00b 3.45s -185.00ms 🚀
dist/status.8783408d.js 1.59kb +0.00b 3.45s -185.00ms 🚀
dist/code.677bd70c.js 1.51kb +0.00b 3.45s -184.00ms 🚀
dist/link.eecf8ee1.js 1.43kb +0.00b 3.45s -184.00ms 🚀
dist/16.0f105e82.js 1.40kb +0.00b 3.11s -161.00ms 🚀
dist/emoji.e0bb5bdd.js 1.36kb +0.00b 3.45s -184.00ms 🚀
dist/16.2475b7ab.js 1.35kb +0.00b 3.11s -160.00ms 🚀
dist/16.24ecf6d5.js 1.35kb +0.00b 3.11s -161.00ms 🚀
dist/16.f6f07bdf.js 1.29kb +0.00b 3.10s -161.00ms 🚀
dist/16.abb96752.js 1.25kb +0.00b 3.10s -161.00ms 🚀
dist/16.8a916ec3.js 1.22kb +0.00b 3.10s -161.00ms 🚀
dist/16.5ab0c52f.js 1.21kb +0.00b 3.10s -161.00ms 🚀
dist/16.17b379b7.js 1.20kb +0.00b 3.44s -183.00ms 🚀
dist/mention.7513d265.js 1.20kb +0.00b 3.45s -185.00ms 🚀
dist/layout.a2215d1e.js 1.18kb +0.00b 3.45s -184.00ms 🚀
dist/Modal.71b21a38.js 1.17kb +0.00b 3.10s -161.00ms 🚀
dist/16.dc7fba57.js 1.16kb +0.00b 3.11s -160.00ms 🚀
dist/16.4947d5d2.js 1.16kb +0.00b 3.10s -161.00ms 🚀
dist/divider.61f72909.js 1.16kb +0.00b 3.45s -184.00ms 🚀
dist/quote.ac356b63.js 1.15kb +0.00b 3.45s -185.00ms 🚀
dist/16.61848cd9.js 1.15kb +0.00b 3.11s -161.00ms 🚀
dist/16.f88600cd.js 1.15kb +0.00b 3.11s -161.00ms 🚀
dist/16.3457832f.js 1.15kb +0.00b 3.11s -160.00ms 🚀
dist/16.59da43e0.js 1.15kb +0.00b 3.11s -160.00ms 🚀
dist/action.03622130.js 1.13kb +0.00b 3.45s -184.00ms 🚀
dist/decision.e8963abf.js 1.12kb +0.00b 3.45s -184.00ms 🚀
dist/panel-warning.d87689fa.js 1.11kb +0.00b 3.45s -185.00ms 🚀
dist/16.71584d67.js 1.11kb +0.00b 3.11s -160.00ms 🚀
dist/list.452d2378.js 1.08kb +0.00b 3.45s -185.00ms 🚀
dist/16.d79d0001.js 1.07kb +0.00b 3.10s -161.00ms 🚀
dist/panel-error.2d1266a1.js 1.01kb +0.00b 3.45s -185.00ms 🚀
dist/panel.2fa2f198.js 1.01kb +0.00b 3.45s -185.00ms 🚀
dist/panel-success.8c4cf740.js 978.00b +0.00b 3.45s -185.00ms 🚀
dist/panel-note.aa22bfaa.js 974.00b +0.00b 3.45s -185.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.e73aa67b.js 2.60mb -2.00b 🚀 182.00ms -10.00ms 🚀
dist/pdf.worker.a3e718f4.js 727.98kb +0.00b 239.00ms +18.00ms ⚠️
dist/editorView.f9f13fe7.js 594.99kb +0.00b 239.00ms +19.00ms ⚠️
dist/pdfRenderer.cb376b35.js 411.56kb +0.00b 239.00ms +18.00ms ⚠️
dist/popup.38bccde5.js 209.85kb +0.00b 239.00ms +18.00ms ⚠️
dist/Toolbar.84a87bac.js 107.27kb +0.00b 239.00ms +19.00ms ⚠️
dist/media-viewer.4c392ce0.js 74.99kb +0.00b 239.00ms +18.00ms ⚠️
dist/card.2b3e2c3a.js 62.67kb +0.00b 207.00ms -13.00ms 🚀
dist/card.a208d637.js 60.71kb +0.00b 239.00ms +18.00ms ⚠️
dist/Modal.c9788e59.js 45.33kb -15.00b 🚀 166.00ms -9.00ms 🚀
dist/component.abdf86ef.js 24.95kb +0.00b 165.00ms -10.00ms 🚀
dist/js.85def1c2.js 17.33kb +0.00b 165.00ms -10.00ms 🚀
dist/ui.a7bbc1b6.js 14.94kb +0.00b 207.00ms -13.00ms 🚀
dist/smartMediaEditor.2c685a53.js 13.25kb +0.00b 239.00ms +19.00ms ⚠️
dist/dropzone.b3e2ed7e.js 12.15kb +0.00b 239.00ms +18.00ms ⚠️
dist/component.9e1648d9.js 6.82kb +0.00b 166.00ms -9.00ms 🚀
dist/card.006509f3.js 5.96kb +0.00b 207.00ms -14.00ms 🚀
dist/media-viewer.b1bdbe97.js 4.51kb +0.00b 239.00ms +18.00ms ⚠️
dist/media-viewer.9cc3198b.js 3.98kb +0.00b 239.00ms +18.00ms ⚠️
dist/png-chunks-extract.26a58e9e.js 3.58kb +0.00b 165.00ms -10.00ms 🚀
dist/index.f012b7ef.css 3.46kb +0.00b 242.00ms +19.00ms ⚠️
dist/dropzone.c754c683.js 3.29kb +0.00b 239.00ms +18.00ms ⚠️
dist/Modal.97b7b979.js 3.15kb +0.00b 166.00ms -9.00ms 🚀
dist/clipboard.29dcb8ca.js 2.93kb +0.00b 239.00ms +18.00ms ⚠️
dist/ResourcedEmojiComponent.425492a2.js 2.12kb +0.00b 207.00ms -13.00ms 🚀
dist/card.1653aa06.js 2.06kb +0.00b 239.00ms +18.00ms ⚠️
dist/browser.7e3a17d9.js 1.69kb +0.00b 239.00ms +18.00ms ⚠️
dist/workerHasher.a70276d4.js 1.63kb +0.00b 239.00ms +18.00ms ⚠️
dist/16.fe096c73.js 1.33kb +0.00b 164.00ms -19.00ms 🚀
dist/16.8a916ec3.js 1.22kb +0.00b 165.00ms -9.00ms 🚀
dist/Modal.71b21a38.js 1.17kb +0.00b 166.00ms -9.00ms 🚀
dist/16.4947d5d2.js 1.16kb +0.00b 165.00ms -9.00ms 🚀
dist/component.0faea072.js 1.12kb +0.00b 165.00ms -9.00ms 🚀
dist/media-card-analytics-error-boundary.92f81a75.js 1.12kb +0.00b 207.00ms -14.00ms 🚀
dist/16.71584d67.js 1.11kb +0.00b 165.00ms -9.00ms 🚀
dist/media-viewer-analytics-error-boundary.3b0c2a90.js 964.00b +0.00b 239.00ms +18.00ms ⚠️
dist/media-picker-analytics-error-boundary.da55e63c.js 964.00b +0.00b 239.00ms +18.00ms ⚠️
dist/media-card-analytics-error-boundary.0bc87153.js 960.00b +0.00b 207.00ms -13.00ms 🚀
dist/media-card-analytics-error-boundary.fd1b1d47.js 960.00b +0.00b 239.00ms +18.00ms ⚠️
dist/simpleHasher.5278a07e.js 641.00b +0.00b 239.00ms +18.00ms ⚠️
dist/index.html 119.00b +0.00b 100.00ms -18.00ms 🚀

Three.js ✅

Timings

Description Time Difference
Cold 7.66s -290.00ms
Cached 578.00ms -45.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

Bundle Size Difference Time Difference
dist/Three.js 579.69kb +0.00b 78.00ms +5.00ms ⚠️

Click here to view a detailed benchmark overview.

@devongovett devongovett merged commit edf7813 into v2 May 21, 2021
@devongovett devongovett deleted the resolver-perf branch May 21, 2021 23:19
lettertwo added a commit that referenced this pull request Jun 4, 2021
…raph

* bdo/buffer-backed-graph: (37 commits)
  Improve resolver performance (#6328)
  v2.0.0-beta.3.1
  Add it to the nightly release workflow as well
  Configure jemalloc page size for M1 (#6314)
  Update swc (#6307)
  Fix parcelDependencies
  v2.0.0-beta.3
  Update swc (#6289)
  Remove old AdjacencyList, serialize EfficientGraph in Graph, update BundleGraph to use new functions
  Babel ast location, diagnostic, and source location remapping (#6238)
  update contributing guide (#6293)
  Update sourcemap to rc-1.0 (#6279)
  Serve nearest index.html in case the applications has multiple index files (#6250)
  Allow bundling browserify bundles by replacing free requires with undefined (#6260)
  Upgrade flow to 0.151.0 (#6281)
  Use local require for `@babel/core` and `postcss` (#6264)
  Resolve helpers relative to JS transformer (#6278)
  Pure comment for $parcel$interopDefault (#6271)
  Don't transpile spread in JSX with modern targets (#6274)
  Update TS validator assertions (#6272)
  ...
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

4 participants