-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Only serialize and send shared references to workers that need them #8589
Conversation
This reverts commit cf5b3ff.
@@ -145,6 +145,7 @@ export type RunAPI = {| | |||
getRequestResult<T>(contentKey: ContentKey): Async<?T>, | |||
getPreviousResult<T>(ifMatch?: string): Async<?T>, | |||
getSubRequests(): Array<StoredRequest>, | |||
getInvalidSubRequests(): Array<StoredRequest>, |
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.
This new API is subtly different than api.getSubRequest().filter(req => !api.canSkipSubrequest(req.id))
in that it doesn't have the side effect of preserving all previous sub requests even if not used.
@@ -110,7 +110,7 @@ export default class Parcel { | |||
await resolvedOptions.cache.ensure(); | |||
|
|||
let {dispose: disposeOptions, ref: optionsRef} = | |||
await this.#farm.createSharedReference(resolvedOptions); | |||
await this.#farm.createSharedReference(resolvedOptions, false); |
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.
Serializing the options aren't cacheable because of the MemoryFS which has a side effect in the serialize()
method... 😬
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached BundlesNo bundle changes detected. React HackerNews ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. AtlasKit Editor ✅
Timings
Cold Bundles
Cached Bundles
Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. |
Closes #8491
This is based on #8491, and in addition to packaging on the main thread, it also transforms on the main thread if there is only one file change which improves performance even more.
It also refactors the code a little to follow a slightly different approach: rather than avoiding creating the shared reference and needing a different way of passing the bundle graph around, it changes the way shared references are implemented in the worker farm. Instead of serializing the bundle graph upfront and always sending it to every worker, it lazily serializes and sends shared references to workers only when needed. This way, if using the main thread, no serialization occurs but the shared reference can still be accessed using the same API. In addition, if you only have 2 bundles but 8 workers, we only send the bundle graph to the 2 workers that need it rather than all 8.