-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix non-deterministic builds between project directories #8869
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
Changes from 11 commits
214cae3
b94daa2
59252ef
dac4122
8197b3f
f1efc0e
fc29b8e
3546ab0
694332c
64f1e2f
9f35ac4
714ba92
7139c9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1031,6 +1031,8 @@ function createIdealGraph( | |
| } | ||
| } | ||
|
|
||
| let modifiedSourceBundles = new Set(); | ||
|
|
||
| // Step Remove Shared Bundles: Remove shared bundles from bundle groups that hit the parallel request limit. | ||
| for (let bundleGroupId of bundleGraph.getNodeIdsConnectedFrom(rootNodeId)) { | ||
| // Find shared bundles in this bundle group. | ||
|
|
@@ -1081,6 +1083,7 @@ function createIdealGraph( | |
| for (let sourceBundleId of sourceBundles) { | ||
| let sourceBundle = nullthrows(bundleGraph.getNode(sourceBundleId)); | ||
| invariant(sourceBundle !== 'root'); | ||
| modifiedSourceBundles.add(sourceBundle); | ||
| bundleToRemove.sourceBundles.delete(sourceBundleId); | ||
| for (let asset of bundleToRemove.assets) { | ||
| sourceBundle.assets.add(asset); | ||
|
|
@@ -1119,6 +1122,23 @@ function createIdealGraph( | |
| } | ||
| } | ||
| } | ||
|
|
||
| // Fix asset order in source bundles as they are likely now incorrect after shared bundle deletion | ||
| if (modifiedSourceBundles.size > 0) { | ||
| let assetOrderMap = new Map(assets.map(a => [a, assets.indexOf(a)])); | ||
|
|
||
| for (let bundle of modifiedSourceBundles) { | ||
| bundle.assets = new Set( | ||
| [...bundle.assets].sort((a, b) => { | ||
| let aIndex = nullthrows(assetOrderMap.get(a)); | ||
| let bIndex = nullthrows(assetOrderMap.get(b)); | ||
|
|
||
| return aIndex - bIndex; | ||
| }), | ||
| ); | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wonder if you could use BitSet for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funny you mention this because I considered that approach as well but was worried this iteration cost might not be worth it. You've inspired me to try it though. Will report back.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @devongovett Just realised it'd be hard to use the BitSet here as we need to create bundles before we know the full list of assets as we add them during the traverse.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could create the bitset earlier maybe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could, but I'd have to add a second full asset traverse to collect the list of all assets before starting the main traverse. Unless there's some other cheap way to get the list of all assets?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After migrating all asset sets to BitSets I actually saw a drop in perf. This is due to the values() extraction being too expensive. I think there's potential to use BitSet more widely in the bundler but it would require a larger rethink to optimise around its benefits. tl;dr let's just sort for now. |
||
|
|
||
| function deleteBundle(bundleRoot: BundleRoot) { | ||
| bundleGraph.removeNode(nullthrows(bundles.get(bundleRoot.id))); | ||
| bundleRoots.delete(bundleRoot); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.