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: use mimalloc for bindings_napi #5201
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #5201 +/- ##
=======================================
Coverage 98.82% 98.82%
=======================================
Files 231 231
Lines 8849 8849
Branches 2314 2314
=======================================
Hits 8745 8745
Misses 43 43
Partials 61 61 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, these are the kind of improvements that I hoped people with Rust experience would dig up.
This PR has been released as part of rollup@4.1.1. You can test it via |
[target.'cfg(not(target_os = "linux"))'.dependencies] | ||
mimalloc-rust = { version = "0.2" } | ||
|
||
[target.'cfg(all(target_os = "linux", not(all(target_env = "musl", target_arch = "aarch64"))))'.dependencies] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sapphi-red: the linux arm64 arch exclusion is intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is. The examples I shown in the OP all excludes linux+musl+arm64. I don't know the reason, but as I cannot easily check the actual behavior, I went with a safer way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That issue microsoft/mimalloc#556 seems to say that since version 2.0.5, it works on linux arm64. So if the mimalloc-rust bindings is against that version or superior, it should also work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rust bindings uses 1.7.9: https://github.com/LemonHX/mimalloc-rust#:~:text=mimalloc%201.7.9%20stable
So that seems to be the reason.
<p>This PR was automatically created by Snyk using the credentials of a real user.</p><br /><h3>Snyk has created this PR to upgrade rollup from 4.0.2 to 4.1.3.</h3> :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project. <hr/> - The recommended version is **3 versions** ahead of your current version. - The recommended version was released **21 days ago**, on 2023-10-15. <details> <summary><b>Release notes</b></summary> <br/> <details> <summary>Package name: <b>rollup</b></summary> <ul> <li> <b>4.1.3</b> - <a href="https://snyk.io/redirect/github/rollup/rollup/releases/tag/v4.1.3">2023-10-15</a></br><h2>4.1.3</h2> <p><em>2023-10-15</em></p> <h3>Bug Fixes</h3> <ul> <li>Fix WASM build as hash function was not exported (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1943384459" data-permission-text="Title is private" data-url="rollup/rollup#5203" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5203/hovercard" href="https://snyk.io/redirect/github/rollup/rollup/pull/5203">#5203</a>)</li> </ul> <h3>Pull Requests</h3> <ul> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5203" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5203/hovercard">#5203</a>: fix: export xxhashBase64Url from wasm (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sapphi-red/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/sapphi-red">@ sapphi-red</a>)</li> </ul> </li> <li> <b>4.1.1</b> - <a href="https://snyk.io/redirect/github/rollup/rollup/releases/tag/v4.1.1">2023-10-15</a></br><h2>4.1.1</h2> <p><em>2023-10-15</em></p> <h3>Bug Fixes</h3> <ul> <li>Improve Node parsing performance (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1943329369" data-permission-text="Title is private" data-url="rollup/rollup#5201" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5201/hovercard" href="https://snyk.io/redirect/github/rollup/rollup/pull/5201">#5201</a>)</li> </ul> <h3>Pull Requests</h3> <ul> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5201" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5201/hovercard">#5201</a>: perf: use mimalloc for bindings_napi (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sapphi-red/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/sapphi-red">@ sapphi-red</a>)</li> </ul> </li> <li> <b>4.1.0</b> - <a href="https://snyk.io/redirect/github/rollup/rollup/releases/tag/v4.1.0">2023-10-14</a></br><h2>4.1.0</h2> <p><em>2023-10-14</em></p> <h3>Features</h3> <ul> <li>Reduce memory usage of Rollup builds (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1891270290" data-permission-text="Title is private" data-url="rollup/rollup#5133" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5133/hovercard" href="https://snyk.io/redirect/github/rollup/rollup/pull/5133">#5133</a>)</li> </ul> <h3>Pull Requests</h3> <ul> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5133" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5133/hovercard">#5133</a>: perf: reducing ast node memory overhead (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/thebanjomatic/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/thebanjomatic">@ thebanjomatic</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5177" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5177/hovercard">#5177</a>: chore: explicitly set rust toolchain channel (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cijiugechu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/cijiugechu">@ cijiugechu</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5179" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5179/hovercard">#5179</a>: Update migration guide for Rollup 4 (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lukastaegert/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/lukastaegert">@ lukastaegert</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5180" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5180/hovercard">#5180</a>: Resolve clippy errors (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cijiugechu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/cijiugechu">@ cijiugechu</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5183" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5183/hovercard">#5183</a>: Add clippy to pipeline and fix remaining issues (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lukastaegert/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/lukastaegert">@ lukastaegert</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5184" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5184/hovercard">#5184</a>: docs: fix code example for <code>onLog</code> (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tjenkinson/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/tjenkinson">@ tjenkinson</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5186" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5186/hovercard">#5186</a>: Improve wording for native artifacts in migration guide (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lukastaegert/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/lukastaegert">@ lukastaegert</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5190" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5190/hovercard">#5190</a>: test: add verifyAst type (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/TrickyPi/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/TrickyPi">@ TrickyPi</a>)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5196" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5196/hovercard">#5196</a>: chore(deps): update dependency rollup to v4 (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/renovate/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/renovate">@ renovate</a>[bot])</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5197" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5197/hovercard">#5197</a>: chore(deps): lock file maintenance minor/patch updates (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/renovate/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/renovate">@ renovate</a>[bot])</li> </ul> </li> <li> <b>4.0.2</b> - <a href="https://snyk.io/redirect/github/rollup/rollup/releases/tag/v4.0.2">2023-10-06</a></br><h2>4.0.2</h2> <p><em>2023-10-06</em></p> <h3>Bug Fixes</h3> <ul> <li>Fix annotation detection logic to not fail when a non-ASCII character precedes a double underscore (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1930196242" data-permission-text="Title is private" data-url="rollup/rollup#5178" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5178/hovercard" href="https://snyk.io/redirect/github/rollup/rollup/pull/5178">#5178</a>)</li> </ul> <h3>Pull Requests</h3> <ul> <li><a href="https://snyk.io/redirect/github/rollup/rollup/pull/5178" data-hovercard-type="pull_request" data-hovercard-url="/rollup/rollup/pull/5178/hovercard">#5178</a>: Handle special characters before double underscores (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/lukastaegert/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://snyk.io/redirect/github/lukastaegert">@ lukastaegert</a>)</li> </ul> </li> </ul> from <a href="https://snyk.io/redirect/github/rollup/rollup/releases">rollup GitHub release notes</a> </details> </details> <details> <summary><b>Commit messages</b></summary> </br> <details> <summary>Package name: <b>rollup</b></summary> <ul> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/c61a1507a88fc71be431550642b040da4b9422b0">c61a150</a> 4.1.3</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/70f79ad2f11a45524fcb89cbbb7138d8bb828b68">70f79ad</a> Fix publish script</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/ebd96c447bab292e33b05628ec8e7d0e61bb59b8">ebd96c4</a> 4.1.2</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/ee0639e711672b552fcd2928a700bc5541a564f0">ee0639e</a> fix: export xxhashBase64Url from wasm (#5203)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/d8b31a202a246758b8d67eefe77361a894d37005">d8b31a2</a> 4.1.1</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/f3eaa288b6afbb0ea5ad60b21238e950122a1766">f3eaa28</a> perf: use mimalloc for bindings_napi (#5201)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/cb144b2be4262b3743b31983b26f7fa985be3ceb">cb144b2</a> 4.1.0</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/72c66398cd3e8d52e6812ff94b721a1a56ad7cdd">72c6639</a> perf: reducing ast node memory overhead (#5133)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/e2f947f28ef921568ae03af9b9e868b9e7c712fa">e2f947f</a> chore(deps): update dependency rollup to v4 (#5196)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/4bcf4e124b534c5fe39cee12f683028f0895a635">4bcf4e1</a> chore(deps): lock file maintenance minor/patch updates (#5197)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/dddf626a77e15d4e0baa5f1689fd233634a29a9a">dddf626</a> Reduce workflow concurrency</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/97bffa81987b72a9fe6168962bc1fe38cb948048">97bffa8</a> Enable Renovate automerge</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/d90f274832b28429bd593ad0e34791ca7c2888ba">d90f274</a> test: add verifyAst type (#5190)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/f52a2ebfdcd568b0876af3fadf9e85f7c4af6e5d">f52a2eb</a> Improve wording for native artifacts in migration guide (#5186)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/080d2245ab6b6298229ebe7258c2b96816e7c52d">080d224</a> Add clippy to pipeline and fix remaining issues (#5183)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/c45366402e1841b6a2fd1f1bd0a4319571acd09f">c453664</a> docs: fix code example for `onLog` (#5184)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/e99ff72b3a60a4f5483a401b0423704675537ca3">e99ff72</a> Resolve clippy errors (#5180)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/2a86412433bd4e1a2a344db75ad180ade62a856e">2a86412</a> Fix toolchain for REPL workflow</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/15d321bf7da5d48ed9a8ed9f87d7f88736ce837d">15d321b</a> chore: explicitly set rust toolchain channel (#5177)</li> <li><a href="https://snyk.io/redirect/github/rollup/rollup/commit/8b217ce2288bd268ed50f23990cced830f2644f2">8b217ce</a> Update migration guide for Rollup 4 (#5179)</li> </ul> <a href="https://snyk.io/redirect/github/rollup/rollup/compare/3d9c833c4fcb666301967554bac7ab0a0a698efe...c61a1507a88fc71be431550642b040da4b9422b0">Compare</a> </details> </details> <hr/> **Note:** *You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.* For more information: <img src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiJjMGRjZTAxNC0wMjlhLTQ2ZTctOWMxNS02YTM0NDg0MTM4NmYiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6ImMwZGNlMDE0LTAyOWEtNDZlNy05YzE1LTZhMzQ0ODQxMzg2ZiJ9fQ==" width="0" height="0"/> 🧐 [View latest project report](https://app.snyk.io/org/woodpile37/project/edb93f5a-17e2-4a56-beb9-1796f0e58302?utm_source=github&utm_medium=referral&page=upgrade-pr) 🛠 [Adjust upgrade PR settings](https://app.snyk.io/org/woodpile37/project/edb93f5a-17e2-4a56-beb9-1796f0e58302/settings/integration?utm_source=github&utm_medium=referral&page=upgrade-pr) 🔕 [Ignore this dependency or unsubscribe from future upgrade PRs](https://app.snyk.io/org/woodpile37/project/edb93f5a-17e2-4a56-beb9-1796f0e58302/settings/integration?pkg=rollup&utm_source=github&utm_medium=referral&page=upgrade-pr#auto-dep-upgrades) <!--- (snyk:metadata:{"prId":"c0dce014-029a-46e7-9c15-6a344841386f","prPublicId":"c0dce014-029a-46e7-9c15-6a344841386f","dependencies":[{"name":"rollup","from":"4.0.2","to":"4.1.3"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/woodpile37/project/edb93f5a-17e2-4a56-beb9-1796f0e58302?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"edb93f5a-17e2-4a56-beb9-1796f0e58302","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":3,"publishedDate":"2023-10-15T17:48:53.269Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]}) --->
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This PR swaps the memory allocator with mimalloc.
This allocator seems to be common in napi-rs world (swc, @napi-rs/fast-escape, parcel, @resvg/resvg-js).
Some projects uses jemallocator on some OS/architectures and ideally we should check which allocator performs better on each of them. But I'll leave this investigation for now.
Running the benchmark in #5182 (actually I used the esbuild repo instead), I got ~200ms / ~3% improvement on my laptop.
Benchmark results
rollup 3.29.4
rollup 4.0.2
rollup 4.1.0
using mimalloc (~200ms / ~3% improvement)
Specs of my laptop
This change increases the binary size by 0.07MB (3.25MB -> 3.32MB).