Skip to content

path: skip resolve normalize for clean absolute paths - #66194

Open
anonrig wants to merge 1 commit into
nodejs:mainfrom
anonrig:cursor/path-simple-fast-ead2
Open

anonrig wants to merge 1 commit into
nodejs:mainfrom
anonrig:cursor/path-simple-fast-ead2

Conversation

@anonrig

@anonrig anonrig commented Sep 22, 2026

Copy link
Copy Markdown
Member

posix.resolve always runs normalizeString, even when the merged path has no . / .. segments and no empty // segments. Skip that pass and drop the trailing slash the join added. When process.cwd() fails, the relative path still goes through normalizeString so path.resolve() stays ..

Official benchmark/path/relative-posix.js (--no-node-snapshot, 5 alternating runs vs parent):

paths change
/data/orandea/test/aaa vs /data/orandea/impl/bbb +52%
/foo/bar/baz/quux vs /var/log +37%
/foo/bar/baz/quux vs / +25%
/foo/bar/baz/quux vs itself +5%
/ vs / +3%
/var vs /bin ~0%
/ vs /var -9%

test/parallel/test-path-resolve.js, test-path-relative.js, test-path-join.js, test-path-normalize.js, and test-path.js pass. A closed-source coding agent assisted with the implementation.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/path

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. labels Sep 22, 2026
posix.resolve always runs normalizeString, even when the merged
path has no '.' / '..' segments and no empty '//'. Skip that pass
and drop the trailing slash the join added.

Official benchmark/path/relative-posix.js is about 52% faster for
/data/orandea/test/aaa vs /data/orandea/impl/bbb, about 37% faster
for /foo/bar/baz/quux vs /var/log, and about 25% faster for
/foo/bar/baz/quux vs /. Paths that still need normalizeString are
within noise except a short double-slash join.

Assisted-by: a closed-source coding agent
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/path-simple-fast-ead2 branch from 81011ae to 62291aa Compare September 22, 2026 06:32
@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.27%. Comparing base (dd5dfb5) to head (62291aa).
⚠️ Report is 48 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #66194    +/-   ##
========================================
  Coverage   90.27%   90.27%            
========================================
  Files         790      790            
  Lines      271651   272544   +893     
  Branches    51842    52039   +197     
========================================
+ Hits       245228   246044   +816     
- Misses      16928    16958    +30     
- Partials     9495     9542    +47     
Files with missing lines Coverage Δ
lib/path.js 97.50% <100.00%> (+0.02%) ⬆️

... and 65 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants