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

Add import helper to decrease ESM loader runtime footprint #9148

Merged
merged 10 commits into from
Jul 27, 2023

Conversation

mattcompiles
Copy link
Contributor

@mattcompiles mattcompiles commented Jul 24, 2023

↪️ Pull Request

While trying to optimize a very large entry bundle, we noticed that the loader runtime was using a lot of bytes via code repetition. This PR adds a new ESM helper that reduces the code footprint of bundle loading.

🚨 Test instructions

Existing tests cover this case and have been updated to reflect the changes.

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@mattcompiles mattcompiles requested review from devongovett and mischnic and removed request for devongovett July 24, 2023 23:57
@parcel-benchmark
Copy link

parcel-benchmark commented Jul 25, 2023

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 2.08s +55.00ms
Cached 321.00ms -61.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

React HackerNews ✅

Timings

Description Time Difference
Cold 5.51s -133.00ms
Cached 504.00ms +15.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/PermalinkedComment.b41e2791.js 4.07kb +0.00b 568.00ms +96.00ms ⚠️
dist/UserProfile.2a2fa310.js 1.51kb +0.00b 567.00ms +94.00ms ⚠️
dist/NotFound.13a965e5.js 399.00b +0.00b 567.00ms +94.00ms ⚠️
dist/logo.8dd07848.png 244.00b +0.00b 437.00ms +59.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.js 460.80kb +0.00b 1.23s -120.00ms 🚀
dist/PermalinkedComment.b41e2791.js 4.07kb +0.00b 452.00ms -23.00ms 🚀
dist/UserProfile.2a2fa310.js 1.51kb +0.00b 452.00ms -23.00ms 🚀

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 52.50s -690.00ms
Cached 2.72s -155.00ms 🚀

Cold Bundles

Bundle Size Difference Time Difference
dist/index.e9c11402.js 3.79mb -2.22kb 🚀 23.67s -448.00ms
dist/media-viewer.b0d6ca9e.js 537.60kb -155.00b 🚀 12.91s -3.69s 🚀
dist/popup.50441968.js 324.61kb -13.00b 🚀 17.12s +462.00ms
dist/ConfigPanelFieldsLoader.a2efc1d2.js 307.31kb -377.00b 🚀 12.93s +254.00ms
dist/EmojiPickerComponent.c4802d1e.js 189.88kb -69.00b 🚀 16.20s -448.00ms
dist/card.1f42b27b.js 140.38kb -69.00b 🚀 12.91s +252.00ms
dist/esm.7d57db8c.js 63.51kb -26.00b 🚀 17.12s +462.00ms
dist/esm.0d76f319.js 59.92kb -69.00b 🚀 12.91s +243.00ms
dist/component.b6d91d2b.js 57.90kb +91.00b ⚠️ 7.73s +245.00ms
dist/esm.c23dea85.js 39.62kb -69.00b 🚀 17.12s +466.00ms
dist/pdfRenderer.187ba54d.js 12.21kb +0.00b 12.91s -3.69s 🚀
dist/ru.896915b9.js 2.94kb +0.00b 12.91s +1.14s ⚠️
dist/codeViewerRenderer.f99075be.js 2.74kb +0.00b 12.91s -3.69s 🚀
dist/pt_BR.eccfad73.js 2.19kb +0.00b 9.23s -2.55s 🚀
dist/heading5.023a8f1f.js 1.36kb +0.00b 9.22s +1.36s ⚠️
dist/sk.101f1705.js 786.00b +0.00b 12.91s +1.14s ⚠️
dist/pt_PT.402f9c4e.js 765.00b +0.00b 9.23s -2.54s 🚀
dist/ro.a6eff34a.js 612.00b +0.00b 9.23s -2.54s 🚀
dist/index.html 240.00b +0.00b 9.24s +1.84s ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.e9c11402.js 3.79mb -2.22kb 🚀 24.14s +402.00ms
dist/media-viewer.b0d6ca9e.js 537.60kb -155.00b 🚀 16.34s +547.00ms
dist/popup.50441968.js 324.61kb -13.00b 🚀 16.33s +548.00ms
dist/ConfigPanelFieldsLoader.a2efc1d2.js 307.31kb -377.00b 🚀 11.79s +385.00ms
dist/EmojiPickerComponent.c4802d1e.js 189.88kb -69.00b 🚀 16.25s +517.00ms
dist/card.1f42b27b.js 140.38kb -69.00b 🚀 11.79s +384.00ms
dist/esm.7d57db8c.js 63.51kb -26.00b 🚀 16.33s +548.00ms
dist/esm.0d76f319.js 59.92kb -69.00b 🚀 11.79s +386.00ms
dist/component-lazy.1b33c14d.js 59.63kb +0.00b 7.87s -775.00ms 🚀
dist/component.b6d91d2b.js 57.90kb +91.00b ⚠️ 7.49s +57.00ms
dist/esm.c23dea85.js 39.62kb -69.00b 🚀 16.33s +543.00ms
dist/pl.5f36d63e.js 2.38kb +0.00b 8.81s -2.44s 🚀
dist/ro.a6eff34a.js 612.00b +0.00b 8.81s -2.59s 🚀

Three.js ✅

Timings

Description Time Difference
Cold 4.29s +59.00ms
Cached 421.00ms -0.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

Copy link
Contributor

@marcins marcins left a comment

Choose a reason for hiding this comment

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

LGTM.. as you mentioned, it does make the codegen logic a bit more messy with the conditionals, but I don't think that could be avoided without more major changes.

@mattcompiles mattcompiles merged commit 47b70a8 into v2 Jul 27, 2023
16 checks passed
@mattcompiles mattcompiles deleted the minify-esm-loader branch July 27, 2023 00:29
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