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 win32 volume-relative paths #14440

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
6 participants
@TimothyGu
Member

TimothyGu commented Jul 24, 2017

path.resolve() and path.join() are left alone in this commit due to
a lack of clear semantics.

Fixes: #14405

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

path

@tniessen

Thanks for working on this!

Show outdated Hide outdated test/parallel/test-path-parse-format.js
['C:abc', 'C:'],
['C:\\', 'C:\\'],
['C:\\abc', 'C:\\' ],
['', ''],

This comment has been minimized.

@tniessen

tniessen Jul 24, 2017

Member

Could you add tests for NTFS alterate streams? e.g. ['cd:foo', '']. Not just to test root, but also the other properties used in checkParseFormat.

@tniessen

tniessen Jul 24, 2017

Member

Could you add tests for NTFS alterate streams? e.g. ['cd:foo', '']. Not just to test root, but also the other properties used in checkParseFormat.

assert.strictEqual(path.win32.basename('C:basename.ext'), 'basename.ext');
assert.strictEqual(path.win32.basename('C:basename.ext\\'), 'basename.ext');
assert.strictEqual(path.win32.basename('C:basename.ext\\\\'), 'basename.ext');
assert.strictEqual(path.win32.basename('C:foo'), 'foo');

This comment has been minimized.

@tniessen

tniessen Jul 24, 2017

Member

Again, a test for NTFS alternate streams would be nice: basename('cd:foo') === 'cd:foo'

@tniessen

tniessen Jul 24, 2017

Member

Again, a test for NTFS alternate streams would be nice: basename('cd:foo') === 'cd:foo'

@refack

refack approved these changes Jul 24, 2017

Show outdated Hide outdated test/parallel/test-path-parse-format.js
@@ -406,6 +422,11 @@ assert.strictEqual(path.win32.normalize('a//b//.'), 'a\\b');
assert.strictEqual(path.win32.normalize('//server/share/dir/file.ext'),
'\\\\server\\share\\dir\\file.ext');
assert.strictEqual(path.win32.normalize('/a/b/c/../../../x/y/z'), '\\x\\y\\z');

This comment has been minimized.

@refack

refack Jul 24, 2017

Member

Optional:

Could you parameterize this part like the others are:

[[a,b]].forEach(([tested, expected]) => ...

(not the scope of this PR but still would be nice)

@refack

refack Jul 24, 2017

Member

Optional:

Could you parameterize this part like the others are:

[[a,b]].forEach(([tested, expected]) => ...

(not the scope of this PR but still would be nice)

This comment has been minimized.

@TimothyGu

TimothyGu Jul 25, 2017

Member

I'd rather leave that to a dedicated PR, as there are many other tests that do not use this pattern in the file.

@TimothyGu

TimothyGu Jul 25, 2017

Member

I'd rather leave that to a dedicated PR, as there are many other tests that do not use this pattern in the file.

Show outdated Hide outdated test/parallel/test-path-parse-format.js
@refack

This comment has been minimized.

Show comment
Hide comment
@refack

refack Jul 24, 2017

Member

@TimothyGu could you run performance comparison, just for reference?
(minimal set could be with --filter parse path i.e. node benchmark/compare.js --old .\nodefwithout.exe --new Release\nodewith.exe --filter parse path > path.csv)

Member

refack commented Jul 24, 2017

@TimothyGu could you run performance comparison, just for reference?
(minimal set could be with --filter parse path i.e. node benchmark/compare.js --old .\nodefwithout.exe --new Release\nodewith.exe --filter parse path > path.csv)

@refack

This comment has been minimized.

Show comment
Hide comment
@refack

refack Jul 24, 2017

Member

P.S. thanks for doing this 👍! Playing with path is not exactly a fun time...

Member

refack commented Jul 24, 2017

P.S. thanks for doing this 👍! Playing with path is not exactly a fun time...

@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu

TimothyGu Jul 25, 2017

Member

@refack For good measure:

$ node benchmark/compare.js --old ./node-master --new ./node-14440 --runs 10 --filter parse-win32 path > path-win32.csv
$ Rscript benchmark/compare.R < path-win32.csv 
                                                                             improvement confidence      p.value
 path/parse-win32.js n=1000000 path=""                                           -1.44 %            1.527455e-01
 path/parse-win32.js n=1000000 path="\\\\foo"                                    29.10 %        *** 4.505598e-07
 path/parse-win32.js n=1000000 path="\\\\foo\\\\bar\\\\baz\\\\asdf\\\\.quux"      3.27 %        *** 7.782213e-11
 path/parse-win32.js n=1000000 path="C:\\\\"                                      0.36 %            2.234293e-01
 path/parse-win32.js n=1000000 path="C:\\\\foo"                                  33.79 %        *** 5.225296e-12
 path/parse-win32.js n=1000000 path="E:\\\\foo\\\\bar.baz"                        0.09 %            7.339049e-01
 path/parse-win32.js n=1000000 path="foo\\\\.bar.baz"                             1.26 %        *** 3.623360e-06
 path/parse-win32.js n=1000000 path="foo\\\\bar"                                 -0.14 %            6.443696e-01
Member

TimothyGu commented Jul 25, 2017

@refack For good measure:

$ node benchmark/compare.js --old ./node-master --new ./node-14440 --runs 10 --filter parse-win32 path > path-win32.csv
$ Rscript benchmark/compare.R < path-win32.csv 
                                                                             improvement confidence      p.value
 path/parse-win32.js n=1000000 path=""                                           -1.44 %            1.527455e-01
 path/parse-win32.js n=1000000 path="\\\\foo"                                    29.10 %        *** 4.505598e-07
 path/parse-win32.js n=1000000 path="\\\\foo\\\\bar\\\\baz\\\\asdf\\\\.quux"      3.27 %        *** 7.782213e-11
 path/parse-win32.js n=1000000 path="C:\\\\"                                      0.36 %            2.234293e-01
 path/parse-win32.js n=1000000 path="C:\\\\foo"                                  33.79 %        *** 5.225296e-12
 path/parse-win32.js n=1000000 path="E:\\\\foo\\\\bar.baz"                        0.09 %            7.339049e-01
 path/parse-win32.js n=1000000 path="foo\\\\.bar.baz"                             1.26 %        *** 3.623360e-06
 path/parse-win32.js n=1000000 path="foo\\\\bar"                                 -0.14 %            6.443696e-01
@refack

refack approved these changes Jul 25, 2017

Thank you

@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu

TimothyGu Jul 25, 2017

Member

However:

                                                                                                improvement confidence      p.value
 path/extname-win32.js n=1000000 path=""                                                           -74.64 %        *** 1.674087e-26
 path/extname-win32.js n=1000000 path="\\\\"                                                        -4.91 %        *** 1.755024e-07
 path/extname-win32.js n=1000000 path="\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.foobarbazasdfquux"     -7.25 %        *** 1.823382e-05
 path/extname-win32.js n=1000000 path="C:\\\\foo"                                                  -21.36 %        *** 5.547522e-18
 path/extname-win32.js n=1000000 path="D:\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux"                    -23.40 %        *** 3.036449e-06
 path/extname-win32.js n=1000000 path="foo\\\\.bar.baz"                                             -7.85 %        *** 1.491586e-14
 path/extname-win32.js n=1000000 path="foo\\\\bar\\\\...baz.quux"                                  -12.20 %        *** 4.673165e-05
 path/extname-win32.js n=1000000 path="foo\\\\bar\\\\..baz.quux"                                   -11.68 %        *** 1.828409e-13
 path/extname-win32.js n=1000000 path="index.html"                                                  -8.17 %        *** 1.836566e-09
 path/extname-win32.js n=1000000 path="index"                                                       -7.79 %          * 2.396233e-02

There isn't anything I can do to improve the worst case (path=""). On the other hand, two factors alleviate the drastic change:

  • The same piece of code is in basename() already.
  • V8 5.9 used in master is known to not handle charCodeAt() well, and Node.js canary which has V8 6.1 restores the original performance for that benchmark while making all other benchmarks faster as well.
Member

TimothyGu commented Jul 25, 2017

However:

                                                                                                improvement confidence      p.value
 path/extname-win32.js n=1000000 path=""                                                           -74.64 %        *** 1.674087e-26
 path/extname-win32.js n=1000000 path="\\\\"                                                        -4.91 %        *** 1.755024e-07
 path/extname-win32.js n=1000000 path="\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux.foobarbazasdfquux"     -7.25 %        *** 1.823382e-05
 path/extname-win32.js n=1000000 path="C:\\\\foo"                                                  -21.36 %        *** 5.547522e-18
 path/extname-win32.js n=1000000 path="D:\\\\foo\\\\bar\\\\baz\\\\asdf\\\\quux"                    -23.40 %        *** 3.036449e-06
 path/extname-win32.js n=1000000 path="foo\\\\.bar.baz"                                             -7.85 %        *** 1.491586e-14
 path/extname-win32.js n=1000000 path="foo\\\\bar\\\\...baz.quux"                                  -12.20 %        *** 4.673165e-05
 path/extname-win32.js n=1000000 path="foo\\\\bar\\\\..baz.quux"                                   -11.68 %        *** 1.828409e-13
 path/extname-win32.js n=1000000 path="index.html"                                                  -8.17 %        *** 1.836566e-09
 path/extname-win32.js n=1000000 path="index"                                                       -7.79 %          * 2.396233e-02

There isn't anything I can do to improve the worst case (path=""). On the other hand, two factors alleviate the drastic change:

  • The same piece of code is in basename() already.
  • V8 5.9 used in master is known to not handle charCodeAt() well, and Node.js canary which has V8 6.1 restores the original performance for that benchmark while making all other benchmarks faster as well.
@refack

This comment has been minimized.

Show comment
Hide comment
@refack

refack Jul 25, 2017

Member

There isn't anything I can do to improve the worst case (path=""). On the other hand, two factors alleviate the drastic change:

Since this is a bug fix IMHO we can absorb the performance degradation for this case. Especially since the most common case doesn't take a bit hit (and the absolute numbers are probably tiny anyway):

 path/extname-win32.js n=1000000 path="index.html"              -8.17 %        *** 1.836566e-09
Member

refack commented Jul 25, 2017

There isn't anything I can do to improve the worst case (path=""). On the other hand, two factors alleviate the drastic change:

Since this is a bug fix IMHO we can absorb the performance degradation for this case. Especially since the most common case doesn't take a bit hit (and the absolute numbers are probably tiny anyway):

 path/extname-win32.js n=1000000 path="index.html"              -8.17 %        *** 1.836566e-09
@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Jul 26, 2017

Member

@TimothyGu This would need to be rebased ;)

Member

addaleax commented Jul 26, 2017

@TimothyGu This would need to be rebased ;)

@tniessen

This comment has been minimized.

Show comment
Hide comment
@tniessen

tniessen Jul 26, 2017

Member

@TimothyGu My bad, sorry, I landed f7f590c this morning. You can safely drop my changes to winPaths.

Member

tniessen commented Jul 26, 2017

@TimothyGu My bad, sorry, I landed f7f590c this morning. You can safely drop my changes to winPaths.

path: fix win32 volume-relative paths
`path.resolve()` and `path.join()` are left alone in this commit due to
the lack of clear semantics.

Fixes: #14405
@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu

TimothyGu Jul 28, 2017

Member

@addaleax @tniessen Rebased. I compared and cherry-picked some changes in f7f590c not already in test-path.js, so this should benefit other path.* functions as well.

Member

TimothyGu commented Jul 28, 2017

@addaleax @tniessen Rebased. I compared and cherry-picked some changes in f7f590c not already in test-path.js, so this should benefit other path.* functions as well.

@tniessen

tniessen approved these changes Jul 30, 2017 edited

LGTM, no opinion on performance. Thanks for fixing this :)

@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu

TimothyGu Jul 30, 2017

Member

Landed in 2791761.

Member

TimothyGu commented Jul 30, 2017

Landed in 2791761.

@TimothyGu TimothyGu closed this Jul 30, 2017

@TimothyGu TimothyGu deleted the TimothyGu:path-win32 branch Jul 30, 2017

TimothyGu added a commit that referenced this pull request Jul 30, 2017

path: fix win32 volume-relative paths
`path.resolve()` and `path.join()` are left alone in this commit due to
the lack of clear semantics.

PR-URL: #14440
Fixes: #14405
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

addaleax added a commit that referenced this pull request Aug 1, 2017

path: fix win32 volume-relative paths
`path.resolve()` and `path.join()` are left alone in this commit due to
the lack of clear semantics.

PR-URL: #14440
Fixes: #14405
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

@addaleax addaleax referenced this pull request Aug 2, 2017

Merged

v8.3.0 proposal #14594

@MylesBorins

This comment has been minimized.

Show comment
Hide comment
@MylesBorins

MylesBorins Aug 11, 2017

Member

This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported

Member

MylesBorins commented Aug 11, 2017

This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported

@TimothyGu

This comment has been minimized.

Show comment
Hide comment
@TimothyGu
Member

TimothyGu commented Aug 12, 2017

MylesBorins added a commit that referenced this pull request Aug 14, 2017

path: fix win32 volume-relative paths
`path.resolve()` and `path.join()` are left alone in this commit due to
the lack of clear semantics.

Backport-PR-URL: #14787
PR-URL: #14440
Fixes: #14405
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

MylesBorins added a commit that referenced this pull request Aug 16, 2017

path: fix win32 volume-relative paths
`path.resolve()` and `path.join()` are left alone in this commit due to
the lack of clear semantics.

Backport-PR-URL: #14787
PR-URL: #14440
Fixes: #14405
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

@MylesBorins MylesBorins referenced this pull request Aug 16, 2017

Merged

v6.11.3-proposal #14852

MylesBorins added a commit that referenced this pull request Sep 5, 2017

2017-09-05, Version 6.11.3 'Boron' (LTS)
This LTS release comes with 152 commits. This includes 75 which are
test related, 25 which are doc related, 21 which are build / tool
related and 3 commits which are updates to dependencies.

Notable Changes:

* build:
 - Codesigning is fixed on macOS (Evan Lucas)
   #14179
* deps:
 - Snapshots are turned back on!!! (Yang Guo)
   #14385
* path:
 - win32 volume-relative paths are working again! (Timothy Gu)
   #14440
* tools:
 - v6.x can now build with ICU 59 (Steven R. Loomis)
   #12078

PR-URL: #14852

MylesBorins added a commit that referenced this pull request Sep 5, 2017

2017-09-05, Version 6.11.3 'Boron' (LTS)
This LTS release comes with 152 commits. This includes 75 which are
test related, 25 which are doc related, 21 which are build / tool
related and 3 commits which are updates to dependencies.

Notable Changes:

* build:
 - Codesigning is fixed on macOS (Evan Lucas)
   #14179
* deps:
 - Snapshots are turned back on!!! (Yang Guo)
   #14385
* path:
 - win32 volume-relative paths are working again! (Timothy Gu)
   #14440
* tools:
 - v6.x can now build with ICU 59 (Steven R. Loomis)
   #12078

PR-URL: #14852

MylesBorins added a commit that referenced this pull request Sep 5, 2017

2017-09-05, Version 6.11.3 'Boron' (LTS)
This LTS release comes with 152 commits. This includes 75 which are
test related, 25 which are doc related, 21 which are build / tool
related and 3 commits which are updates to dependencies.

Notable Changes:

* build:
 - Codesigning is fixed on macOS (Evan Lucas)
   #14179
* deps:
 - Snapshots are turned back on!!! (Yang Guo)
   #14385
* path:
 - win32 volume-relative paths are working again! (Timothy Gu)
   #14440
* tools:
 - v6.x can now build with ICU 59 (Steven R. Loomis)
   #12078

PR-URL: #14852

antoine-amara pushed a commit to antoine-amara/node that referenced this pull request Sep 7, 2017

2017-09-05, Version 6.11.3 'Boron' (LTS)
This LTS release comes with 152 commits. This includes 75 which are
test related, 25 which are doc related, 21 which are build / tool
related and 3 commits which are updates to dependencies.

Notable Changes:

* build:
 - Codesigning is fixed on macOS (Evan Lucas)
   nodejs#14179
* deps:
 - Snapshots are turned back on!!! (Yang Guo)
   nodejs#14385
* path:
 - win32 volume-relative paths are working again! (Timothy Gu)
   nodejs#14440
* tools:
 - v6.x can now build with ICU 59 (Steven R. Loomis)
   nodejs#12078

PR-URL: nodejs#14852

addaleax added a commit to addaleax/node that referenced this pull request Sep 13, 2017

2017-09-05, Version 6.11.3 'Boron' (LTS)
This LTS release comes with 152 commits. This includes 75 which are
test related, 25 which are doc related, 21 which are build / tool
related and 3 commits which are updates to dependencies.

Notable Changes:

* build:
 - Codesigning is fixed on macOS (Evan Lucas)
   nodejs#14179
* deps:
 - Snapshots are turned back on!!! (Yang Guo)
   nodejs#14385
* path:
 - win32 volume-relative paths are working again! (Timothy Gu)
   nodejs#14440
* tools:
 - v6.x can now build with ICU 59 (Steven R. Loomis)
   nodejs#12078

PR-URL: nodejs#14852
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment