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

Use LMDB as a cache backend #5509

Merged
merged 19 commits into from
May 28, 2021
Merged

Use LMDB as a cache backend #5509

merged 19 commits into from
May 28, 2021

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Dec 21, 2020

This implements support for multiple cache backends, and adds an LMDB based implementation. LMDB is a very fast embedded key/value store written in C. Rather than write each cache entry to the file system separately, it uses one large memory-mapped file which is asynchronously written to disk. Overall this results in ~15% faster builds, and is even faster than using our own MemoryFS instead of NodeFS.

This PR automatically enables the LMDB-based cache when using a NodeFS, otherwise it falls back to the existing FS-based cache implementation.

Close T-265

@height
Copy link

height bot commented Dec 21, 2020

This pull request has been linked to and will mark 1 task as "Done" when merged:

💡Tip: You can link multiple Height tasks to a pull request.

@parcel-benchmark
Copy link

parcel-benchmark commented Dec 21, 2020

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.98s -79.00ms
Cached 429.00ms -8.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/modern/parcel.d5807e82.webp 102.94kb +0.00b 583.00ms -44.00ms 🚀
dist/legacy/index.a6466710.js 2.00kb +0.00b 1.10s +407.00ms ⚠️
dist/modern/index.4f9cafee.js 2.00kb +0.00b 1.10s +408.00ms ⚠️
dist/legacy/index.html 701.00b +0.00b 608.00ms -42.00ms 🚀
dist/modern/index.html 701.00b +0.00b 608.00ms -42.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.d5807e82.webp 102.94kb +0.00b 87.00ms +29.00ms ⚠️
dist/modern/parcel.d5807e82.webp 102.94kb +0.00b 55.00ms -24.00ms 🚀
dist/legacy/index.a6466710.js 2.00kb +0.00b 87.00ms +6.00ms ⚠️
dist/legacy/index.html 701.00b +0.00b 88.00ms +7.00ms ⚠️
dist/legacy/index.ec8349b2.css 77.00b +0.00b 88.00ms +7.00ms ⚠️

React HackerNews ✅

Timings

Description Time Difference
Cold 12.07s -351.00ms
Cached 688.00ms -57.00ms 🚀

Cold Bundles

Bundle Size Difference Time Difference
dist/PermalinkedComment.0c75a695.js 4.19kb +0.00b 6.58s +6.12s ⚠️
dist/UserProfile.031c1548.js 1.56kb +0.00b 6.58s +6.12s ⚠️
dist/NotFound.c3254f12.js 417.00b +0.00b 6.58s +6.12s ⚠️
dist/logo.24c8bf9e.png 274.00b +0.00b 22.00ms -74.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.js 491.15kb +0.00b 97.00ms -10.00ms 🚀
dist/PermalinkedComment.0c75a695.js 4.19kb +0.00b 97.00ms -10.00ms 🚀
dist/UserProfile.031c1548.js 1.56kb +0.00b 97.00ms -10.00ms 🚀
dist/NotFound.c3254f12.js 417.00b +0.00b 97.00ms -10.00ms 🚀
dist/logo.24c8bf9e.png 274.00b +0.00b 61.00ms -18.00ms 🚀

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.41m -408.00ms
Cached 3.27s +218.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/index.5f5a942c.js 2.60mb -3.00b 🚀 33.62s -32.27s 🚀
dist/pdf.worker.a3e718f4.js 727.98kb +0.00b 55.36s +18.02s ⚠️
dist/editorView.37b11157.js 594.99kb +0.00b 1.11m +29.02s ⚠️
dist/pdfRenderer.4dcd091a.js 411.56kb +0.00b 1.10m +47.99s ⚠️
dist/popup.868dd13c.js 209.85kb +0.00b 1.10m +47.95s ⚠️
dist/EmojiPickerComponent.ebf1688d.js 147.28kb +0.00b 55.36s +39.67s ⚠️
dist/Toolbar.7ad3a942.js 107.27kb +0.00b 1.11m +48.61s ⚠️
dist/media-viewer.abeacbd4.js 74.99kb +0.00b 1.10m +56.87s ⚠️
dist/card.2833fa08.js 62.67kb +0.00b 1.10m +56.87s ⚠️
dist/card.e07b12e3.js 60.71kb +0.00b 1.10m +56.88s ⚠️
dist/Modal.a7c870ec.js 45.33kb +0.00b 33.55s +29.95s ⚠️
dist/component.4b060332.js 37.59kb +0.00b 33.55s +29.95s ⚠️
dist/esm.dd6f087c.js 33.24kb +0.00b 1.10m +56.88s ⚠️
dist/component.6fad7538.js 24.95kb +0.00b 33.55s +29.95s ⚠️
dist/DatePicker.7e4cfd48.js 22.99kb +0.00b 55.22s +46.51s ⚠️
dist/js.85def1c2.js 17.33kb +0.00b 33.28s +29.68s ⚠️
dist/ui.8bcf31ff.js 14.94kb +0.00b 1.10m +57.01s ⚠️
dist/smartMediaEditor.147dc050.js 13.25kb +0.00b 1.10m +48.09s ⚠️
dist/dropzone.cbad3252.js 12.15kb +0.00b 1.10m +57.00s ⚠️
dist/workerHasher.95f27d4e.js 11.81kb +0.00b 55.36s +46.65s ⚠️
dist/component.9e1648d9.js 6.82kb +0.00b 33.28s +29.68s ⚠️
dist/card.006509f3.js 5.96kb +0.00b 1.10m +57.01s ⚠️
dist/media-viewer.b1bdbe97.js 4.51kb +0.00b 55.36s +46.65s ⚠️
dist/media-viewer.9cc3198b.js 3.98kb +0.00b 55.36s +46.65s ⚠️
dist/EmojiPickerComponent.20965f41.js 3.72kb +0.00b 1.10m +57.01s ⚠️
dist/png-chunks-extract.26a58e9e.js 3.58kb +0.00b 33.28s +29.70s ⚠️
dist/index.44263fbe.css 3.46kb +0.00b 1.11m +28.48s ⚠️
dist/dropzone.6e6a4109.js 3.29kb +0.00b 1.10m +56.99s ⚠️
dist/Modal.97b7b979.js 3.15kb +0.00b 33.55s +29.95s ⚠️
dist/clipboard.68ddfab7.js 2.93kb +0.00b 1.10m +57.02s ⚠️
dist/16.ca688077.js 2.36kb +0.00b 33.55s +29.95s ⚠️
dist/ResourcedEmojiComponent.425492a2.js 2.12kb +0.00b 1.10m +57.01s ⚠️
dist/card.1653aa06.js 2.06kb +0.00b 55.36s +46.63s ⚠️
dist/date.13837189.js 1.86kb +0.00b 35.14s +31.16s ⚠️
dist/images.a51e31c2.js 1.80kb +0.00b 35.14s +31.16s ⚠️
dist/feedback.a4084b43.js 1.77kb +0.00b 54.68s +50.64s ⚠️
dist/16.b8c83009.js 1.75kb +0.00b 33.28s +29.70s ⚠️
dist/browser.c9706d38.js 1.69kb +0.00b 1.10m +57.02s ⚠️
dist/16.f48613ba.js 1.68kb +0.00b 33.28s +29.70s ⚠️
dist/workerHasher.a91c28d5.js 1.63kb +0.00b 1.10m +57.01s ⚠️
dist/workerHasher.a70276d4.js 1.63kb +0.00b 1.10m +56.88s ⚠️
dist/list-number.494da4e7.js 1.59kb +0.00b 35.14s +31.16s ⚠️
dist/status.8783408d.js 1.59kb +0.00b 35.14s +31.11s ⚠️
dist/code.677bd70c.js 1.51kb +0.00b 35.14s +31.16s ⚠️
dist/heading6.2df789d9.js 1.51kb +0.00b 54.68s +50.64s ⚠️
dist/heading3.99e77e15.js 1.49kb +0.00b 54.68s +50.64s ⚠️
dist/link.eecf8ee1.js 1.43kb +0.00b 35.14s +31.16s ⚠️
dist/16.0f105e82.js 1.40kb +0.00b 33.28s +29.70s ⚠️
dist/heading5.c9eff376.js 1.38kb +0.00b 54.68s +50.64s ⚠️
dist/emoji.e0bb5bdd.js 1.36kb +0.00b 35.14s +31.16s ⚠️
dist/16.2475b7ab.js 1.35kb +0.00b 33.28s +29.70s ⚠️
dist/16.24ecf6d5.js 1.35kb +0.00b 33.28s +29.70s ⚠️
dist/16.fe096c73.js 1.33kb +0.00b 33.28s +29.47s ⚠️
dist/16.9c0dd14e.js 1.33kb +0.00b 33.28s +29.68s ⚠️
dist/heading2.689c1725.js 1.32kb +0.00b 35.14s +31.11s ⚠️
dist/16.f6f07bdf.js 1.29kb +0.00b 33.28s +29.70s ⚠️
dist/expand.c97517e7.js 1.29kb +0.00b 54.68s +49.22s ⚠️
dist/heading4.a48496c5.js 1.27kb +0.00b 54.68s +50.64s ⚠️
dist/16.abb96752.js 1.25kb +0.00b 33.28s +29.70s ⚠️
dist/16.8a916ec3.js 1.22kb +0.00b 33.28s +29.70s ⚠️
dist/16.5ab0c52f.js 1.21kb +0.00b 33.28s +29.70s ⚠️
dist/16.17b379b7.js 1.20kb +0.00b 33.89s +29.91s ⚠️
dist/mention.7513d265.js 1.20kb +0.00b 35.14s +31.16s ⚠️
dist/layout.a2215d1e.js 1.18kb +0.00b 35.14s +31.16s ⚠️
dist/Modal.71b21a38.js 1.17kb +0.00b 33.28s +29.70s ⚠️
dist/16.dc7fba57.js 1.16kb +0.00b 33.28s +29.70s ⚠️
dist/heading1.53882705.js 1.16kb +0.00b 35.14s +31.10s ⚠️
dist/16.4947d5d2.js 1.16kb +0.00b 33.28s +29.68s ⚠️
dist/divider.61f72909.js 1.16kb +0.00b 35.14s +31.16s ⚠️
dist/quote.ac356b63.js 1.15kb +0.00b 35.14s +31.11s ⚠️
dist/16.61848cd9.js 1.15kb +0.00b 33.28s +29.70s ⚠️
dist/16.f88600cd.js 1.15kb +0.00b 33.28s +29.70s ⚠️
dist/16.3457832f.js 1.15kb +0.00b 33.28s +29.70s ⚠️
dist/16.59da43e0.js 1.15kb +0.00b 33.28s +29.70s ⚠️
dist/action.03622130.js 1.13kb +0.00b 35.14s +31.16s ⚠️
dist/component.0faea072.js 1.12kb +0.00b 33.55s +29.95s ⚠️
dist/media-card-analytics-error-boundary.92f81a75.js 1.12kb +0.00b 1.10m +57.01s ⚠️
dist/decision.e8963abf.js 1.12kb +0.00b 35.14s +31.16s ⚠️
dist/panel-warning.d87689fa.js 1.11kb +0.00b 35.14s +31.16s ⚠️
dist/16.71584d67.js 1.11kb +0.00b 33.28s +29.70s ⚠️
dist/list.452d2378.js 1.08kb +0.00b 35.14s +31.16s ⚠️
dist/16.d79d0001.js 1.07kb +0.00b 33.28s +29.70s ⚠️
dist/panel-error.2d1266a1.js 1.01kb +0.00b 35.14s +31.16s ⚠️
dist/panel.2fa2f198.js 1.01kb +0.00b 35.14s +31.16s ⚠️
dist/table.5143dd29.js 1022.00b +0.00b 35.14s +31.11s ⚠️
dist/panel-success.8c4cf740.js 978.00b +0.00b 35.14s +31.16s ⚠️
dist/panel-note.aa22bfaa.js 974.00b +0.00b 35.14s +31.16s ⚠️
dist/media-viewer-analytics-error-boundary.c51589b7.js 964.00b +0.00b 1.10m +57.00s ⚠️
dist/media-picker-analytics-error-boundary.da55e63c.js 964.00b +0.00b 1.10m +56.99s ⚠️
dist/media-card-analytics-error-boundary.b94e1438.js 960.00b +0.00b 1.10m +57.01s ⚠️
dist/media-card-analytics-error-boundary.fd1b1d47.js 960.00b +0.00b 1.10m +57.02s ⚠️
dist/simpleHasher.74d2cfec.js 641.00b +0.00b 1.10m +57.01s ⚠️
dist/simpleHasher.5278a07e.js 641.00b +0.00b 1.10m +48.04s ⚠️
dist/index.html 119.00b +0.00b 28.48s +24.98s ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.e7395e7f.js 2.60mb +10.00b ⚠️ 175.00ms -0.00ms
dist/pdf.worker.a3e718f4.js 727.98kb +0.00b 225.00ms -15.00ms 🚀
dist/pdfRenderer.4dcd091a.js 411.56kb +0.00b 225.00ms -15.00ms 🚀
dist/EmojiPickerComponent.1fcfdd18.js 147.28kb +0.00b 217.00ms -21.00ms 🚀
dist/media-viewer.abeacbd4.js 74.99kb +0.00b 225.00ms -15.00ms 🚀
dist/card.2833fa08.js 62.67kb +0.00b 222.00ms -18.00ms 🚀
dist/esm.dd6f087c.js 33.24kb +0.00b 217.00ms -22.00ms 🚀
dist/ui.8bcf31ff.js 14.94kb +0.00b 222.00ms -18.00ms 🚀
dist/workerHasher.95f27d4e.js 11.81kb +0.00b 217.00ms -22.00ms 🚀
dist/card.006509f3.js 5.96kb +0.00b 222.00ms -18.00ms 🚀
dist/EmojiPickerComponent.20965f41.js 3.72kb +0.00b 222.00ms -17.00ms 🚀
dist/index.44263fbe.css 3.46kb +0.00b 264.00ms -32.00ms 🚀
dist/ResourcedEmojiComponent.425492a2.js 2.12kb +0.00b 222.00ms -17.00ms 🚀
dist/date.13837189.js 1.86kb +0.00b 185.00ms -20.00ms 🚀
dist/images.a51e31c2.js 1.80kb +0.00b 188.00ms -17.00ms 🚀
dist/16.b8c83009.js 1.75kb +0.00b 260.00ms +84.00ms ⚠️
dist/16.f48613ba.js 1.68kb +0.00b 258.00ms +82.00ms ⚠️
dist/workerHasher.a91c28d5.js 1.63kb +0.00b 217.00ms -22.00ms 🚀
dist/list-number.494da4e7.js 1.59kb +0.00b 195.00ms -11.00ms 🚀
dist/status.8783408d.js 1.59kb +0.00b 199.00ms -17.00ms 🚀
dist/code.677bd70c.js 1.51kb +0.00b 184.00ms -21.00ms 🚀
dist/heading3.99e77e15.js 1.49kb +0.00b 200.00ms -22.00ms 🚀
dist/link.eecf8ee1.js 1.43kb +0.00b 195.00ms -11.00ms 🚀
dist/16.0f105e82.js 1.40kb +0.00b 259.00ms +83.00ms ⚠️
dist/heading5.c9eff376.js 1.38kb +0.00b 202.00ms -20.00ms 🚀
dist/emoji.e0bb5bdd.js 1.36kb +0.00b 187.00ms -18.00ms 🚀
dist/16.2475b7ab.js 1.35kb +0.00b 257.00ms +82.00ms ⚠️
dist/16.24ecf6d5.js 1.35kb +0.00b 258.00ms +82.00ms ⚠️
dist/16.fe096c73.js 1.33kb +0.00b 262.00ms +88.00ms ⚠️
dist/heading2.689c1725.js 1.32kb +0.00b 200.00ms -21.00ms 🚀
dist/16.f6f07bdf.js 1.29kb +0.00b 261.00ms +68.00ms ⚠️
dist/heading4.a48496c5.js 1.27kb +0.00b 201.00ms -21.00ms 🚀
dist/16.abb96752.js 1.25kb +0.00b 260.00ms +83.00ms ⚠️
dist/16.5ab0c52f.js 1.21kb +0.00b 261.00ms +84.00ms ⚠️
dist/16.17b379b7.js 1.20kb +0.00b 184.00ms -21.00ms 🚀
dist/mention.7513d265.js 1.20kb +0.00b 195.00ms -20.00ms 🚀
dist/layout.a2215d1e.js 1.18kb +0.00b 195.00ms -10.00ms 🚀
dist/16.dc7fba57.js 1.16kb +0.00b 260.00ms +84.00ms ⚠️
dist/heading1.53882705.js 1.16kb +0.00b 199.00ms -22.00ms 🚀
dist/divider.61f72909.js 1.16kb +0.00b 186.00ms -19.00ms 🚀
dist/quote.ac356b63.js 1.15kb +0.00b 199.00ms -17.00ms 🚀
dist/16.61848cd9.js 1.15kb +0.00b 262.00ms +86.00ms ⚠️
dist/16.f88600cd.js 1.15kb +0.00b 258.00ms +82.00ms ⚠️
dist/16.3457832f.js 1.15kb +0.00b 259.00ms +83.00ms ⚠️
dist/action.03622130.js 1.13kb +0.00b 183.00ms -22.00ms 🚀
dist/media-card-analytics-error-boundary.92f81a75.js 1.12kb +0.00b 222.00ms -18.00ms 🚀
dist/decision.e8963abf.js 1.12kb +0.00b 185.00ms -20.00ms 🚀
dist/panel-warning.d87689fa.js 1.11kb +0.00b 199.00ms -16.00ms 🚀
dist/16.71584d67.js 1.11kb +0.00b 176.00ms -18.00ms 🚀
dist/list.452d2378.js 1.08kb +0.00b 195.00ms -11.00ms 🚀
dist/16.d79d0001.js 1.07kb +0.00b 261.00ms +84.00ms ⚠️
dist/panel-error.2d1266a1.js 1.01kb +0.00b 195.00ms -20.00ms 🚀
dist/panel.2fa2f198.js 1.01kb +0.00b 199.00ms -17.00ms 🚀
dist/table.5143dd29.js 1022.00b +0.00b 199.00ms -22.00ms 🚀
dist/panel-success.8c4cf740.js 978.00b +0.00b 195.00ms -20.00ms 🚀
dist/panel-note.aa22bfaa.js 974.00b +0.00b 195.00ms -20.00ms 🚀
dist/media-card-analytics-error-boundary.b94e1438.js 960.00b +0.00b 222.00ms -18.00ms 🚀
dist/simpleHasher.74d2cfec.js 641.00b +0.00b 217.00ms -22.00ms 🚀
dist/index.html 119.00b +0.00b 122.00ms +14.00ms ⚠️

Three.js ✅

Timings

Description Time Difference
Cold 8.40s -297.00ms
Cached 598.00ms -8.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

Bundle Size Difference Time Difference
dist/Three.js 579.69kb +0.00b 69.00ms -8.00ms 🚀

Click here to view a detailed benchmark overview.

@wbinnssmith
Copy link
Contributor

I tried this out on a large app, and got this after a few transformations:

node(26504,0x70000f77a000) malloc: *** error for object 0x1189d8000: pointer being freed was not allocated
node(26504,0x70000f77a000) malloc: *** set a breakpoint in malloc_error_break to debug

@wbinnssmith wbinnssmith force-pushed the lmdb-cache branch 2 times, most recently from c2f6ac5 to 4b4ce35 Compare March 16, 2021 17:44
),
);

// TODO: don't replace hash references in binary files??
Copy link
Member

Choose a reason for hiding this comment

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

I guess this wasn't introduced by your changes?

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 just a problem I noticed. But not sure how to know which files we should do this for.

Copy link
Member

Choose a reason for hiding this comment

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

We use this in the data url optimizer, but its detection logic is rather sketchy : gjtorikian/isBinaryFile#22

@devongovett devongovett merged commit 2d3c676 into v2 May 28, 2021
@devongovett devongovett deleted the lmdb-cache branch May 28, 2021 20:07
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.

4 participants