-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
fix(watchman): Parallelize Watchman calls in crawler again #5640
Conversation
This is a follow up to #5615 where it made all async watchman commands serialized when converting them from promises to `async` functions. Existing Watchman crawler tests should pass, maybe slightly faster.
/cc @cpojer @jeanlauliac |
} else { | ||
// Make the filter directories an empty array to signal that this root | ||
// was already seen and needs to be watched for all files/directories | ||
watchmanRoots.set(response.watch, []); |
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.
Slightly concerned about race conditions here but it should be fine since the main thread is memory-safe, right?
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.
yes, this is completely fine
shouldReset = shouldReset || response.is_fresh_instance; | ||
watchmanFileResults.set(root, response); | ||
} | ||
const response = await cmd('query', root, query); |
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.
Instead of what I did above, I can also just return [root, cmd('query', root, query)]
here and then do
const watchmanFileResults = new Map(await Promise.all(...));
That said I still need to loop through responses and determine if shouldReset
needs to be set to true, which would probably be
const watcmanRawResults = await Promise.all(...);
const watchmanFileResults = new Map(watcmanRawResults);
const shouldReset = watcmanRawResults.some(([_root, response]) => response.is_fresh_instance);
I'm kind of liking this new version but what do you think?
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 think this is fine tbh
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.
Thanks, this is nicer
} else { | ||
// Make the filter directories an empty array to signal that this root | ||
// was already seen and needs to be watched for all files/directories | ||
watchmanRoots.set(response.watch, []); |
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.
yes, this is completely fine
shouldReset = shouldReset || response.is_fresh_instance; | ||
watchmanFileResults.set(root, response); | ||
} | ||
const response = await cmd('query', root, query); |
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 think this is fine tbh
// A root can only be filtered if it was never seen with a relative_path before | ||
const canBeFiltered = !existing || existing.length > 0; | ||
await Promise.all( | ||
roots.map(async root => { |
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.
a function that you could hoist 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.
I like it
let files = data.files; | ||
|
||
try { | ||
async function getWatcmanRoots(roots) { |
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.
typo, you are missing a “h”
Codecov Report
@@ Coverage Diff @@
## master #5640 +/- ##
==========================================
+ Coverage 62.28% 62.31% +0.03%
==========================================
Files 216 216
Lines 7898 7903 +5
Branches 3 4 +1
==========================================
+ Hits 4919 4925 +6
+ Misses 2978 2977 -1
Partials 1 1
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This is a follow up to #5615 where it made all async watchman
commands serialized when converting them from promises to
async
functions.
Test plan
Existing Watchman crawler tests should pass, maybe slightly faster.