Routing core made once, list orders kept, and Auto-TE's detour searches cut: same routing, much less work
The game plays exactly as before. * The core of compute() (rankPass, directPass, sendGroup, send, push, carry, altPath) is ROUTE in 29-route-core.js, built once by routeCore(): made inside compute() they were new functions every call and V8 threw away their code. Exits are read by number from typed columns (USED, CAPX, CIX, HPX, VISX), each list is an object of one shape. * The route cache keeps, for each list and source city, the order routing tries it (xOrder()); a list whose exits, cities and preferences are unchanged on the same graph keeps its orders when other exits change (rcExitKeep()). * Auto-TE: pairs with no detour are marked (TEF), exits that cannot help are skipped (dud()), one failed search answers the next ones, dijkstraTo() searches in arrays kept between calls, teSearch() runs on the graph as flat arrays and picks up where the last search from the same POP stopped. * The PNI/IX tie-break (#298) reaches the core. Tests: route-cache, routing-reference, speed (the fast core against the plain path, Auto-TE on crowded meshes with POPs outside the core, picked-up searches counted).
This commit is contained in:
parent
d03dde6fcd
commit
1edf0abb54
10 changed files with 409 additions and 159 deletions
|
|
@ -22,15 +22,16 @@ function network(ev) {
|
|||
}
|
||||
compute();`);
|
||||
// Share the model and path sender, but replace indexed exit selection with
|
||||
// the original full scan and stable sort for every flow.
|
||||
const source = ev('compute.toString()');
|
||||
const start = source.indexOf(' for(const pass of PASSES)for(const rank of RANKS){');
|
||||
const end = source.indexOf(' for(const i of NORD)', start);
|
||||
// the original full scan and stable sort for every flow: in the routing core (29-route-core.js), the passes of run().
|
||||
const core = ev('routeCore.toString()'), source = ev('compute.toString()');
|
||||
const start = core.indexOf(' for(const pass of PASSES)for(const rank of RANKS){');
|
||||
const end = core.indexOf(' for(let x=0;x<NX;x++)E[x].used=USED[x];', start);
|
||||
assert.ok(start >= 0 && end > start, 'allocation loop boundaries must exist');
|
||||
// The reference also builds every table afresh, so the comparison covers what routing keeps between calls.
|
||||
assert.ok(source.includes('RCON=RC.on'), 'compute() can be told not to keep its tables');
|
||||
const ref = (source.slice(0,start)+referenceAllocation+source.slice(end)).replace('RCON=RC.on', 'RCON=false');
|
||||
ev(`window.referenceCompute=eval('('+${lit(ref)}+')')`);
|
||||
const refCore = (core.slice(0, start) + referenceAllocation + core.slice(end)).replace(/^function routeCore/, 'function');
|
||||
ev(`window.referenceCore=(${refCore})();window.referenceRaw=(0,eval)('('+${lit(source.replace('RCON=RC.on', 'RCON=false').replace(/^function compute/, 'function'))}+')');
|
||||
window.referenceCompute=function(){const r=ROUTE;ROUTE=referenceCore;try{referenceRaw();}finally{ROUTE=r;}};`);
|
||||
}
|
||||
|
||||
test('indexed routing matches the simple allocation loop across network changes', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue