From 1473fb06272bef5ba4c9078ca28da701f97c408b Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Mon, 26 Oct 2026 07:14:21 +0100 Subject: [PATCH] RouteScript optimizer: smarter tips after #96 Suggest protect customers only where IP customers would get unhappy (under 95% served): it costs a second routing pass, about +65% on a big network. Point at the exchange the network actually peers at, where you have no port yet, instead of the city's main IX. And the draft admits it has never been paged at 3 a.m. --- site/i18n/it.js | 2 +- site/i18n/pt.js | 2 +- site/index.html | 10 ++++++---- tests/modes.test.js | 4 ++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/site/i18n/it.js b/site/i18n/it.js index 52ba216..a09faf4 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2435,8 +2435,8 @@ "+{n} more customer":"+{n} altro cliente", "+{n} more customers":"+{n} altri clienti", "line {n}: prepend 1 to 3 times":"riga {n}: prepend da 1 a 3 volte", -"# Suggested by the optimizer from live traffic. Check it, then deploy.":"# Suggerito dall’ottimizzatore in base al traffico reale. Controllalo, poi fai il deploy.", "# {net}: {g} over transit, but it peers at {ix} in {city}, where you have a POP. Get a port there.":"# {net}: {g} via transit, ma fa peering a {ix} a {city}, dove hai un POP. Prendi una porta lì.", "# {net}: {g} over the IX. A PNI would take it off the shared port.":"# {net}: {g} via IX. Un PNI lo toglierebbe dalla porta condivisa.", "Optimize":"Ottimizza", +"# Suggested by the optimizer from live traffic. It has never been paged at 3 a.m., so check it, then deploy.":"# Suggerito dall’ottimizzatore dal traffico in tempo reale. Non è mai stato svegliato alle 3 di notte, quindi controllalo e poi fai il deploy.", }; diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 3f2862b..52256d2 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2435,8 +2435,8 @@ "+{n} more customer":"+{n} cliente a mais", "+{n} more customers":"+{n} clientes a mais", "line {n}: prepend 1 to 3 times":"linha {n}: prepend de 1 a 3 vezes", -"# Suggested by the optimizer from live traffic. Check it, then deploy.":"# Sugerido pelo otimizador a partir do tráfego ao vivo. Confira e depois faça o deploy.", "# {net}: {g} over transit, but it peers at {ix} in {city}, where you have a POP. Get a port there.":"# {net}: {g} via transit, mas faz peering no {ix} em {city}, onde você tem um POP. Pegue uma porta lá.", "# {net}: {g} over the IX. A PNI would take it off the shared port.":"# {net}: {g} via IX. Um PNI tiraria isso da porta compartilhada.", "Optimize":"Otimizar", +"# Suggested by the optimizer from live traffic. It has never been paged at 3 a.m., so check it, then deploy.":"# Sugerido pelo otimizador a partir do tráfego ao vivo. Ele nunca foi acionado às 3 da manhã, então confira e depois faça o deploy.", }; diff --git a/site/index.html b/site/index.html index 6a239e0..5a3b7ec 100644 --- a/site/index.html +++ b/site/index.html @@ -1730,13 +1730,15 @@ function teParse(src){const out={spill:null,cap:{},net:{},up:{},prep:{},protect: return out;} // Share of an upstream's traffic that moves away for each prepend: prepending is a hint, not an order. const PREPEND_F=[0,0.35,0.6,0.75]; -function teOptimize(){const L=[tr('# Suggested by the optimizer from live traffic. Check it, then deploy.'),'spill at 85%']; - if(S.biz.some(b=>!BIZ_T[b.type].l2&&!BIZ_T[b.type].fiber))L.push('protect customers'); +function teOptimize(){const L=[tr('# Suggested by the optimizer from live traffic. It has never been paged at 3 a.m., so check it, then deploy.'),'spill at 85%']; + // Protecting customers costs a second routing pass: only worth it where IP customers would get unhappy (under 95% served). + if(S.biz.some(b=>!BIZ_T[b.type].l2&&!BIZ_T[b.type].fiber&&!BIZ_T[b.type].event&&sfOf(R,b.city)<0.95))L.push('protect customers'); const ups=[...new Set(S.transit.map(t=>t.net))].map(n=>({n,p:Math.min(...S.transit.filter(t=>t.net===n).map(t=>NET[n].price*regionMult(t.city)))})).sort((a,b)=>a.p-b.p); if(ups.length>1){L.push('prefer transit '+NET[ups[0].n].name.toLowerCase());L.push('avoid transit '+NET[ups[ups.length-1].n].name.toLowerCase());} const tips=[]; - for(const n of NETS){const g=(R.netEg[n.id]||{}).t||0;if(g<1)continue;const at=Object.keys(S.pops).find(c=>S.ixp[c]===undefined&&ixStatic(c).some(x=>ixMembers(x).includes(n.id))); - if(at)tips.push([g,tr('# {net}: {g} over transit, but it peers at {ix} in {city}, where you have a POP. Get a port there.',{net:n.name,g:fmtG(g),ix:ixName(at),city:CITY[at].name})]);} + for(const n of NETS){const g=(R.netEg[n.id]||{}).t||0;if(g<1)continue;// The exchange where it is a member and you have no port yet, in a city where you have a POP. + let at=null;for(const c of Object.keys(S.pops)){at=ixIdsIn(c).find(x=>S.ixp[x]===undefined&&ixMembers(x).includes(n.id));if(at)break;} + if(at)tips.push([g,tr('# {net}: {g} over transit, but it peers at {ix} in {city}, where you have a POP. Get a port there.',{net:n.name,g:fmtG(g),ix:ixName(at),city:CITY[ixCity(at)].name})]);} for(const n of NETS){const g=(R.netEg[n.id]||{}).ix||0;if(g>=50&&!S.pni.some(p=>p.net===n.id))tips.push([g,tr('# {net}: {g} over the IX. A PNI would take it off the shared port.',{net:n.name,g:fmtG(g)})]);} tips.sort((a,b)=>b[0]-a[0]).slice(0,5).forEach(x=>L.push(x[1])); return L.join('\n');} diff --git a/tests/modes.test.js b/tests/modes.test.js index 465421f..a6e7743 100644 --- a/tests/modes.test.js +++ b/tests/modes.test.js @@ -201,6 +201,10 @@ test('RouteScript BGP: local-pref and prepending move transit, protected custome assert.match(draft, /prefer transit cogentle/); assert.match(draft, /peers at DE-KICKS/); assert.equal(ev('teParse(teOptimize()).errors.length'), 0, 'the draft is a valid script'); + // With room to spare, protecting customers would only cost a second routing pass, so it is not suggested. + ev("S.pops.fra.bb.d=5;S.te.script='';compute()"); + assert.ok(ev("sfOf(R,'fra')") >= 0.95); + assert.doesNotMatch(ev('teOptimize()'), /protect customers/); ev("S.te.script='';ACT.teEdit();ACT.teOpt()"); assert.match(ev("document.getElementById('teSrc').value"), /Suggested by the optimizer/); assert.deepEqual(errors, []);