FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

url: improve invalid url performance by anonrig · Pull Request #49692 · nodejs/node · GitHub

/ node Public

url: improve invalid url performance - #49692

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:improve-invalid-url-performance
Sep 26, 2023
Merged

url: improve invalid url performance#49692
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:improve-invalid-url-performance

Conversation

anonrig commented Sep 17, 2023
edited
Loading

Copy link
Copy Markdown
Member

Some easy wins for Invalid URL path.

                                                    confidence improvement accuracy (*)   (**)  (***)
url/whatwg-url-validity.js e=100000 type='invalid'        ***    120.33 %       ±2.06% ±2.74% ±3.56%
url/whatwg-url-validity.js e=100000 type='valid'                   1.35 %       ±2.21% ±2.96% ±3.91%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 2 comparisons, you can thus expect the following amount of false-positive results:
  0.10 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.02 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

cc @nodejs/url @nodejs/performance

anonrig added performance Issues and PRs related to the performance of Node.js. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Sep 17, 2023

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/url

nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Sep 17, 2023
anonrig force-pushed the improve-invalid-url-performance branch from 0501c68 to 79415ed Compare September 17, 2023 21:36
anonrig added the semver-major PRs that contain breaking changes and should be released in the next major version. label Sep 17, 2023

anonrig commented Sep 17, 2023

Copy link
Copy Markdown
Member Author

@nodejs/tsc I've removed the error.input from URL error - ERR_INVALID_URL to make sure we share a similar output with Chrome and Safari. I've also added semver-major label because of the removal of error.input attribute.

Safari returns: TypeError: Type error
Chrome returns: VM78:1 Uncaught TypeError: Failed to construct 'URL': Invalid URL

None of them have the error.input attribute.

aduh95 commented Sep 17, 2023

Copy link
Copy Markdown
Contributor

I would keep the input, and even add the base, it can very hard to understand what is the error without seeing the input and base

Comment thread lib/internal/errors.js Outdated
rluvaton added the needs-benchmark-ci PR that need a benchmark CI run. label Sep 18, 2023

Copy link
Copy Markdown
Member

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

aduh95 commented Sep 18, 2023

Copy link
Copy Markdown
Contributor

Could there be a way to get the same performance improvements without removing helpful debugging information? If not, maybe we could use a flag to opt-in to the slower option that outputs the input and base?

anonrig commented Sep 18, 2023

Copy link
Copy Markdown
Member Author

Could there be a way to get the same performance improvements without removing helpful debugging information? If not, maybe we could use a flag to opt-in to the slower option that outputs the input and base?

Probably, although I'm not sure. This requires a similar approach to what ThrowAccessDenied is doing in https://github.com/nodejs/node/blob/main/src/permission/permission.cc#L102.

anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 18, 2023
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 18, 2023

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Member

FWIW, I tend to agree with @aduh95 that removing error information for the sake of performance (on an error path!) does not benefit users. I thought that URL.canParse() was specifically added to avoid having to rely on the performance of the URL error path.

Uzlopak commented Sep 19, 2023

Copy link
Copy Markdown
Contributor

How much is actually the performance hit when keeping the input as an attribute?

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I do not think it's a good idea to remove important debug information in favor of performance. We can definitely improve the performance but debug information is more important. I had an open PR to improve the situation a lot and I have to get back to that again.

anonrig force-pushed the improve-invalid-url-performance branch from 147dd75 to a9c408a Compare September 19, 2023 22:30

anonrig commented Sep 19, 2023

Copy link
Copy Markdown
Member Author

@BridgeAR @aduh95 @tniessen I've updated the implementation. Previously this pull request was 142% faster than main. Right now it is 120% faster. I also added base field to the error object.

Appreciate it, if you can review it once again.

anonrig force-pushed the improve-invalid-url-performance branch from a9c408a to 29267d9 Compare September 19, 2023 22:32
anonrig requested a review from BridgeAR September 19, 2023 22:33
anonrig force-pushed the improve-invalid-url-performance branch from 29267d9 to c59b136 Compare September 19, 2023 22:38
anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 20, 2023
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 20, 2023

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

anonrig commented Sep 22, 2023

Copy link
Copy Markdown
Member Author

Hey @BridgeAR, can you re-review this pull request, and remove your block?

Copy link
Copy Markdown
Member

I suspect he would still object since the URL isn't part of the message string, what's the cost of adding that back?

anonrig commented Sep 23, 2023
edited
Loading

Copy link
Copy Markdown
Member Author

I suspect he would still object since the URL isn't part of the message string, what's the cost of adding that back?

I don't follow. URL was never part of the message string? Input is a property of the error object. On top of that I've also added base property to the error as well.

Copy link
Copy Markdown
Member

@anonrig ah, I'm probably mixing it up with another PR then, lgtm

anonrig added the tsc-agenda Issues and PRs to discuss during the meetings of the TSC. label Sep 26, 2023

anonrig commented Sep 26, 2023

Copy link
Copy Markdown
Member Author

Adding to @nodejs/tsc agenda to resolve the block.

targos commented Sep 26, 2023

Copy link
Copy Markdown
Member

There's no need for the TSC to intervene if you addressed the blocking comment

anonrig dismissed BridgeAR’s stale review September 26, 2023 15:32

The comment is addressed.

anonrig added commit-queue Add this label to land a pull request using GitHub Actions. and removed tsc-agenda Issues and PRs to discuss during the meetings of the TSC. labels Sep 26, 2023
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 26, 2023
nodejs-github-bot merged commit c829c03 into nodejs:main Sep 26, 2023

Copy link
Copy Markdown
Collaborator

Landed in c829c03

ruyadorno pushed a commit that referenced this pull request Sep 28, 2023
PR-URL: #49692
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
ruyadorno mentioned this pull request Sep 28, 2023
ruyadorno pushed a commit that referenced this pull request Sep 28, 2023
PR-URL: #49692
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
ruyadorno mentioned this pull request Sep 28, 2023
debadree25 pushed a commit to debadree25/node that referenced this pull request Apr 15, 2024
PR-URL: nodejs#49692
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL