Skip to content

Conversation

@PandaWorker
Copy link
Contributor

@PandaWorker PandaWorker commented Oct 4, 2025

This relates to...

Header name validation performance

Changes

Status

@PandaWorker
Copy link
Contributor Author

This implementation has already been added to node.

nodejs/node#59832

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Great work! How much do we gain?

lib/core/util.js Outdated

for (let i = 0; i < characters.length; i++) {
const c = characters.charCodeAt(i)
if (!isTokenCharCode(c)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please remove the isTokeCharCode function and just inline the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done)

@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2025

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.93%. Comparing base (6365a90) to head (d3c5f6e).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
lib/core/util.js 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #4608       +/-   ##
=========================================
+ Coverage      0   92.93%   +92.93%     
=========================================
  Files         0      106      +106     
  Lines         0    32971    +32971     
=========================================
+ Hits          0    30640    +30640     
- Misses        0     2331     +2331     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@PandaWorker
Copy link
Contributor Author

Great work! How much do we gain?

I didn't just take the number 12 for validation through a regular expression, it's after 12 characters that the problems start in the fast version, it's probably something to do with v8 optimization for short strings.

Here is a benchmarking of the validation of strings from 8 to 20 characters

image

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

lgtm with Matteo's comment

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@metcoder95 metcoder95 merged commit 9456d8f into nodejs:main Oct 13, 2025
28 of 29 checks passed
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