-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Stop pre-emptively creating directories #34521
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
Conversation
Checking for directory existence is expensive and frequently indicates success. Instead of pre-emptively creating the directory containing a file to be written, attempt to create the file and only do the directory scaffolding if the write fails. Appears to reduce file write time by 10-20% for a file-I/O heavy partner build. Thanks to @rbuckton for the suggestion!
@typescript-bot perf test |
Heya @amcasey, I've started to run the perf test suite on this PR at b6659e5. You can monitor the build here. It should now contribute to this PR's status checks. Update: The results are in! |
@amcasey Here they are:Comparison Report - master..34521
System
Hosts
Scenarios
|
👍 but get sign off from others. |
src/compiler/program.ts
Outdated
fileName, | ||
data, | ||
writeByteOrderMark, | ||
(f, d, w) => writeFileWorker(f, d, w), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter names seem not very friendly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to convey that they're just threaded through to writeFileWorker
. If full names are more conventional, I'm happy to expand them.
Checking for directory existence is expensive and frequently indicates success. Instead of pre-emptively creating the directory containing a file to be written, attempt to create the file and only do the directory scaffolding if the write fails.
Appears to reduce file write time by 10-20% for a file-I/O heavy partner build.
Thanks to @rbuckton for the suggestion!