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

fs: add c++ binding for readdirRecursiveSync #55722

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gurgunday
Copy link
Contributor

Creates a C++ binding for readdirRecursiveSync

My first ever C++ PR, so please have mercy, I might be doing silly/unnecessary operations 😄

It lowers the JS-C++ jumps significantly, from however many paths to 1 for each call

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Nov 4, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 76.19048% with 25 lines in your changes missing coverage. Please review.

Project coverage is 88.40%. Comparing base (32ff100) to head (3774a32).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/node_file.cc 73.68% 11 Missing and 14 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #55722    +/-   ##
========================================
  Coverage   88.39%   88.40%            
========================================
  Files         654      654            
  Lines      187560   187716   +156     
  Branches    36087    36127    +40     
========================================
+ Hits       165800   165956   +156     
- Misses      14996    14999     +3     
+ Partials     6764     6761     -3     
Files with missing lines Coverage Δ
lib/fs.js 98.12% <100.00%> (-0.02%) ⬇️
src/node_file.cc 77.11% <73.68%> (-0.18%) ⬇️

... and 35 files with indirect coverage changes

src/node_file.cc Outdated Show resolved Hide resolved
src/node_file.cc Outdated Show resolved Hide resolved
src/node_file.cc Outdated
uv_fs_req_cleanup(&req_wrap_sync.req);
}

Local<Array> result_array = Array::New(isolate,
Copy link
Member

Choose a reason for hiding this comment

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

creating an std::array, mutating them after the for loops below, and later assigning it to a Local might make the code more readable (and faster)

lib/fs.js Outdated Show resolved Hide resolved
lib/fs.js Show resolved Hide resolved
lib/fs.js Outdated Show resolved Hide resolved
@anonrig
Copy link
Member

anonrig commented Nov 5, 2024

Can you create a new benchmark in https://github.com/nodejs/node/blob/main/benchmark/fs folder?

@gurgunday
Copy link
Contributor Author

gurgunday commented Nov 5, 2024

I will add a benchmark later today

@gurgunday gurgunday force-pushed the readdirrecursivesync branch 6 times, most recently from 20d06ca to d89cb3c Compare November 5, 2024 19:02
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++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants