-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Bundles Refactor #5675
Bundles Refactor #5675
Conversation
Is is possible to have some perf numbers in the PR description please? I think the concern before was the bundles didn't reliably give better startup times than unbundled assets. So if we can now demonstrate that, I think I'd be much happier to promote bundle usage to users. |
Given the following example, it's not totally clear to me whether // pc.AssetRegistry
assets.load(asset, {
bundlesIgnore: true,
bundlesFilter: (bundles) => bundles[0];
}) This could be potentially be simplified with something along the following lines // pc.AssetRegistry
assets.load(asset, { // optional options object
useBundle: (bundles) => { // by default (undefined) or if true and multiple assets contain a bundle, it chooses either already loaded bundle, or if none available the smallest file size bundle. If false load asset directly
return bundles[0] // you can provide custom method to control this logic, if falsy defaults to logic as if useBundle: false
}
}) Examples would be: assets.load(asset) // Asset loads from bundle if it exists in one
assets.load(asset, { useBundle : true }) // Same as above
assets.load(asset, { useBundle : false }) // Asset does not loads from bundle and loads directly
assets.load(asset, { useBundle : bundle => bundles[0] }) // Asset loads from specific bundle if it exists |
Below are benchmarks of a specific project that I believe is a good case for bundles. Conclusions:In case of no cache, loading is 18-35% faster depending on latency.Worse latency = more benefits from bundles. Test Types:no bundles, no cache: 312 requests, 12.3Mb download Timing Names:First Frame - when first Timings (good latency, Latvia - Frankfurt):
Timings (bad latency 150ms+, Latvia - San Francisco):
|
marklundin Here is current PRs ways: // default to be loaded from bundle if any is suitable
assets.load(asset);
// force asset to be loaded not from a bundle
assets.load(asset, {
bundlesIgnore: true
});
// choose a random bundle (if any suitable) to load from
assets.load(asset, {
bundlesFilter: (bundles) => {
const ind = Math.ceil(Math.random() * bundles.length);
return bundles[ind];
}
}); |
Just wanted to ask another question about bundles. Obviously, these work fine in the Editor. But are they also useful for engine-only developers? So I believe I originally recommended the TAR format because anyone can open a terminal window and tar up some files. But is that all a bundle is? A vanilla TAR file? Or is there extra metadata that would make it hard for engine-only users to create? |
It is just a tar file. Tests run over a bundle that I've produced using command line |
Is there any update on this? This could be potentially increase our C2P values on our web games. |
Hey, @slimbuck and @mvaligursky - I want us to set aside some time this week to properly review this PR and finally get it merged. 🙏 |
Hi @Maksims - we're keen to get to review this / finalize this. When you get a chance, could you please merge main to it and resolve the conflicts. |
Updated this PR:
Tested on existing project - works as before. |
Fixes #5626
Refactor and improve behavior of Bundles:
fetch
instead ofXMLHttpRequest
. This provides a source for aReadableStream
.load
as they individually are loaded before whole bundle is downloaded. This spreads parsing time and improves overall loading speed.text
,json
,template
, ..) now do not create Blob, which does not pollute network tab with Blob url requests and loads such assets at sync speed when it gets available from bundle. Similar approach can be applied to other binary formats (separate PR).load
for all of its assets once they are downloaded.bundlesFilter
.This makes working with bundles much easier, and does not require any changes to existing projects that use bundles. It actually provides a simplification so developers can load async bundles and its assets much easier without custom code.
As well as slightly speeds up the loading as it spreads parsing as it downloads.
New APIs:
Benchmarks #5675 (comment)
In case of no cache, loading is 18-35% faster depending on latency.
Worse latency = more benefits from bundles.
Larger bundles (more assets in them) = more benefit from bad latency.
Preloaded vs post-loaded assets improvements might vary depending on bundles contents.
When loading from cache, there is no effect (marginal error).
I confirm I have read the contributing guidelines and signed the Contributor License Agreement.