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

fix(watchman): Parallelize Watchman calls in crawler again #5640

Merged
merged 3 commits into from
Feb 22, 2018

Conversation

BYK
Copy link
Contributor

@BYK BYK commented Feb 22, 2018

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.

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.
@BYK
Copy link
Contributor Author

BYK commented Feb 22, 2018

/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, []);
Copy link
Contributor Author

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?

Copy link
Contributor

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);
Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

@davidaurelio davidaurelio left a 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, []);
Copy link
Contributor

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);
Copy link
Contributor

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 => {
Copy link
Contributor

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 :-)

Copy link
Contributor

@davidaurelio davidaurelio left a 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) {
Copy link
Contributor

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-io
Copy link

Codecov Report

Merging #5640 into master will increase coverage by 0.03%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
packages/jest-haste-map/src/crawlers/watchman.js 93.84% <95.83%> (+2.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 497be76...ce4773f. Read the comment docs.

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants