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

perf: remove unnecessary c++ call with url.format #2045

Closed
wants to merge 1 commit into from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Apr 4, 2023

Before

[bench:run] │ undici - fetch      │       1 │ 1506.39 req/sec │  ± 0.00 % │               + 12.58 % │

After

[bench:run] │ undici - fetch      │       1 │ 1562.92 req/sec │  ± 0.00 % │                       - │

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

I prefer the simplicity of the existing solution.

Comment on lines -527 to +526
return URLSerializer(this[kState].url)
return this[kState].url.toString()
Copy link
Member Author

Choose a reason for hiding this comment

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

@ronag Then we should at least keep the changes like this, where C++ call is not necessary at all.

Copy link
Member

Choose a reason for hiding this comment

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

Do they do the exact same thing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

Why does URL.href go into C++ if it does the same thing as toString?

Copy link
Member

Choose a reason for hiding this comment

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

  toString() {
    return this.#context.href;
  }

  get href() {
    return this.#context.href;
  }

There is no difference?

Copy link
Member

Choose a reason for hiding this comment

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

As far as I can see this is a noop.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I forgot that I changed it a couple of months ago (#1955). Regardless, this removes the extra branch (and is faster)

@@ -117,7 +116,7 @@ class Response {
responseObject[kState].status = status

// 6. Let value be parsedURL, serialized and isomorphic encoded.
const value = isomorphicEncode(URLSerializer(parsedURL))
const value = isomorphicEncode(parsedURL.toString())
Copy link
Member Author

Choose a reason for hiding this comment

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

@ronag Same place in here too.

@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.02 ⚠️

Comparison is base (5f3b8e1) 90.39% compared to head (ea84a86) 90.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2045      +/-   ##
==========================================
- Coverage   90.39%   90.37%   -0.02%     
==========================================
  Files          71       71              
  Lines        6184     6183       -1     
==========================================
- Hits         5590     5588       -2     
- Misses        594      595       +1     
Impacted Files Coverage Δ
lib/fetch/request.js 87.98% <100.00%> (-0.06%) ⬇️
lib/fetch/response.js 95.83% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@anonrig anonrig closed this Apr 4, 2023
@anonrig anonrig deleted the remove-format branch April 4, 2023 13:19
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