Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15491 closed enhancement (fixed)

[patch][ccla] reduce calls to traverse in dojo/_base/loader

Reported by: ben hockey Owned by: Rawld Gill
Priority: blocker Milestone: 1.7.3
Component: Loader Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by ben hockey)

in a legacy/sync app there was a performance issue noticed with the number of calls to traverse being quite high. in this case, there were ~80k calls and the execution time was about 22% of the load time for the app. the patch below reduced this to ~6k calls with only 6.5% of the execution time during load.

the improvement comes from an optimization where we don't try to traverse modules that are already marked as traversed in touched cache or are already executed.

it would be good if this could be applied to 1.7.3 as well as 1.8

  • dojo/_base/loader.js

     
    6363                touched,
    6464
    6565                traverse = function(m){
     66                        var module;
     67
    6668                        if(touched[m.mid]===1 || /loadInit\!/.test(m.mid) || /require\!/.test(m.mid)){
    6769                                // loadInit/require plugin modules are dependencies of modules in dojoRequireModuleStack...
    6870                                // which would cause a circular dependency chain that would never be resolved if checked here
     
    8183                        }
    8284                    touched[m.mid] = 1;
    8385                        for(var deps = m.deps || [], i= 0; i<deps.length; i++){
    84                                 if(!traverse(deps[i])){
     86                                module = deps[i];
     87                                if(!touched[module.mid] && !module.executed && !traverse(module)){
    8588                                        touched[m.mid] = 0;
    8689                                        return false;
    8790                                }
     
    9093                },
    9194
    9295                checkDojoRequirePlugin = function(){
     96                        var module;
    9397                        touched = {};
    9498                        for(var i = 0, end = dojoRequireModuleStack.length; i<end; i++){
    95                                 if(!traverse(dojoRequireModuleStack[i])){
     99                                module = dojoRequireModuleStack[i];
     100                                if(!touched[module.mid] && !module.executed && !traverse(module)){
    96101                                        return;
    97102                                }
    98103                        }

Change History (7)

comment:1 Changed 7 years ago by ben hockey

Description: modified (diff)
Milestone: tbd1.7.3
Priority: undecidedblocker
Summary: [patch][cla] reduce calls to traverse in dojo/_base/loader[patch][ccla] reduce calls to traverse in dojo/_base/loader

comment:2 Changed 7 years ago by Rawld Gill

Resolution: fixed
Status: newclosed

In [28848]:

improved dojo/require resolution algorithm efficientcy; thanks neonstalwart; fixes #15491; !strict

comment:3 Changed 7 years ago by Rawld Gill

Thanks neonstalwart! The proposed change was fine, but I played with it some more and I think the soln I committed is a slight improvement. fwiw, it still might be valuable to revisit this and reattempt the algorithm allowing to resolve for partial completion of some dojo/require! subgraphs.

comment:4 Changed 7 years ago by Rawld Gill

In [28849]:

backport [28848]; refs #15491; !strict

comment:5 Changed 7 years ago by ben hockey

thanks - this reduced another 45 calls (although over 6k+ calls that's a small amount) and it cut the own time in the traverse function by a third (that's a decent saving).

comment:6 Changed 7 years ago by Rawld Gill

[29319] should have ref'd this ticket

comment:7 Changed 7 years ago by Rawld Gill

In [29326]:

fixed too-aggressive error squeltching in [29319]; refs #15491; !strict

Note: See TracTickets for help on using tickets.