X Tutup
The Wayback Machine - https://web.archive.org/web/20220610043145/https://github.com/angular/angular/pull/46069
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(bazel): use allowedInputs to avoid fs.stat #46069

Closed
wants to merge 1 commit into from

Conversation

frigus02
Copy link
Contributor

@frigus02 frigus02 commented May 20, 2022

PR Checklist

Regarding tests: Do you have a way to test for file system calls during compilation?

PR Type

  • Build related changes

What is the current behavior?

ngc-wrapped calls TypeScript's fileExists function during module resolution, which calls fs.statSync.

File system calls can be quite slow depending on the file system. In google3 I saw a 38 seconds compilation, which spent 6 seconds just doing fs.stat calls during module resolution.

What is the new behavior?

Call tsc_wrapped's fileExists function instead of TypeScript's.

tsc_wrapped (used internally by ngc-wrapped) has an optimization under bazel to avoid file system calls where possible. It takes advantage bazelOpts.allowedInputs, which contains a list of all files available for compilation.

The fs.stat calls mentioned for the slow google3 target are entirely gone after with this change.

Does this PR introduce a breaking change?

  • No

Call tsc_wrapped's fileExists function instead of TypeScript's.

tsc_wrapped (used internally by ngc-wrapped) has an optimization under
bazel to avoid file system calls where possible. It takes advantage
bazelOpts.allowedInputs, which contains a list of all files available
for compilation.

File system calls can be quite slow depending on the file system. In
google3 I saw a 38 seconds compilation, which spent 6 seconds just doing
fs.stat calls during module resolution. Those fs.stat calls are entirely
gone after with this change.
@pullapprove pullapprove bot requested a review from devversion May 20, 2022
@frigus02
Copy link
Contributor Author

@frigus02 frigus02 commented May 20, 2022

Here are screenshots of a CPU profile before and after the change:

Before After
biggest contributor to execution time is statSync with ~6s, after that is openSync with 800ms statSync is gone. biggest contributors are now scan with 900ms and openSync with 800ms

More details are in an internal ticket: http://b/232199273#comment2

@devversion devversion added action: merge action: presubmit target: rc comp: bazel labels May 20, 2022
@ngbot ngbot bot added this to the Backlog milestone May 20, 2022
@devversion
Copy link
Member

@devversion devversion commented May 20, 2022

Presubmit: cl/449952536 (we want to wait for a TGP)

@devversion devversion added action: merge and removed action: presubmit action: merge labels May 20, 2022
@alxhub
Copy link
Contributor

@alxhub alxhub commented May 24, 2022

This PR was merged into the repository by commit 7efa09b.

alxhub pushed a commit that referenced this issue May 24, 2022
Call tsc_wrapped's fileExists function instead of TypeScript's.

tsc_wrapped (used internally by ngc-wrapped) has an optimization under
bazel to avoid file system calls where possible. It takes advantage
bazelOpts.allowedInputs, which contains a list of all files available
for compilation.

File system calls can be quite slow depending on the file system. In
google3 I saw a 38 seconds compilation, which spent 6 seconds just doing
fs.stat calls during module resolution. Those fs.stat calls are entirely
gone after with this change.

PR Close #46069
@frigus02 frigus02 deleted the optimize-fileexists branch May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge comp: bazel target: rc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants
X Tutup