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

url: fix performance regression #39778

Closed
wants to merge 1 commit into from

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Aug 16, 2021

This (mostly) fixes a performance regression introduced in e1e669b. While this PR does help, it doesn't completely restore performance levels pre- e1e669b but it's fairly close.

Example benchmark results:

                                                                       confidence improvement accuracy (*)   (**)  (***)
url/legacy-vs-whatwg-url-get-prop.js e=11 method='whatwg' type='auth'        ***     11.87 %       ±1.67% ±2.24% ±2.94%

/cc @jasnell

@mscdex mscdex added url Issues and PRs related to the legacy built-in url module. performance Issues and PRs related to the performance of Node.js. labels Aug 16, 2021
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Aug 16, 2021
@mscdex mscdex removed the needs-ci PRs that need a full CI run. label Aug 16, 2021
@nodejs-github-bot

This comment has been minimized.

@mscdex mscdex removed the url Issues and PRs related to the legacy built-in url module. label Aug 16, 2021
@@ -626,7 +626,7 @@ function onParseHashComplete(flags, protocol, username, password,
}

function isURLThis(self) {
return self?.[context] !== undefined;
return (self !== undefined && self !== null && self[context] !== undefined);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return (self !== undefined && self !== null && self[context] !== undefined);
return self != null && self[context] !== undefined;

Isn't this faster, or at least equivalent?


or like isURLSearchParams?

Copy link
Member

@devsnek devsnek left a comment

Choose a reason for hiding this comment

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

this is fascinating to me, as these two lines of code should generate identical graph representations

@Flarna Flarna added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 21, 2021
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 21, 2021
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

lpinca pushed a commit that referenced this pull request Aug 25, 2021
PR-URL: #39778
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
@lpinca
Copy link
Member

lpinca commented Aug 25, 2021

Landed in f581f6d.

@lpinca lpinca closed this Aug 25, 2021
@mscdex mscdex deleted the url-fix-perf-regression branch August 25, 2021 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

10 participants