Skip to content

Speed up getAccessibleFileSystemEntries #36139

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

Closed
wants to merge 3 commits into from

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented Jan 11, 2020

While writing a benchmark, I happened to notice that (a) the natural
win32 APIs for this task include "isDirectory" in the result and (b)
readDirSync will return entries, rather than strings, if you pass
withFileTypes. It turns out this version, which allows us to dispense
with path math and stat calls is ~20X faster (enumerating a directory
with 600 children).

While writing a benchmark, I happened to notice that (a) the natural
win32 APIs for this task include "isDirectory" in the result and (b)
readDirSync will return entries, rather than strings, if you pass
withFileTypes.  It turns out this version, which allows us to dispense
with path math and stat calls is ~30X faster (enumerating a directory
with 600 children).
@minestarks
Copy link
Member

Struggling to find an emoji to express my joy

@amcasey
Copy link
Member Author

amcasey commented Jan 11, 2020

On Node 8 on Linux, the flag is ignored and strings are returned regardless.

@amcasey
Copy link
Member Author

amcasey commented Jan 11, 2020

Node 10 on Linux shows a ~5X improvement, so it's probably worth finding a way to special case Node 8 on Linux.

@amcasey amcasey requested a review from sheetalkamat January 11, 2020 03:46
@ajafff
Copy link
Contributor

ajafff commented Jan 11, 2020

There's already a PR to use withFileTypes which is waiting for review for a few weeks.

@amcasey
Copy link
Member Author

amcasey commented Jan 13, 2020

@ajafff Thanks for the link! Closing in favor of #35286.

@amcasey amcasey closed this Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants