Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
[perf] disabling _populateCache() in loader in favor of an on-demand process to create internal module info based on the raw meta when the module is needed #1581
For a very basic page with all necessary modules in the page upfront, and a YUI().use(‘json-stringify’) call, will run under 20ms in chrome/desktop, but it takes more than 100ms in safari iPad3.
For a more complex example, adding more modules (app level modules), we can clearly see more degradation of the initialization, even though none of those modules are "used". Here is an example using modules from screen.yahoo.com (almost 400 new modules + the 407 modules from yui core):
For what we can see in the profiling, _populateCache(), which is executed once per Y instance, it will do a one time operation to digest all the raw metadata from YUI.Env.modules, passing them thru addModule() method that will do a basic expansion of the meta without doing the recursive computation to expand the dependencies, that happens on demand.
By using the loader built of this branch, we seed a good deal of improvement, and overall a constant time to use despited the number of extra modules added thru the metas, which is exactly what we are looking for.
Loader keeps a member called
A quirk on this new way of initialization is that conditional modules are not requested by any other module in the require chain, which means they will have to be analyzed before applying any operation to compute dependencies, for that, we are just warming up the conditional cache (which is normally 16 entries for yui core), instead of just initializing all core modules (400+).
loader resolve core modules
loader resolve application modules
loader constructor with global cache
loader constructor without cache