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

Fix perf of lazy mode glob matches #9260

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

marcins
Copy link
Contributor

@marcins marcins commented Sep 21, 2023

↪️ Pull Request

The "selective lazy" implementation used isGlobMatch to determine whether a particular asset was "lazy" or not - this turns out was inefficient because for every glob it would be compiled to a regex for every asset. This regressed performance of incremental changes significantly with a large asset graph.

This change instead uses the globToRegex util to pre-compile the globs at option resolution time, and then does regex matches against these pre-compiled regexes. This has fixed the performance issue in our usage.

🚨 Test instructions

  • existing integration tests still pass
  • we've tested in our very large application and the performance has improved for 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

Copy link
Contributor

@mattcompiles mattcompiles left a comment

Choose a reason for hiding this comment

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

🚀

@parcel-benchmark
Copy link

parcel-benchmark commented Sep 21, 2023

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.43s +16.00ms
Cached 272.00ms -10.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

React HackerNews ✅

Timings

Description Time Difference
Cold 3.85s -18.00ms
Cached 385.00ms -5.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/PermalinkedComment.3145598b.js 3.94kb +0.00b 310.00ms -308.00ms 🚀
dist/UserProfile.b37bbaff.js 1.38kb +0.00b 310.00ms -308.00ms 🚀
dist/NotFound.c08212ea.js 265.00b +0.00b 309.00ms -309.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.js 460.91kb +0.00b 939.00ms -50.00ms 🚀

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 33.06s -1.91s 🚀
Cached 2.13s -144.00ms 🚀

Cold Bundles

Bundle Size Difference Time Difference
dist/index.c9a8b20f.js 3.79mb +0.00b 16.26s -1.33s 🚀
dist/pdfRenderer.4cf5cffc.js 1.11mb +0.00b 11.68s -1.65s 🚀
dist/editorView.3f952334.js 619.77kb +0.00b 13.05s -1.07s 🚀
dist/refractor.61b4c5e1.js 601.68kb +0.00b 10.36s -1.50s 🚀
dist/media-viewer.bc1a2415.js 537.32kb +0.00b 7.68s -580.00ms 🚀
dist/popup.32b3d0ef.js 324.46kb +0.00b 10.35s -1.50s 🚀
dist/ConfigPanelFieldsLoader.8648eeee.js 306.81kb +0.00b 7.68s -580.00ms 🚀
dist/EmojiPickerComponent.c199902f.js 189.68kb +0.00b 10.29s -1.54s 🚀
dist/card.3521c96b.js 140.18kb +0.00b 7.68s -580.00ms 🚀
dist/ConfigPanelFieldsLoader.1a016f33.js 82.96kb +0.00b 10.29s -1.55s 🚀
dist/mobile-upload.0917d4f0.js 66.50kb +0.00b 4.38s -503.00ms 🚀
dist/esm.5b5f7c9f.js 63.36kb +0.00b 10.35s -1.50s 🚀
dist/ElementBrowser.c496dd44.js 62.20kb +0.00b 7.68s -580.00ms 🚀
dist/archive.fe044de4.js 60.16kb +0.00b 10.35s -1.50s 🚀
dist/esm.ce3e12df.js 59.72kb +0.00b 7.68s -586.00ms 🚀
dist/component-lazy.aeb22f50.js 59.50kb +0.00b 5.18s -573.00ms 🚀
dist/component.508d12ab.js 57.88kb +0.00b 4.38s -502.00ms 🚀
dist/DatePicker.f4cb448f.js 47.85kb +0.00b 5.18s -598.00ms 🚀
dist/esm.f9edadb2.js 39.42kb +0.00b 10.35s -1.50s 🚀
dist/Modal.f90b31a7.js 28.20kb +0.00b 4.38s -502.00ms 🚀
dist/DatePicker.412226fe.js 25.02kb +0.00b 5.18s -598.00ms 🚀
dist/smartMediaEditor.226eb0f2.js 21.76kb +0.00b 10.35s -1.50s 🚀
dist/esm.a421c1ca.js 20.52kb +0.00b 10.35s -1.50s 🚀
dist/component.d038388b.js 18.68kb +0.00b 4.39s -501.00ms 🚀
dist/js.9cb9c5be.js 17.21kb +0.00b 4.38s -506.00ms 🚀
dist/ConfigPanelFieldsLoader.8efb299e.js 15.82kb +0.00b 7.68s -580.00ms 🚀
dist/ui.8e1e1200.js 14.49kb +0.00b 7.68s -580.00ms 🚀
dist/ConfigPanelFieldsLoader.f78f3b60.js 13.65kb +0.00b 7.68s -580.00ms 🚀
dist/dropzone.452cdf0e.js 13.48kb +0.00b 10.35s -1.50s 🚀
dist/pdfRenderer.6335b9a2.js 12.08kb +0.00b 7.68s -580.00ms 🚀
dist/dropzone.eff4ce1e.js 11.51kb +0.00b 10.35s -1.50s 🚀
dist/Toolbar.759db587.js 9.40kb +0.00b 10.35s -1.50s 🚀
dist/clipboard.121b0510.js 7.94kb +0.00b 10.35s -1.50s 🚀
dist/mobile-upload.86840439.js 7.86kb +0.00b 4.38s -502.00ms 🚀
dist/mobile-upload.c687ddb2.js 7.86kb +0.00b 7.68s -580.00ms 🚀
dist/mobile-upload.e9eb996a.js 7.86kb +0.00b 7.68s -586.00ms 🚀
dist/mobile-upload.d7818b6e.js 7.86kb +0.00b 10.35s -1.50s 🚀
dist/index.runtime.1064c960.js 7.29kb +0.00b 10.36s -1.49s 🚀
dist/browser.857fa69b.js 7.20kb +0.00b 10.35s -1.50s 🚀
dist/index.b16227d6.css 4.08kb +0.00b 10.37s -1.51s 🚀
dist/Modal.efe95f7f.js 3.87kb +0.00b 4.38s -502.00ms 🚀
dist/component.342752e9.js 3.22kb +0.00b 4.38s -502.00ms 🚀
dist/media-viewer-analytics-error-boundary.54c54975.js 3.19kb +0.00b 10.35s -1.50s 🚀
dist/media-picker-analytics-error-boundary.6a30027d.js 3.19kb +0.00b 10.35s -1.50s 🚀
dist/media-card-analytics-error-boundary.b80de757.js 3.19kb +0.00b 10.36s -1.50s 🚀
dist/png-chunks-extract.01ed8f60.js 3.06kb +0.00b 4.38s -506.00ms 🚀
dist/ru.aaea8ba6.js 2.81kb +0.00b 7.68s -581.00ms 🚀
dist/uk.5d2e97bd.js 2.76kb +0.00b 7.68s -581.00ms 🚀
dist/codeViewerRenderer.7d374cd5.js 2.61kb +0.00b 10.35s +2.10s ⚠️
dist/th.df60823c.js 2.60kb +0.00b 7.68s -581.00ms 🚀
dist/ResourcedEmojiComponent.184d62aa.js 2.47kb +0.00b 5.18s -598.00ms 🚀
dist/pl.f089a702.js 2.25kb +0.00b 5.18s -598.00ms 🚀
dist/cs.c0d356c1.js 2.23kb +0.00b 5.18s -597.00ms 🚀
dist/de.1a167b65.js 2.17kb +0.00b 5.18s -597.00ms 🚀
dist/fr.6cc5b166.js 2.12kb +0.00b 5.18s -598.00ms 🚀
dist/es.38a88442.js 2.12kb +0.00b 5.18s -598.00ms 🚀
dist/hu.026ff8dd.js 2.10kb +0.00b 5.18s -598.00ms 🚀
dist/fi.84541eb7.js 2.09kb +0.00b 5.18s -599.00ms 🚀
dist/ja.a9cd0bd6.js 2.09kb +0.00b 5.18s -598.00ms 🚀
dist/vi.3e6d5bcb.js 2.09kb +0.00b 7.68s -581.00ms 🚀
dist/pt_BR.1db6fd92.js 2.06kb +0.00b 5.18s -599.00ms 🚀
dist/tr.4de346b9.js 2.03kb +0.00b 7.68s -581.00ms 🚀
dist/ko.954590a1.js 1.97kb +0.00b 5.18s -598.00ms 🚀
dist/sv.b893ead3.js 1.97kb +0.00b 7.68s -581.00ms 🚀
dist/it.5c7edaaf.js 1.97kb +0.00b 5.18s -598.00ms 🚀
dist/nb.7f52770f.js 1.96kb +0.00b 5.18s -598.00ms 🚀
dist/date.6db71354.js 1.94kb +0.00b 4.62s -569.00ms 🚀
dist/da.23f674ea.js 1.94kb +0.00b 5.18s -597.00ms 🚀
dist/nl.fd54481e.js 1.94kb +0.00b 5.18s -598.00ms 🚀
dist/images.21df3a8f.js 1.90kb +0.00b 4.62s -569.00ms 🚀
dist/zh_TW.3d130b76.js 1.85kb +0.00b 7.68s -580.00ms 🚀
dist/zh.fb21f066.js 1.83kb +0.00b 7.68s -580.00ms 🚀
dist/feedback.647089cf.js 1.76kb +0.00b 5.18s -598.00ms 🚀
dist/status.be4e3842.js 1.67kb +0.00b 4.62s -569.00ms 🚀
dist/code.64a301f3.js 1.56kb +0.00b 4.62s -568.00ms 🚀
dist/workerHasher.e01f8bcf.js 1.56kb +0.00b 4.38s -505.00ms 🚀
dist/workerHasher.322762e4.js 1.56kb +0.00b 7.68s -580.00ms 🚀
dist/workerHasher.8fdadeba.js 1.56kb +0.00b 7.68s -580.00ms 🚀
dist/workerHasher.65b703b7.js 1.56kb +0.00b 10.35s -1.50s 🚀
dist/workerHasher.100ea0bf.js 1.56kb +0.00b 10.35s -1.50s 🚀
dist/workerHasher.81697bdc.js 1.56kb +0.00b 10.35s -1.50s 🚀
dist/list-number.e454dc8e.js 1.47kb +0.00b 4.62s -570.00ms 🚀
dist/heading6.eae34279.js 1.36kb +0.00b 5.18s -599.00ms 🚀
dist/16.a4c7368c.js 1.35kb +0.00b 4.39s -502.00ms 🚀
dist/heading3.82217cc7.js 1.35kb +0.00b 4.62s -570.00ms 🚀
dist/16.347f2ad3.js 1.28kb +0.00b 4.38s -502.00ms 🚀
dist/link.ef87b7d4.js 1.28kb +0.00b 4.62s -570.00ms 🚀
dist/emoji.f9caa19f.js 1.25kb +0.00b 4.62s -569.00ms 🚀
dist/heading5.20183aa6.js 1.23kb +0.00b 5.18s -599.00ms 🚀
dist/expand.e7437f2e.js 1.18kb +0.00b 5.18s -598.00ms 🚀
dist/heading2.a43a84af.js 1.17kb +0.00b 4.62s -570.00ms 🚀
dist/heading4.bc1ea347.js 1.12kb +0.00b 4.62s -570.00ms 🚀
dist/mention.12d040af.js 1.08kb +0.00b 4.62s -569.00ms 🚀
dist/layout.467fc22b.js 1.04kb +0.00b 4.62s -570.00ms 🚀
dist/divider.875eeb9b.js 1.04kb +0.00b 4.62s -569.00ms 🚀
dist/action.4747cf93.js 1.02kb +0.00b 4.62s -568.00ms 🚀
dist/heading1.a2a2d506.js 1.01kb +0.00b 4.62s -569.00ms 🚀
dist/16.1d939d76.js 1.00kb +0.00b 4.39s -502.00ms 🚀
dist/list.a024d070.js 1007.00b +0.00b 4.62s -570.00ms 🚀
dist/quote.790784b0.js 1007.00b +0.00b 4.62s -569.00ms 🚀
dist/decision.f09ec841.js 988.00b +0.00b 4.62s -569.00ms 🚀
dist/16.92be0d97.js 976.00b +0.00b 4.38s -502.00ms 🚀
dist/16.5befcdea.js 976.00b +0.00b 4.38s -502.00ms 🚀
dist/panel-warning.b246d7d3.js 964.00b +0.00b 4.62s -569.00ms 🚀
dist/16.ef2df2b6.js 956.00b +0.00b 4.38s -502.00ms 🚀
dist/16.792a9556.js 951.00b +0.00b 4.62s -569.00ms 🚀
dist/table.348d2eb0.js 942.00b +0.00b 4.62s -569.00ms 🚀
dist/16.01cdc55d.js 916.00b +0.00b 4.40s -486.00ms 🚀
dist/panel.bc621c8f.js 883.00b +0.00b 4.62s -569.00ms 🚀
dist/panel-error.9152f129.js 860.00b +0.00b 4.62s -569.00ms 🚀
dist/16.8fc349c9.js 858.00b +0.00b 4.40s -487.00ms 🚀
dist/16.c5423dbe.js 830.00b +0.00b 4.39s -502.00ms 🚀
dist/16.1be49b4b.js 823.00b +0.00b 4.38s -503.00ms 🚀
dist/16.eb6f51c1.js 817.00b +0.00b 4.62s -568.00ms 🚀
dist/panel-success.25629fed.js 801.00b +0.00b 4.62s -569.00ms 🚀
dist/panel-note.f23dd251.js 791.00b +0.00b 4.62s -569.00ms 🚀
dist/16.924dd2e3.js 778.00b +0.00b 4.39s -502.00ms 🚀
dist/16.01e372d3.js 772.00b +0.00b 4.38s -502.00ms 🚀
dist/16.0cd21a5f.js 772.00b +0.00b 4.38s -503.00ms 🚀
dist/16.a0490963.js 771.00b +0.00b 4.38s -503.00ms 🚀
dist/16.a5f45cdb.js 770.00b +0.00b 4.38s -502.00ms 🚀
dist/16.bc1a05f3.js 769.00b +0.00b 4.38s -503.00ms 🚀
dist/16.d9cd1f88.js 742.00b +0.00b 4.62s -568.00ms 🚀
dist/16.e3d16653.js 721.00b +0.00b 4.38s -502.00ms 🚀
dist/16.592b5fd3.js 693.00b +0.00b 4.39s -502.00ms 🚀
dist/sk.1a0c584e.js 652.00b +0.00b 7.68s -581.00ms 🚀
dist/pt_PT.16308ef8.js 631.00b +0.00b 5.18s -598.00ms 🚀
dist/et.3d28125f.js 629.00b +0.00b 5.18s -598.00ms 🚀
dist/simpleHasher.329400f6.js 585.00b +0.00b 4.38s -506.00ms 🚀
dist/simpleHasher.0488d56a.js 585.00b +0.00b 7.68s -580.00ms 🚀
dist/simpleHasher.180c1d91.js 585.00b +0.00b 7.68s -581.00ms 🚀
dist/simpleHasher.88f1b387.js 585.00b +0.00b 10.35s -1.50s 🚀
dist/simpleHasher.2c36efc2.js 585.00b +0.00b 10.35s -1.50s 🚀
dist/simpleHasher.37be2994.js 585.00b +0.00b 10.35s -1.50s 🚀
dist/is.b5f0121f.js 491.00b +0.00b 5.18s -598.00ms 🚀
dist/ro.ee42c980.js 478.00b +0.00b 7.68s +1.89s ⚠️
dist/en_GB.f6c48dd5.js 468.00b +0.00b 5.18s -598.00ms 🚀
dist/en.b8f14ffb.js 465.00b +0.00b 5.18s -597.00ms 🚀
dist/index.html 248.00b +0.00b 10.40s -1.60s 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.c9a8b20f.js 3.79mb +0.00b 17.54s +1.01s ⚠️
dist/editorView.3f952334.js 619.77kb +0.00b 14.80s +1.20s ⚠️
dist/refractor.61b4c5e1.js 601.68kb +0.00b 12.31s +970.00ms ⚠️
dist/media-viewer.bc1a2415.js 537.32kb +0.00b 12.28s +4.06s ⚠️
dist/popup.32b3d0ef.js 324.46kb +0.00b 12.31s +970.00ms ⚠️
dist/EmojiPickerComponent.c199902f.js 189.68kb +0.00b 12.29s +961.00ms ⚠️
dist/ConfigPanelFieldsLoader.1a016f33.js 82.96kb +0.00b 12.29s +1.99s ⚠️
dist/esm.5b5f7c9f.js 63.36kb +0.00b 12.31s +969.00ms ⚠️
dist/archive.fe044de4.js 60.16kb +0.00b 12.31s +970.00ms ⚠️
dist/esm.f9edadb2.js 39.42kb +0.00b 12.31s +969.00ms ⚠️
dist/smartMediaEditor.226eb0f2.js 21.76kb +0.00b 12.31s +970.00ms ⚠️
dist/esm.a421c1ca.js 20.52kb +0.00b 12.31s +970.00ms ⚠️
dist/dropzone.452cdf0e.js 13.48kb +0.00b 12.31s +969.00ms ⚠️
dist/dropzone.eff4ce1e.js 11.51kb +0.00b 12.31s +969.00ms ⚠️
dist/Toolbar.759db587.js 9.40kb +0.00b 12.31s +971.00ms ⚠️
dist/clipboard.121b0510.js 7.94kb +0.00b 12.31s +969.00ms ⚠️
dist/mobile-upload.d7818b6e.js 7.86kb +0.00b 12.31s +970.00ms ⚠️
dist/index.runtime.1064c960.js 7.29kb +0.00b 12.33s +991.00ms ⚠️
dist/browser.857fa69b.js 7.20kb +0.00b 12.31s +969.00ms ⚠️
dist/index.b16227d6.css 4.08kb +0.00b 12.35s +995.00ms ⚠️
dist/media-viewer-analytics-error-boundary.54c54975.js 3.19kb +0.00b 12.31s +970.00ms ⚠️
dist/media-picker-analytics-error-boundary.6a30027d.js 3.19kb +0.00b 12.31s +969.00ms ⚠️
dist/media-card-analytics-error-boundary.b80de757.js 3.19kb +0.00b 12.31s +970.00ms ⚠️
dist/codeViewerRenderer.7d374cd5.js 2.61kb +0.00b 12.29s +943.00ms ⚠️
dist/workerHasher.65b703b7.js 1.56kb +0.00b 12.31s +969.00ms ⚠️
dist/workerHasher.100ea0bf.js 1.56kb +0.00b 12.31s +969.00ms ⚠️
dist/workerHasher.81697bdc.js 1.56kb +0.00b 12.31s +969.00ms ⚠️
dist/simpleHasher.88f1b387.js 585.00b +0.00b 12.31s +969.00ms ⚠️
dist/simpleHasher.2c36efc2.js 585.00b +0.00b 12.31s +969.00ms ⚠️
dist/simpleHasher.37be2994.js 585.00b +0.00b 12.31s +969.00ms ⚠️
dist/index.html 248.00b +0.00b 12.39s +1.02s ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 2.75s -29.00ms
Cached 292.00ms -30.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@marcins marcins force-pushed the mszczepanski/improve-lazy-glob-performance branch from 18a8e9b to 33b955a Compare September 21, 2023 05:43
@marcins marcins closed this Sep 21, 2023
@marcins marcins deleted the mszczepanski/improve-lazy-glob-performance branch September 21, 2023 06:20
@marcins marcins restored the mszczepanski/improve-lazy-glob-performance branch September 21, 2023 06:20
@marcins marcins reopened this Sep 21, 2023
@marcins marcins merged commit df8f72b into v2 Sep 21, 2023
29 of 31 checks passed
@marcins marcins deleted the mszczepanski/improve-lazy-glob-performance branch September 21, 2023 06:24
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