Skip to content

perf: reduce content-type parser overhead - #7012

Merged
gurgunday merged 1 commit into
mainfrom
perf/content-type-parser-overhead
Sep 8, 2026
Merged

gurgunday merged 1 commit into
mainfrom
perf/content-type-parser-overhead

Conversation

@gurgunday

Copy link
Copy Markdown
Member

This PR does 2 things:

  • Replace AsyncResource.bind() with a callback that still preserves async scope (this is an optimization I've seen in Node.js, I believe by @mcollina)
  • Cache parameterized content-type parser matches
   Existing command                   Before            After    Change
  ━━━━━━━━━━━━━━━━━━━━━━━━━━  ━━━━━━━━━━━━━━━  ━━━━━━━━━━━━━━━  ━━━━━━━━
   npm run benchmark:parser    123,106 req/s    161,468 req/s    +31.2%
  ──────────────────────────  ───────────────  ───────────────  ────────
   npm run benchmark           201,041 req/s    201,310 req/s    +0.13%

@gurgunday
gurgunday requested a review from a team September 7, 2026 20:59
Comment thread lib/content-type-parser.js
@gurgunday
gurgunday requested review from a team and Uzlopak September 8, 2026 18:04

@metcoder95 metcoder95 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice!

@gurgunday
gurgunday merged commit d1dd890 into main Sep 8, 2026
31 checks passed
@gurgunday
gurgunday deleted the perf/content-type-parser-overhead branch September 8, 2026 20:25
@Eomm Eomm added the performances Everything related to performances label Sep 9, 2026
@gurgunday gurgunday added the backport 5.x Issue or pr that should be backported to Fastify v5 label Sep 10, 2026
gurgunday added a commit that referenced this pull request Sep 11, 2026
Backport d1dd890 from #7012.

Signed-off-by: Gürgün Dayıoğlu <[email protected]>
Co-authored-by: Gürgün Dayıoğlu <[email protected]>
Co-authored-by: KaKa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 5.x Issue or pr that should be backported to Fastify v5 performances Everything related to performances

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants