-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Optimize buildActionsForCopy routine #2657
Conversation
In the tests, there's only one failure (resolving |
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.
That is very useful, thanks a lot for improving it.
Just a few nits
src/util/fs.js
Outdated
let destStat; | ||
try { | ||
destStat = await lstat(dest); | ||
} catch (e) {} |
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.
there needs to be an explanation for a muted exception.
Could you add a one line comment?
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.
Oh, sure. Basically, fs.exists
is deprecated in Node, which recommends using fs.stat
with error handling instead. In this case destStat
will be undefined if error occurs during lstat
.
src/util/fs.js
Outdated
// EINVAL access errors sometimes happen which shouldn't because node shouldn't be giving | ||
// us modes that aren't valid. investigate this, it's generally safe to proceed. | ||
|
||
// if (srcStat.mode !== destStat.mode) { |
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.
Forgot to remove?
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 thought it was left there as something to investigate in future, so I left it as a comment. Should I remove?
86e5e69
to
d77af50
Compare
@bestander addressed your first comment and rebased on master, so this PR should be good to go. Regarding the read mode leftover — it was there before my changes (as sort of a TODO to investigate), so I'm leaving it there as a comment. @kittens introduced it in 4bbc653. |
The AppVeyor build failed with the following error, which seems unrelated to the PR changes:
|
// EINVAL access errors sometimes happen which shouldn't because node shouldn't be giving | ||
// us modes that aren't valid. investigate this, it's generally safe to proceed. | ||
|
||
/* if (srcStat.mode !== destStat.mode) { |
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.
So what should we do with this code?
No reason to keep it commented out.
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.
If no one from the Yarn team is willing to investigate cases where it's unsafe to proceed when the file read modes don't match, I'm OK removing the code. I'd leave the text comment above though, just in case.
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.
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.
Ping me in 2 days if there is no answer, then let's just merge with this code removed.
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.
@bestander Ping 😉
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.
Ok, let's remove the commented out code and get back to it if we see errors reported.
Sorry for the late response — I should probably wait before master starts passing CI tests more reliably before rebasing and suggesting to merge. Most recent commits in master fail on all servers. |
We have a few flaky tests but master got stable enough to get the signal if a PR is breaking something, so let's give this one one more try. |
@mourner, would you rebase? |
@bestander yes, will do! |
@bestander sorry for getting out of the loop. I see that Travis started having a failed test after this merge — do you think this is a consequence of this PR or an unrelated intermittent failure?
|
It's probably related, previous tests weren't subject to this (it's usually timeout that kill our tests) |
OK, submitting a PR to revert a few lines that caused the failure until we figure out what's going on. |
There's a bunch of lint warnings on |
Summary
Makes linking faster by reducing the number of file system calls in the
buildActionsForCopy
routine which synchronizes existingnode_modules
tree with the ideal one.In my test runs (on
yarn
itself, and on another big project), it saves about 400ms when runningyarn
without a lock file (or during upgrade).fs.exists
(in favor oflstat
which is called later anyway)fs.access
(which does nothing — it's a placeholder in the code, so should be commented)possibleExtraneous
since it should be populated with the same values later in the queue anyway.mkdirp
if we know the destination folder already exists.cc @bestander
Test plan
Not necessary — it doesn't change the results of exported functions. Let's see if this PR passes the CI tests.