GeezerVison is showing github.com — util: make mime parsing faster by jasnell · Pull Request #66369 · nodejs/node
Conversation
Improve the implementation of util.MIMEType parsing to eliminate overhead. Modules like undici end up handrolling their mime parsing impls because util.MIMEType just had never been performance optimized. This update makes it about twice as fast as undici's handrolled version for typical inputs.
$ cd /home/dev/node && ./node benchmark/compare.js --old /tmp/opencode/mime/node-old --new ./out/Release/node --runs 10 --no-progress --analyze --csv /tmp/opencode/mime/compare.csv mime 2>&1 | tail -60
mime/mimetype-parse.js operation='essence' value='application/json' n=100000 *** +81.04 % ±3.34% ±4.63% ±6.43%
mime/mimetype-parse.js operation='params.get' value='application/json' n=100000 *** +114.31 % ±4.97% ±7.03% ±10.06%
mime/mimetype-parse.js operation='parse' value='text/html; charset=utf-8' n=100000 *** +118.11 % ±4.77% ±6.66% ±9.35%
mime/mimetype-parse.js operation='essence' value='text/html; charset=utf-8' n=100000 *** +70.97 % ±6.86% ±9.54% ±13.30%
mime/mimetype-parse.js operation='params.get' value='text/html; charset=utf-8' n=100000 *** +139.05 % ±4.51% ±6.37% ±9.11%
mime/mimetype-parse.js operation='parse' value='multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' n=100000 *** +92.57 % ±4.57% ±6.40% ±9.04%
mime/mimetype-parse.js operation='essence' value='multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' n=100000 *** +73.89 % ±18.69% ±26.76% ±39.13%
mime/mimetype-parse.js operation='params.get' value='multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' n=100000 *** +125.18 % ±5.09% ±7.20% ±10.30%
mime/mimetype-parse.js operation='parse' value='text/plain; charset="utf-8"; foo="b\\"ar"; x=y' n=100000 *** +113.24 % ±6.59% ±9.26% ±13.14%
mime/mimetype-parse.js operation='essence' value='text/plain; charset="utf-8"; foo="b\\"ar"; x=y' n=100000 *** +70.11 % ±4.21% ±5.84% ±8.13%
mime/mimetype-parse.js operation='params.get' value='text/plain; charset="utf-8"; foo="b\\"ar"; x=y' n=100000 *** +179.52 % ±6.07% ±8.70% ±12.74%
mime/mimetype-parse.js operation='parse' value='not a mime type' n=100000 *** +57.83 % ±4.81% ±6.78% ±9.69%
mime/mimetype-parse.js operation='essence' value='not a mime type' n=100000 *** +59.27 % ±4.64% ±6.47% ±9.09%
mime/mimetype-parse.js operation='params.get' value='not a mime type' n=100000 *** +57.58 % ±4.10% ±5.73% ±8.05%
mime/mimetype-to-string.js value='application/ecmascript; ' n=100000 -8.77 % ±15.56% ±22.30% ±32.67%
mime/mimetype-to-string.js value='text/html;charset=gbk' n=100000 ** +8.35 % ±4.46% ±6.13% ±8.40%
mime/mimetype-to-string.js value='text/html;012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk' n=100000 *** +13.55 % ±3.00% ±4.17% ±5.81%
mime/mimetype-to-string.js value='text/html;test=ÿ;charset=gbk' n=100000 *** +17.04 % ±3.19% ±4.38% ±5.97%
mime/mimetype-to-string.js value='x/x;\n\r\t x=x\n\r\t ;x=y' n=100000 *** +15.31 % ±3.41% ±4.68% ±6.38%
-185.6% 0% +185.6%
mime/mimetype-instantiation.js value='application/ecmascript; ' n=100000 |████████░ +86.21% ***
mime/mimetype-instantiation.js value='text/html;charset=gbk' n=100000 |████████████░░ +124.07% ***
mime/mimetype-instantiation.js value='text/html;012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk' n=100000 |███████████░ +113.17% ***
mime/mimetype-instantiation.js value='text/html;test=ÿ;charset=gbk' n=100000 |████████████░ +117.66% ***
mime/mimetype-instantiation.js value='x/x;\n\r\t x=x\n\r\t ;x=y' n=100000 |██████████████ +137.13% ***
mime/mimetype-parse.js operation='parse' value='application/json' n=100000 |██████████░ +104.81% ***
mime/mimetype-parse.js operation='essence' value='application/json' n=100000 |████████ +81.04% ***
mime/mimetype-parse.js operation='params.get' value='application/json' n=100000 |███████████░ +114.31% ***
mime/mimetype-parse.js operation='parse' value='text/html; charset=utf-8' n=100000 |████████████ +118.11% ***
mime/mimetype-parse.js operation='essence' value='text/html; charset=utf-8' n=100000 |███████ +70.97% ***
mime/mimetype-parse.js operation='params.get' value='text/html; charset=utf-8' n=100000 |██████████████ +139.05% ***
mime/mimetype-parse.js operation='parse' value='multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' n=100000 |█████████ +92.57% ***
mime/mimetype-parse.js operation='essence' value='multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' n=100000 |███████░░ +73.89% ***
mime/mimetype-parse.js operation='params.get' value='multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' n=100000 |████████████░ +125.18% ***
mime/mimetype-parse.js operation='parse' value='text/plain; charset="utf-8"; foo="b\\"ar"; x=y' n=100000 |███████████░ +113.24% ***
mime/mimetype-parse.js operation='essence' value='text/plain; charset="utf-8"; foo="b\\"ar"; x=y' n=100000 |███████ +70.11% ***
mime/mimetype-parse.js operation='params.get' value='text/plain; charset="utf-8"; foo="b\\"ar"; x=y' n=100000 |██████████████████░ +179.52% ***
mime/mimetype-parse.js operation='parse' value='not a mime type' n=100000 |█████░ +57.83% ***
mime/mimetype-parse.js operation='essence' value='not a mime type' n=100000 |█████░ +59.27% ***
mime/mimetype-parse.js operation='params.get' value='not a mime type' n=100000 |█████░ +57.58% ***
mime/mimetype-to-string.js value='application/ecmascript; ' n=100000 ░░▓| -8.77%
mime/mimetype-to-string.js value='text/html;charset=gbk' n=100000 | +8.35% **
mime/mimetype-to-string.js value='text/html;012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789=x;charset=gbk' n=100000 |░ +13.55% ***
mime/mimetype-to-string.js value='text/html;test=ÿ;charset=gbk' n=100000 |█ +17.04% ***
mime/mimetype-to-string.js value='x/x;\n\r\t x=x\n\r\t ;x=y' n=100000 |█ +15.31% ***
Rates were scaled by 1000x into HdrHistogram (3 significant figures).
Use --scale to adjust precision if needed.
Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 25 comparisons, you can thus
expect the following amount of false-positive results:
1.25 false positives, when considering a 5% risk acceptance (*, **, ***),
0.25 false positives, when considering a 1% risk acceptance (**, ***),
0.03 false positives, when considering a 0.1% risk acceptance (***)
The stars above are per-benchmark and uncorrected. Adjusting for the size of
this comparison set (Holm-Bonferroni), 24 comparisons remain significant at 5%.
--max-regression uses the corrected values.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
bricss, H4ad, and TheOneTheOnlyJJ reacted with rocket emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Sep 28, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.36%. Comparing base (cd908df) to head (cf37283).
⚠️ Report is 123 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #66369 +/- ##
==========================================
- Coverage 90.37% 90.36% -0.02%
==========================================
Files 792 792
Lines 275324 275526 +202
Branches 52764 52824 +60
==========================================
+ Hits 248828 248982 +154
- Misses 16918 16973 +55
+ Partials 9578 9571 -7
... and 45 files with indirect coverage changes
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
jasnell
added
request-ci
Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review.
author ready
PRs with CI started, the required approvals, and no outstanding review comments.
labels
Oct 4, 2026
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
mcollina
mcollina approved these changes
ronag
Awaiting requested review from ronag
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
author ready
PRs with CI started, the required approvals, and no outstanding review comments.
needs-ci
PRs that need a full CI run.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|