Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Improvements for transforms running before dependency extraction #32

Merged
merged 3 commits into from
Feb 18, 2016

Conversation

davidaurelio
Copy link

  • passes through transform options when getting dependencies
  • passes back all properties provided by a custom transform
  • ModuleCache can create Polyfill objects that are completly operational
  • ResolutionRequest parallelizes dependency extraction instead of running it serially

- passes through transform options when getting dependencies
- passes back all properties provided by a custom transform
- `ModuleCache` can create `Polyfill` objects that are completly functional
- `ResolutionRequest` parallelizes dependency extraction instead of running it serially
});

return p;
return Promise.all([modDep, recursive ? collect(modDep) : []]);
Copy link
Author

Choose a reason for hiding this comment

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

This effectively parallelizes dependency extraction.

Copy link

Choose a reason for hiding this comment

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

This is nice, I'm a bit concerned about I/O thrashing though because we'll fire off file-reads for every single JS file in the tree at the same time. In Jest on www, this completely stalled the process for about an hour (yes!). To mitigate this, I made a queue, like this: https://github.com/facebook/jest/blob/master/src/TestRunner.js#L203-L234

Another solution to limit concurrent jobs would be throat by our own @ForbesLindesay: https://www.npmjs.com/package/throat

Do you think this will also be an issue here?

Copy link
Author

Choose a reason for hiding this comment

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

Can I try it out on www easily? throat looks good, will add it. It probably wasn’t a problem for packager, because most time is spent in the transform, effectively limiting i/o. What’s a good number? 64? 256? 1024?

Copy link

Choose a reason for hiding this comment

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

Not super easy because I actually had to disable this for www because of how slow it is :(

You could potentially try it on react-native after I land my diffs but landcastle is giving me trouble.

I used lower numbers, I think 16, 24 or 32 should be the max for concurrent promises that access the file system here.

Copy link
Author

Choose a reason for hiding this comment

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

ok. I fear in the current form this will deadlock, because the the promise for a module only returns after all of its child promises return. Will refactor a bit.

@cpojer cpojer changed the title Improvements for transforms running before dependecy extraction Improvements for transforms running before dependency extraction Feb 18, 2016
@cpojer
Copy link

cpojer commented Feb 18, 2016

Looks great, feel free to merge. A bit worried about the parallelization. I think we should throttle it. Feel free to add throat and merge this?

davidaurelio added a commit that referenced this pull request Feb 18, 2016
Improvements for transforms running before dependency extraction
@davidaurelio davidaurelio merged commit d7a4c84 into master Feb 18, 2016
@davidaurelio davidaurelio deleted the additional-transform-support branch February 18, 2016 12:50
const MAX_CONCURRENT_FILE_READS = 32;
const getDependencies = throat(
MAX_CONCURRENT_FILE_READS,
(module, transformOptions) => module.getDependencies(transformOptions)

Choose a reason for hiding this comment

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

Does this end up being recursive? If module.getDependencies ends up calling the throttled getDependencies, you could end up in deadlock, which would ultimately fail silently as it's undetectable. Providing getDependencies is not recursive, this looks fine 👍

Copy link
Author

Choose a reason for hiding this comment

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

no, it’s not recursive – that’s why I’ve pulled it out of collect

Choose a reason for hiding this comment

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

👍 great, just thought I should check.

@cpojer
Copy link

cpojer commented Feb 19, 2016

Nice work!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants