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

Use UV_FS_COPYFILE_FICLONE flag in fs.copyFile when available #6302

Merged
merged 3 commits into from
Sep 5, 2018

Conversation

as-com
Copy link
Contributor

@as-com as-com commented Aug 22, 2018

Summary

Fixes #5456.

This flag increases performance and saves disk space on COW filesystems that support this flag (APFS, btrfs). On my machine running High Sierra, this decreases yarn install --offline time from 9.24s to 6.89s for a project with a lot of dependencies.

Test plan

  • yarn run test passes

@@ -38,7 +38,7 @@ export const unlink: (path: string) => Promise<void> = promisify(require('rimraf
export const copyFile = async function(data: CopyFileAction, cleanup: () => mixed): Promise<void> {
try {
await unlink(data.dest);
await copyFilePoly(data.src, data.dest, 0, data);
await copyFilePoly(data.src, data.dest, (fs.constants: any).COPYFILE_FICLONE || 0, data);
Copy link
Member

@Gudahtt Gudahtt Aug 27, 2018

Choose a reason for hiding this comment

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

Hmm. This is unfortunate.

The flow error you're suppressing here is because Flow's built-in types for Node.js are missing this constant. I have submitted a PR to Flow to fix this, but even if that gets merged and released we can't immediately pull it in here. There were Flow errors introduced with a recent update that still need to be fixed first.

So in the meantime, bypassing this type check in some manner is appropriate I think. Typically this is done with a $FlowFixMe comment though, so that we know that we should come back and fix this at some point. I don't know what the maintainers would prefer here.

The benefit of using $FlowFixMe is that it would mark the line as something to fix later. You could also mention the PR that is required. The downside would be that it would suppress type errors elsewhere in this line.

It's probably worthwhile using the comment instead.

@arcanis arcanis merged commit 3c34587 into yarnpkg:master Sep 5, 2018
@langpavel
Copy link

langpavel commented Sep 6, 2018

Hooray! 🎉

Great work, I did't expect simple implementation like that really, but let's celebrate 🎈 and thank you!

Where is this used, it will apply on every yarn install, are there cases where files will be duplicated on COW file systems?
I'm asking for known cases that does not use src/util/fs-normalized.js:copyFile

@manishmkr45
Copy link

HI
Getting this error -
error An unexpected error occurred: "Cannot read property 'COPYFILE_FICLONE' of undefined".

@arcanis
Copy link
Member

arcanis commented Sep 26, 2018 via email

@manishmkr45
Copy link

Can you share your node version + system?

On Wed, Sep 26, 2018, 11:40 AM manishmkr45 @.***> wrote: HI Getting this error - error An unexpected error occurred: "Cannot read property 'COPYFILE_FICLONE' of undefined". — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#6302 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA_WayfHCjUW6KusCbVzonIjIOrsGHs4ks5ue1mogaJpZM4WIgMg .

Node version is 6.14.3
Linux system

@craigjbass
Copy link

craigjbass commented Sep 26, 2018

I'm also seeing this problem as of an hour ago.

yarn install v1.10.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[91merror An unexpected error occurred: "Cannot read property 'COPYFILE_FICLONE' of undefined".
[0minfo If you think this is a bug, please open a bug report with the information provided in "/usr/src/app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
[91mrails aborted!

We've also got

Yarn version: 
  1.11.0

Node version: 
  4.8.2

Platform: 
  linux x64

@arcanis
Copy link
Member

arcanis commented Sep 26, 2018 via email

@arcanis arcanis mentioned this pull request Sep 26, 2018
@arcanis
Copy link
Member

arcanis commented Sep 26, 2018

All hail the train station free wifi: #6432

@arcanis
Copy link
Member

arcanis commented Sep 26, 2018 via email

Copy link

@st-bender st-bender left a comment

Choose a reason for hiding this comment

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

Hi,
This change breaks yarn on some platforms, see for example #7152, #7440 .
The consequence being that also seemingly unrelated projects break: jupyterlab/jupyterlab#6969.
Cheers.

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.

7 participants