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

path: fix POSIX path.resolve() perf regression #38064

Closed

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Apr 3, 2021

b0d5e03 introduced an unnecessary performance regression when using path.resolve() on POSIX systems. This commit both removes that regression in that situation and reduces the performance hit when path.posix.resolve() is used directly/indirectly on Windows systems.

The following benchmark results come from a Linux system:

After b0d5e03:

                                                                           confidence improvement accuracy (*)   (**)  (***)
path/resolve-posix.jsn=1000000 paths=''                                          ***    -54.27 %       ±0.94% ±1.26% ±1.65%
path/resolve-posix.jsn=1000000 paths='|'                                         ***    -54.97 %       ±1.07% ±1.43% ±1.86%
path/resolve-posix.jsn=1000000 paths='a/b/c/|../../..'                           ***    -34.18 %       ±0.86% ±1.15% ±1.50%
path/resolve-posix.jsn=1000000 paths='foo/bar|/tmp/file/|..|a/../subfile'        ***      8.11 %       ±1.55% ±2.07% ±2.71%

After the new implementation (basically caching the regexp):

                                                                           confidence improvement accuracy (*)   (**)  (***)
path/resolve-posix.jsn=1000000 paths=''                                          ***    -12.13 %       ±1.60% ±2.13% ±2.78%
path/resolve-posix.jsn=1000000 paths='|'                                         ***    -11.08 %       ±1.37% ±1.82% ±2.37%
path/resolve-posix.jsn=1000000 paths='a/b/c/|../../..'                           ***     -6.80 %       ±1.05% ±1.40% ±1.83%
path/resolve-posix.jsn=1000000 paths='foo/bar|/tmp/file/|..|a/../subfile'        ***      7.86 %       ±1.40% ±1.87% ±2.44%

After avoiding the transformations from b0d5e03 for POSIX systems (I'm not sure why there is a performance increase in this case, as I would have expected zero or close to zero change, but that's V8 for you):

                                                                           confidence improvement accuracy (*)   (**)  (***)
path/resolve-posix.jsn=1000000 paths=''                                          ***      9.13 %       ±1.16% ±1.54% ±2.01%
path/resolve-posix.jsn=1000000 paths='|'                                         ***      8.69 %       ±1.13% ±1.51% ±1.97%
path/resolve-posix.jsn=1000000 paths='a/b/c/|../../..'                           ***      4.82 %       ±0.91% ±1.21% ±1.58%
path/resolve-posix.jsn=1000000 paths='foo/bar|/tmp/file/|..|a/../subfile'        ***      8.62 %       ±1.24% ±1.66% ±2.17%

/cc @Trott @mcollina

@mscdex mscdex added path Issues and PRs related to the path subsystem. performance Issues and PRs related to the performance of Node.js. labels Apr 3, 2021
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 3, 2021
@nodejs-github-bot

This comment has been minimized.

@mscdex mscdex force-pushed the path-resolve-fix-perf-regression branch from ed62b39 to 7b1cc3d Compare April 4, 2021 03:30
@nodejs-github-bot

This comment has been minimized.

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

@mscdex mscdex added the wip Issues and PRs that are still a work in progress. label Apr 4, 2021
@mscdex mscdex force-pushed the path-resolve-fix-perf-regression branch from 7b1cc3d to 02deafb Compare April 4, 2021 16:24
@nodejs-github-bot
Copy link
Collaborator

@mscdex mscdex removed the wip Issues and PRs that are still a work in progress. label Apr 4, 2021
@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Apr 5, 2021

Fast-track to get this into the 15.14.0 release that's happening in another day-and-a-half or so?

@Trott Trott mentioned this pull request Apr 5, 2021
@targos targos added the fast-track PRs that do not need to wait for 48 hours to land. label Apr 5, 2021
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Apr 6, 2021

Landed in e38d62a.

@Trott Trott closed this Apr 6, 2021
Trott pushed a commit that referenced this pull request Apr 6, 2021
PR-URL: #38064
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@mscdex mscdex deleted the path-resolve-fix-perf-regression branch April 6, 2021 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fast-track PRs that do not need to wait for 48 hours to land. needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants