routing: Accounts and keys are folded again only when a request listed changes (#3164)
renderActs folded every kept request's seats (60 routes x ~800 seats on the issue's load, ~48k entries) on each of its ~10 draws a second, and in 63% of draws the requests were the very same objects. The fold now lives in foldActs, kept while the list holds the same route objects (routes are replaced whole on an update, ghost() makes new ones in a replay). The rests lifted by hand (#1869) are taken off afterwards, without touching the kept fold, since lifted() goes by the time shown and a replay takes it back. Run at this head (014680033+ this change), WebKit, the bin3164 sandbox app under load.sh (60 routes, ~800 keys), two folds open, 10s, two runs each: - renderActs 341 / 352 ms -> 181 / 174 ms (98-109 calls) - renderHist (includes it) 407 / 417 ms -> 283 / 278 ms GUI: every test file that reads .rt-act or replays/history (49 files, 1452 tests, concurrency 4, load ~33): 1403 ok, 49 red. Each red file run alone on origin/main014680033and on this change, same counts both: routing-live-patch 4/6 (#3637), routing-manual 2/2 (#3409), routing-pause 0/14 (#3410), routing-rule-effort 4/14 (#3411); routing-model-rest 20/20 on both. The others red in the full run, routing-rule-remove (#3094, #3096), routing-intent-entry (#3408) and routing-steady (#3412), are rule-editor and scroll tests this doesn't reach, and were red on main already. Not tried: the real app window (a dev shell showed a blank page here).
This commit is contained in:
@@ -3282,8 +3282,13 @@ function routingPage(part) {
|
||||
if ((a.mrests.get(m)?.at || 0) <= when) a.mrests.set(m, { rest, at: when });
|
||||
}
|
||||
// each account or key the kept requests weighed: how often it was
|
||||
// tried, answered and failed in them, and how the latest found it
|
||||
function renderActs(rs) {
|
||||
// tried, answered and failed in them, and how the latest found it.
|
||||
// Folded again only when a request listed is new or has changed: the
|
||||
// list is drawn ten times a second, and each fold went through every
|
||||
// kept request's hundreds of keys, a few ms each time (#3164)
|
||||
let actsFold = { rs: [], by: null };
|
||||
function foldActs(rs) {
|
||||
if (actsFold.by && actsFold.rs.length === rs.length && rs.every((r, i) => r === actsFold.rs[i])) return actsFold.by;
|
||||
const by = new Map();
|
||||
// The agent's current sign-in uses its provider's ID; after switching,
|
||||
// that same account uses provider@user and the base ID names another.
|
||||
@@ -3318,13 +3323,19 @@ function routingPage(part) {
|
||||
else if (tr.rest && end >= a.restAt) { a.rest = tr.rest; a.restAt = end; }
|
||||
}
|
||||
}
|
||||
actsFold = { rs: [...rs], by };
|
||||
return by;
|
||||
}
|
||||
function renderActs(rs) {
|
||||
// a rest lifted by hand since the request that found it (#1869): the
|
||||
// kept requests still say it, until the next one asks it again
|
||||
for (const a of by.values()) {
|
||||
if (a.rest && lifted(a.rest.key, a.restAt)) a.rest = null;
|
||||
for (const [m, x] of a.mrests) if (lifted(x.rest.key, x.at)) a.mrests.delete(m);
|
||||
}
|
||||
const list = [...by.values()].sort((x, y) => (x.w.name || "").localeCompare(y.w.name || "") || x.w.provider.localeCompare(y.w.provider) || rankOf(x.w) - rankOf(y.w) || x.pos - y.pos);
|
||||
// kept requests still say it, until the next one asks it again. By the
|
||||
// time shown, which a replay takes back, so the fold is left as it is
|
||||
const list = [...foldActs(rs).values()].map((a) => {
|
||||
const rest = a.rest && lifted(a.rest.key, a.restAt) ? null : a.rest;
|
||||
const mrests = [...a.mrests.values()].some((x) => lifted(x.rest.key, x.at))
|
||||
? new Map([...a.mrests].filter(([, x]) => !lifted(x.rest.key, x.at))) : a.mrests;
|
||||
return rest === a.rest && mrests === a.mrests ? a : { ...a, rest, mrests };
|
||||
}).sort((x, y) => (x.w.name || "").localeCompare(y.w.name || "") || x.w.provider.localeCompare(y.w.provider) || rankOf(x.w) - rankOf(y.w) || x.pos - y.pos);
|
||||
setText(actLabel, t("Accounts and keys"));
|
||||
setText(actNote, t("over those requests"));
|
||||
// live, with a subscription account listed: a kept day's were weighed
|
||||
|
||||
Reference in New Issue
Block a user