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

Write tmp files to the OS tmp directory #9580

Merged
merged 3 commits into from
Mar 14, 2024
Merged

Write tmp files to the OS tmp directory #9580

merged 3 commits into from
Mar 14, 2024

Conversation

mattcompiles
Copy link
Contributor

↪️ Pull Request

This PR attempts to utilize the OS tmp directory for temporary files when streaming content to files. This greatly reduces the amount of events the watcher needs to process during the build. We only use the tmp directory when the following are true:

  • The process has read/write access to the tmp directory
  • The tmp directory is on the same partition as the target directory

🚨 Test instructions

We've tested this approach extensively internally.

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

let useOsTmpDir;
function shouldUseOsTmpDir(filePath) {
if (useOsTmpDir != null) {
return useOsTmpDir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there's a tiny risk the /tmp directory becomes un-usable between the first check and the first write, but that seems pretty unlikely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't even imagine how that would happen. I'm comfortable with a single check.

packages/core/fs/src/NodeFS.js Outdated Show resolved Hide resolved
@mattcompiles mattcompiles merged commit d56bf45 into v2 Mar 14, 2024
16 checks passed
@mattcompiles mattcompiles deleted the use-os-tmp-dir branch March 14, 2024 04:08
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.

3 participants