-
Notifications
You must be signed in to change notification settings - Fork 203
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
Re-introduce chunk clustering #6
Comments
Thanks for writing this up, Minko! For an application without deeply nested routes, I think the above implementation could be reasonable. Let's attempt to mentally apply this to Shop - an example that would match the level of nesting in your suggestion. Clustering the entry route, a category chunk /list/mens_outerwear and chunk for the product view detail/mens_outerwear/Anvil+L+S+Crew+Neck+-+Grey into a single file for prefetching makes sense to me. Let's imagine the routes are cleaner, but the overall navigation path matches your Where this becomes more complicated is:
For
The concept of |
Another corner case I see is if a child module ( If a user wants to load The solution I see is to combine |
👍 |
Prior implementation
The initial chunk clustering implementation accepts a minimum number of chunks that need to be produced by the build process and goes through a graph clustering based on Tarjan's algorithm for finding strongly connected components.
This algorithm has a number of problems:
Suggested implementation
Combine only chunks of nested routes where the probability of two chunks to be used together is high (threshold should be discussed).
In such case, if we have the following routes in the application:
We'll recommend developers to load everything lazily (i.e. even load lazily
/a
,/a/b
, and/a/b/c
).In such case, the probability
/a
,/a/b
, and/a/b/c
to be visited in the same session is1
(because we have only one route with root/a
), for/e
and/e/f
the probability isn
.In this case, we'll cluster the chunks from
/a
,/a/b
, and/a/b/c
into a single file. Depending on the value ofn
, we may also combine/e
and/e/f
.When the user is at any page (e.g.
/a/b/c
) we'll prefetch the other bundles based on the Markov chain which we've built in the prefetch plugin.Note: this algorithm does not solve the problem which occurs when combining large chunks together.
The text was updated successfully, but these errors were encountered: