GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — util: make mime parsing faster by jasnell · Pull Request #66369 · nodejs/node

Conversation

@jasnell

@jasnell jasnell commented Sep 28, 2026

Copy link
Copy Markdown
Member

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
All reactions
  • 🚀 3 reactions
@jasnell
util: make mime parsing faster
cf37283
Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode
@jasnell
jasnell requested review from mcollina and ronag September 28, 2026 05:22
@nodejs-github-bot

nodejs-github-bot commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Sep 28, 2026
@codecov

codecov Bot commented Sep 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ 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     
Files with missing lines Coverage Δ
lib/internal/mime.js 100.00% <100.00%> (ø)

... 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Oct 4, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

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.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jasnell 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
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 4, 2026 •
edited by jasnell
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78163/ 💚

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 4, 2026
@nodejs-github-bot nodejs-github-bot added the lacks-second-approval Commit Queue PRs awaiting a second collaborator approval or completion of the required wait. label Oct 4, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 6812e92 into nodejs:main Oct 5, 2026
83 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Landed in 6812e92

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed commit-queue PRs queued for automated landing through the Commit Queue. lacks-second-approval Commit Queue PRs awaiting a second collaborator approval or completion of the required wait. labels Oct 5, 2026
aduh95 pushed a commit that referenced this pull request Oct 5, 2026
@jasnell @aduh95
util: make mime parsing faster
aff6017
Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode
PR-URL: #66369
Reviewed-By: Matteo Collina <[email protected]>
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
2026-10-07, Version 26.11.0 (Current) #66546
Merged
aduh95 pushed a commit that referenced this pull request Oct 23, 2026
@jasnell @aduh95
util: make mime parsing faster
77bdf6c
Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode
PR-URL: #66369
Reviewed-By: Matteo Collina <[email protected]>
aduh95 pushed a commit that referenced this pull request Oct 28, 2026
@jasnell @aduh95
util: make mime parsing faster
4612967
Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode
PR-URL: #66369
Reviewed-By: Matteo Collina <[email protected]>
@robobun robobun mentioned this pull request Oct 29, 2026
util.MIMEType: end quoted parameter values per the MIME Sniffing standard oven-sh/bun#47319
Closed
@leapmux-renovate leapmux-renovate Bot mentioned this pull request Nov 1, 2026
chore(deps): Update Node.js to v26 leapmux/leapmux#578
Merged
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@jasnell @aduh95
util: make mime parsing faster
4ca11d3
Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode
PR-URL: #66369
Reviewed-By: Matteo Collina <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 24.23.0 'Krypton' (LTS) #67663
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@ronag 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.

Projects

None yet

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.

3 participants

@jasnell @nodejs-github-bot @mcollina
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.