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

perf: improve isFileReadable performance #6868

Merged
merged 2 commits into from Feb 13, 2022

Conversation

Demivan
Copy link
Contributor

@Demivan Demivan commented Feb 11, 2022

Description

accessSync used in isFileReadable is slow because it throws and Node spends significant time generating stack trace.
This PR uses statSync with throwIfNoEntry: false parameter to make it not throw.

Build performance improvement on my machine was around 10%.

Additional context

After profiling Vite 2.7 I found that resolve package is slow. After updating Vite, performance issue with resolve package was fixed, but I saw the same stack trace in Vite code. Tracked down resolve solution to this issue browserify/resolve#255. Backported this solution to Vite.

I could not find mentioned in the comment issue to test for that case. #2051 looks completely unrelated.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Niputi Niputi added the p4-important Violate documented behavior or significantly improves performance (priority) label Feb 11, 2022
patak-dev
patak-dev previously approved these changes Feb 11, 2022
@patak-dev
Copy link
Member

This looks great, and I think we can get it in the next patch. Thanks @Demivan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants