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

Incorporate child bundle ids in BundleGraph.getHash(bundle) #4189

Merged
merged 4 commits into from
Feb 21, 2020

Conversation

padmaia
Copy link
Contributor

@padmaia padmaia commented Feb 20, 2020

↪️ Pull Request

Before the addition of bundle content hash references (#4114), BundleGraph.getHash(bundle) incorporated the content of all descendant bundles (See #3414 for reasoning). With bundles maintaining stable hash references through packaging and optimizing, this was overkill, so I updated the method. Unfortunately I updated it to not consider they may end up referencing different bundles 😔.

Now all descendant bundle ids are considered in the BundleGraph.getHash(bundle) function. This is still a little overkill because bundles usually only reference direct child bundles, but in the future when we add mappings of stable ids to final bundle names for all bundles in entry bundles, we would need to consider every child. Maybe the runtime assets with the mappings could add dependencies to all bundles it references, in which case checking only child bundles would be okay. But still, we kind of have a problem that packagers have access to the entire BundleGraph and we aren't totally sure what they are going to do with it. If we are only going to use direct child bundle ids in the hash, we need to make sure that's all packagers have access to. That or add another method to packagers that can narrow down what should go in the cache key before packaging.

Another thing I just discovered was that scope hoisting brings in the possibility of bundles referencing parent bundles. They reference not just their names, but their exports too, which means we probably also have to consider parent bundle content in the hash? This is based on my findings working on #4188.

✔️ PR Todo

  • Add some tests
  • Maybe consider parent bundle's content based on scope hoisting findings

@parcel-benchmark
Copy link

parcel-benchmark commented Feb 20, 2020

Benchmark Results

packages/benchmarks/kitchen-sink ✅

Timings

Description Time Difference
Cold 5.42s +1.48s ⚠️
Cached 3.60s +6.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.js 1.07kb +5.00b ⚠️ 236.00ms +12.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/parcel.d5807e82.webp 102.94kb +0.00b 2.00ms -397.00ms 🚀
dist/index.js 1.07kb +5.00b ⚠️ 7.00ms -397.00ms 🚀

packages/benchmarks/react-hn ✅

Timings

Description Time Difference
Cold 8.69s +315.00ms
Cached 3.68s +24.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.js 64.04kb +397.00b ⚠️ 1.25s +83.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.js 64.04kb +397.00b ⚠️ 326.00ms +320.00ms ⚠️

packages/benchmarks/ak-editor ✅

Timings

Description Time Difference
Cold 4.89s +851.00ms ⚠️
Cached 3.52s -59.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.js 743.00b +7.00b ⚠️ 1.06s +867.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.js 743.00b +7.00b ⚠️ 7.00ms +1.00ms ⚠️

Click here to view a detailed benchmark overview.

@padmaia padmaia merged commit 8dc29d3 into v2 Feb 21, 2020
@devongovett devongovett deleted the fix-packager-runner-cache-key branch February 22, 2020 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants