Skip to content

fs: reduce glob section allocations - #66716

Open
rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:fs-reduce-glob-section-allocations
Open

rozzilla wants to merge 1 commit into
nodejs:mainfrom
rozzilla:fs-reduce-glob-section-allocations

Conversation

@rozzilla

Copy link
Copy Markdown
Contributor

Store non-globstar prefix counts in section records instead of a separate vector, avoiding its allocations during multi-globstar matching. Matching bounds use the same counts; matching behavior and recursion limits are unchanged. Add regression coverage and benchmarks for multi-globstar matching and in-memory path filtering.

Measured against ea6ec93 on Apple M2, macOS arm64, Node v27.0.0-pre, V8 15.5.35.22-node.15.

Filtering throughput changes below include unadjusted 95% confidence-interval half-widths. Reverse runs swap baseline and candidate labels.

Pattern Path syntax Candidate vs baseline Reverse: baseline vs candidate
**/node_modules/**/test/** POSIX +26.57% +/- 1.33% -20.81% +/- 1.04%
**/src/** POSIX +11.52% +/- 1.10% -9.63% +/- 2.40%
**/node_modules/**/test/** Windows +18.36% +/- 1.47% -15.96% +/- 1.19%
**/src/** Windows +12.52% +/- 1.82% -10.44% +/- 1.64%

The 16 multi-globstar hit/miss microbenchmarks improve 18.73-37.88% in the forward comparison, with every gain confirmed in reverse.

Across 30 configurations, each direction used 30 independent samples per binary: 3,600 samples total. All 20 targeted gains remain significant after Holm correction in both directions; neither direction shows a corrected-significant regression.

Store prefix counts in section records to avoid a separate vector
and its allocations during multi-globstar matching.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/path
  • @nodejs/performance

@nodejs-github-bot 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 Oct 14, 2026
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.48%. Comparing base (3f0c2e4) to head (60d8a41).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66716   +/-   ##
=======================================
  Coverage   90.48%   90.48%           
=======================================
  Files         791      791           
  Lines      277204   277210    +6     
  Branches    53309    53317    +8     
=======================================
+ Hits       250827   250833    +6     
- Misses      16789    16805   +16     
+ Partials     9588     9572   -16     
Files with missing lines Coverage Δ
src/glob/glob_matcher.cc 66.86% <100.00%> (+0.06%) ⬆️

... and 31 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.

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

lgtm

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-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants