Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Introduce AoT predictive prefetching #94
This pull request introduces Ahead-of-Time predictive prefetching.
AoT vs. JiT prefetching
With AoT predictive prefetching, we query the model at build time. This has several benefits.
Advantages of the AoT model
Instead of shipping the entire model to the browser, now we just need to provide a
The prefetch function is part of the main application bundle. Each lazy-loaded chunk has a few instructions which trigger the prefetching mechanism for its neighbors.
// main.js __GUESS__.p = () => /* prefetching logic */; // a.js __GUESS__.p(['b.js', 0.1], ['c.js', 0.9]); /* rest of the a.js chunk */ // b.js __GUESS__.p(['a.js', 0.1], ['c.js', 0.9]); /* rest of the b.js chunk */ // c.js __GUESS__.p(['a.js', 1]); /* rest of the c.js chunk */
In the example above, when the user visits
May 30, 2019
@mgechev do you happen have a small but fully functioning AoT example I can use as PoC to get buy-in from others on my team? I'm assuming there is a training step (data from Google Analytics maybe?) and during build time the prefetches are determined based on the trained model. I assume the model can be trained continually? In other words, as user behavior changes/evolves and we have a larger dataset, we can retrain it or resume its training and get the updated prefetch predictions.
Or maybe I have a purely imaginary sense of how this works?