Skip to content
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

Fix performance regression in node:http from #18599 #18798

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Jarred-Sumner
Copy link
Collaborator

What does this PR do?

Fix performance regression in node:http from #18599

How did you verify your code works?

@robobun
Copy link

robobun commented Apr 5, 2025

Updated 11:42 AM PT - Apr 5th, 2025

@cirospaciari, your commit 8aebcf6 has 6 failures in Build #14526:


🧪   try this PR locally:

bunx bun-pr 18798

Copy link
Member

@cirospaciari cirospaciari left a comment

Choose a reason for hiding this comment

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

We have test failures, we need to make sure that node:http remains compatible, otherwise I think that the chances are in the right direction

// This is the equivalent of checkIsHttpToken from internal/validators.js
// The regex is /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/
for (const auto& c : name) {
if (!(c == '^' || c == '_' || c == '`' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '-' || (c >= '0' && c <= '9') || c == '!' || c == '#' || c == '$' || c == '%' || c == '&' || c == '\'' || c == '*' || c == '+' || c == '.' || c == '|' || c == '~')) {
Copy link
Member

Choose a reason for hiding this comment

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

is this faster than a switch statement? because is not easy to read

@@ -41,6 +41,16 @@ bool isTokenCharacter(UChar c)
|| c == '`' || c == '|' || c == '~';
}

bool isTokenCharacter(LChar c)
{
return isASCIIAlpha(c) || isASCIIDigit(c)
Copy link
Member

Choose a reason for hiding this comment

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

I just like how this is formatted in a way that is easier to read than a switch/case

if (hasBody) {
// Don't automatically read the body, the user will need to resume() or .on("data") to read it.
// But, avoid the system call overhead unless we are going to receive body data.
handle.pause();
Copy link
Member

Choose a reason for hiding this comment

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

I should have added this check from the start, thanks

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.

3 participants