Skip to content

Speed up getAccessibleFileSystemEntries - #36139

Closed
Andrew Casey (amcasey) wants to merge 3 commits into
microsoft:masterfrom
amcasey:FastReadDir
Closed

Speed up getAccessibleFileSystemEntries#36139
Andrew Casey (amcasey) wants to merge 3 commits into
microsoft:masterfrom
amcasey:FastReadDir

Conversation

@amcasey

@amcaseyAndrew Casey (amcasey) commented Jan 11, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor

Struggling to find an emoji to express my joy

@amcasey

Copy link
Copy Markdown
MemberAuthor

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

@amcasey

Copy link
Copy Markdown
MemberAuthor

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

@ajafff

Copy link
Copy Markdown
Contributor

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

@amcasey

Copy link
Copy Markdown
MemberAuthor

Klaus Meinhardt (@ajafff) Thanks for the link! Closing in favor of #35286.

@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
@typescript-bot

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@amcasey@minestarks@ajafff@typescript-bot