routing: a session's Avg. speed says the wait for the first token is left out, and gives the speed with it counted
@verymoes on X (tweet 2121533934332985393): an opencode session over the Command Code plugin read "平均速率 142 token/秒" on Routing's By session row, while CC Switch read ≈77 tok/s for the same 26-27 requests and opencode's footer 76.7 tok/s, and asked whether magpie counts wrong. It doesn't; the three divide by different times. magpie's average is Σ answer tokens over Σ (end − first token) of the timed replies (decodeOf; for a reply that reasoned, its answer from its first text), so the wait for the first token is left out. CC Switch's "≈" is its estimate from the session log's timestamps, which it documents as counting the wait for the first token (src/components/usage/format.ts, docs/user-manual 4.4). opencode's footer is one turn, not the session, and counted from the request until #63321 (11-11) moved it to the first streamed token, with reasoning tokens added in. With a ~28K-token prompt each and short agent replies, the wait is about half of a request's time, which is the gap. Nothing in the measurement is wrong, so it isn't changed; the tooltip now says what it measures: - "the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out" in place of "total decode time; excludes waiting"; - a line with the same timed replies over their whole time, the wait and the reasoning counted ("Over each request's whole time ...: N tok/s"), the number a tool that times the whole request reads. In zh, zh-TW, ja and de. The Usage page's speeds and a row's own speed already say "from its first token to its end". routing-request-metrics checks the tooltip's wording and its whole-time number (4,000 tokens over 82 s, 49 tok/s, beside the 133 average) in en and zh, both engines. Run on mica at this tree (mote was over its 18 cores): - node --test, Chromium then WebKit: routing-request-metrics, reasoning-speed, routing-burst-speed, routing-speed-first, routing-row-floor-speed, routing-sessions, routing-by-key, routing-session-title, i18n-keys, gui-ja, gui-de, gui-zh-tw. Chromium 191/191; WebKit 101/102, the one red reasoning-speed's cut-off fetch (#1350), fixed in the commit before this. - Broken by hand: the test against the old client.js and i18n.js is red in all four (chromium/webkit × en/zh) at "the tooltip says the wait for the first token is left out". No Go code changed. Not tried with the reporter's data: their session isn't on this machine, and the owner's Command Code account answers 401.
This commit is contained in:
@@ -4182,10 +4182,14 @@ function routingPage(part) {
|
||||
const { prompt, read } = promptOf(r);
|
||||
if (prompt) { s.prompt += prompt; s.read += read; s.cached++; }
|
||||
const d = !noAnswer(outcome(r)[1]) && decodeOf(r, r.ms, r.ttft, r.firstText);
|
||||
if (d) { s.decodeMs += d.w; s.decodeOut += d.n; s.timed++; }
|
||||
// the same replies over their whole time too, the wait for the
|
||||
// first token and the reasoning in: what a tool that times the
|
||||
// whole request reads (@verymoes on X: CC Switch's ≈77 and
|
||||
// opencode's 76.7 beside this 142)
|
||||
if (d) { s.decodeMs += d.w; s.decodeOut += d.n; s.timed++; s.wholeMs += r.ms; s.wholeOut += r.out; }
|
||||
}
|
||||
return s;
|
||||
}, { cost: 0, tokens: 0, priced: 0, unpriced: 0, running: 0, completed: 0, prompt: 0, read: 0, cached: 0, decodeMs: 0, decodeOut: 0, timed: 0 });
|
||||
}, { cost: 0, tokens: 0, priced: 0, unpriced: 0, running: 0, completed: 0, prompt: 0, read: 0, cached: 0, decodeMs: 0, decodeOut: 0, timed: 0, wholeMs: 0, wholeOut: 0 });
|
||||
setText(x.arrow, open ? "▾" : "▸");
|
||||
// Background workers have their own IDs. Label groups made entirely
|
||||
// for one purpose without renaming a chat that also made helper calls.
|
||||
@@ -4231,7 +4235,8 @@ function routingPage(part) {
|
||||
if (g.key && visibleMetrics.includes("cache") && total.prompt) meta.push(metricElement(["cache-hit", "Avg. cache", hitPct(total.read / total.prompt),
|
||||
t("Total cache reads divided by total prompt tokens; larger prompts carry more weight") + "\n" + coverage(total.cached)]));
|
||||
if (g.key && visibleMetrics.includes("speed") && total.decodeMs) meta.push(metricElement(["speed", "Avg. speed", t("{n} tok/s", { n: Math.round(total.decodeOut * 1000 / total.decodeMs) }),
|
||||
t("Total output tokens divided by total decode time; excludes waiting and replies without usable timing") + ". " + t("A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it") + ". " + t("No answer text: speed includes reasoning only when visible reasoning streamed; hidden reasoning has no speed") + "\n" + coverage(total.timed)]));
|
||||
tipLines(t("Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out") + ". " + t("A reply that reasoned counts only its answer, from its first text: the reasoning was written before the stream showed it") + ". " + t("No answer text: speed includes reasoning only when visible reasoning streamed; hidden reasoning has no speed"),
|
||||
total.wholeMs ? t("Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s", { n: Math.round(total.wholeOut * 1000 / total.wholeMs) }) : "", coverage(total.timed))]));
|
||||
const metaSig = JSON.stringify([bits, tokenHelp, meta.map((e) => [e.textContent, e.title])]);
|
||||
if (x.meta.dataset.sig !== metaSig) { x.meta.replaceChildren(...meta); x.meta.dataset.sig = metaSig; }
|
||||
const credits = routeCredits(g.rows);
|
||||
|
||||
@@ -132,7 +132,8 @@ magpie.strings({
|
||||
"request cache hit rate {p}": "请求缓存命中率 {p}",
|
||||
"Based on {n} of {total} completed requests": "基于 {total} 个已完成请求中的 {n} 个",
|
||||
"Total cache reads divided by total prompt tokens; larger prompts carry more weight": "缓存读取总量除以输入 token 总量;输入越大的请求权重越高",
|
||||
"Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "输出 token 总量除以输出耗时总和;不计等待时间及缺少有效计时的回复",
|
||||
"Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "输出 token 总量除以每个回复从首个 token 到结束的时间总和;不计等待首个 token 的时间,也不计缺少有效计时的回复",
|
||||
"Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "按每个请求的全程时间算,含等待首个 token 的时间和推理:{n} token/秒",
|
||||
"Read the accounts' allowances again": "重新读取各账号的额度",
|
||||
"live, as the gateway decides": "实时 · 网关正在做的决定",
|
||||
"Add another model": "再添加一个模型",
|
||||
@@ -893,7 +894,8 @@ magpie.strings({
|
||||
"request cache hit rate {p}": "請求快取命中率 {p}",
|
||||
"Based on {n} of {total} completed requests": "基於 {total} 個已完成請求中的 {n} 個",
|
||||
"Total cache reads divided by total prompt tokens; larger prompts carry more weight": "快取讀取總量除以輸入 token 總量;輸入越大的請求權重越高",
|
||||
"Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "輸出 token 總量除以輸出耗時總和;不計等待時間及缺少有效計時的回覆",
|
||||
"Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "輸出 token 總量除以每個回覆從首個 token 到結束的時間總和;不計等待首個 token 的時間,也不計缺少有效計時的回覆",
|
||||
"Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "按每個請求的全程時間算,含等待首個 token 的時間和推理:{n} token/秒",
|
||||
"Read the accounts' allowances again": "重新讀取各帳號的額度",
|
||||
"live, as the gateway decides": "即時 · 閘道正在做的決定",
|
||||
"Add another model": "再新增一個模型",
|
||||
@@ -1632,7 +1634,8 @@ magpie.strings({
|
||||
"request cache hit rate {p}": "リクエストのキャッシュヒット率 {p}",
|
||||
"Based on {n} of {total} completed requests": "完了した {total} 件中 {n} 件に基づく",
|
||||
"Total cache reads divided by total prompt tokens; larger prompts carry more weight": "キャッシュ読み取り合計を入力トークン合計で割った値。入力が多いリクエストほど重みが大きくなります",
|
||||
"Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "出力トークン合計を生成時間の合計で割った値。待ち時間と有効な計測のない応答は除きます",
|
||||
"Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "出力トークンの合計を、各応答の最初のトークンから終わりまでの時間の合計で割った値。最初のトークンを待つ時間と、有効な計測のない応答は除きます",
|
||||
"Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "各リクエストの全体時間で計算(最初のトークンの待ち時間と推論を含む):{n} tok/s",
|
||||
"Read the accounts' allowances again": "アカウントの利用枠を読み直します",
|
||||
"live, as the gateway decides": "ライブ · ゲートウェイの判断どおり",
|
||||
"Add another model": "別のモデルを追加",
|
||||
@@ -2383,7 +2386,8 @@ magpie.strings({
|
||||
"request cache hit rate {p}": "Cache-Trefferquote der Anfrage {p}",
|
||||
"Based on {n} of {total} completed requests": "Basierend auf {n} von {total} abgeschlossenen Anfragen",
|
||||
"Total cache reads divided by total prompt tokens; larger prompts carry more weight": "Gesamte Cache-Lese-Token geteilt durch gesamte Eingabe-Token; größere Eingaben erhalten mehr Gewicht",
|
||||
"Total output tokens divided by total decode time; excludes waiting and replies without usable timing": "Gesamte Ausgabe-Token geteilt durch gesamte Generierungszeit; ohne Wartezeit und Antworten ohne brauchbare Zeitmessung",
|
||||
"Total output tokens divided by the time from each reply's first token to its end; the wait for the first token, and replies without usable timing, are left out": "Gesamte Ausgabe-Token geteilt durch die Zeit vom ersten Token jeder Antwort bis zu ihrem Ende; ohne die Wartezeit auf das erste Token und ohne Antworten ohne brauchbare Zeitmessung",
|
||||
"Over each request's whole time, the wait for the first token and the reasoning counted: {n} tok/s": "Über die ganze Dauer jeder Anfrage, Wartezeit auf das erste Token und Reasoning mitgezählt: {n} tok/s",
|
||||
"Read the accounts' allowances again": "Kontingente der Konten neu lesen",
|
||||
"live, as the gateway decides": "live, während der Zugangspunkt entscheidet",
|
||||
"Add another model": "Weiteres Modell hinzufügen",
|
||||
|
||||
@@ -126,6 +126,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.doesNotMatch(await unknown.locator(".summary").textContent(), /token|—/, "a session without token counts has no fake zero or dash");
|
||||
assert.equal(await group.locator(".cache-hit .v").textContent(), "63%", "cache average is weighted by prompt tokens, not by request count");
|
||||
assert.match(await group.locator(".speed .v").textContent(), /^133 /, "speed is output divided by summed decode windows, not the mean of individual speeds");
|
||||
// the same six replies over their whole time, the wait for the first
|
||||
// token in, as tools that time the whole request read it (@verymoes
|
||||
// on X): 4,000 tokens over 82 s
|
||||
const speedTip = await group.locator(".speed").getAttribute("title");
|
||||
assert.match(speedTip, lang === "zh" ? /不计等待首个 token 的时间/ : /the wait for the first token, and replies without usable timing, are left out/, "the tooltip says the wait for the first token is left out");
|
||||
assert.match(speedTip, lang === "zh" ? /全程时间.*:49 token\/秒/ : /whole time.*: 49 tok\/s/, "the tooltip gives the speed over the whole time too");
|
||||
assert.match(await group.locator(".cache-hit").getAttribute("title"), /9.*11|11.*9/, "unknown and unfinished requests are excluded and coverage is disclosed");
|
||||
assert.match(await group.locator(".rt-token-total").getAttribute("title"), /11.*12|12.*11/, "session token breakdown discloses missing records");
|
||||
await group.click();
|
||||
|
||||
Reference in New Issue
Block a user