Skip to content

Commit f5917f3

Browse files
committed
feat(site): show the benchmark version, and mark rows measured by an older one
The engine commit travelled into every row from the first stamped run and nothing rendered it. "Which version of the benchmark produced this number" was answerable only by opening the JSON, and the only thing that ever consulted it was C8 - a build guard that refuses a mixed board and then says nothing when it passes. Each row now carries its benchmark version, quiet when it matches the board and red when it does not, with a tooltip naming both versions and why the difference matters: numbers from two harnesses are not directly comparable. The footer states the board's own version so a red pill has something to be compared against, and counts how many rows are behind it - one red pill in a long table is easy to miss, and the count is what actually decides whether the board is safely comparable. A row with no stamp at all renders "engine unknown" rather than nothing: implying it matches is worse than saying we cannot tell. The board's version is the engine of the most recently measured row, which is the one a re-run moves forward. Test covers current, behind, unstamped, and the nothing-to-compare case, and was confirmed RED without the flag.
1 parent ce0daeb commit f5917f3

4 files changed

Lines changed: 127 additions & 2 deletions

File tree

‎site/app.js‎

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,40 @@ function measuredBadge(g, now = Date.now()) {
158158
const stalePill = g.stale
159159
? ` <span class="stale-pill" title="This gateway's data has aged past the freshness threshold; re-run it to refresh.">stale</span>`
160160
: "";
161-
return `<span class="measured-at${g.stale ? " stale" : ""}" title="${esc(stampWithAge(g.measured_at, now))}">${esc(rel)}</span>${stalePill}`;
161+
return `<span class="measured-at${g.stale ? " stale" : ""}" title="${esc(stampWithAge(g.measured_at, now))}">${esc(rel)}</span>${stalePill}${engineBadge(g)}`;
162+
}
163+
164+
/* The board's own benchmark version, read defensively: this helper is called from measuredBadge(),
165+
which site/test.mjs drives under Node where there is no window and no live state. */
166+
function boardBenchmarkVersion() {
167+
try {
168+
return (typeof state !== "undefined" && state.data && state.data.benchmark_version) || null;
169+
} catch {
170+
return null;
171+
}
172+
}
173+
174+
/* WHICH HARNESS MEASURED THIS ROW.
175+
The engine commit already travelled into every row and nothing rendered it, so "which version of
176+
the benchmark produced this number" was answerable only by opening the JSON. A row measured by an
177+
older engine is not necessarily wrong, but it is not comparable to the rest of the board, and a
178+
reader deciding whether to trust a side-by-side needs to see that rather than be told.
179+
Current rows show the sha quietly; an older one is red and says what it should have been.
180+
Returns "" when the row carries no engine at all AND the board has none either - there is nothing
181+
to compare, so a badge would be noise. Pure; covered by site/test.mjs. */
182+
function engineBadge(g, boardEngine = boardBenchmarkVersion()) {
183+
const e = g && g.engine;
184+
if (!e) return "";
185+
if (!e.sha) {
186+
return boardEngine
187+
? ` <span class="engine-pill old" title="This row carries no benchmark version at all: it predates the stamp, so which harness measured it cannot be established. The board is on ${esc(boardEngine.slice(0, 7))}.">engine unknown</span>`
188+
: "";
189+
}
190+
const cls = e.current ? "engine-pill" : "engine-pill old";
191+
const title = e.current
192+
? `Measured by benchmark ${e.sha}, which is the version the rest of the board was measured on.`
193+
: `Measured by benchmark ${e.sha}, but the board is on ${boardEngine ? boardEngine.slice(0, 7) : "a newer version"}. Numbers from two different harnesses are not directly comparable - re-run this gateway to refresh it.`;
194+
return ` <span class="${cls}" title="${esc(title)}">${esc(e.short)}</span>`;
162195
}
163196

164197
function esc(s) {
@@ -2475,6 +2508,17 @@ function renderStatic() {
24752508
const bits = [];
24762509
if (state.data.hardware) bits.push(`Ran on: ${state.data.hardware}`);
24772510
if (state.data.latest_measured_at) bits.push(`Latest measurement: ${stampWithAge(state.data.latest_measured_at)}`);
2511+
// WHICH BENCHMARK PRODUCED THIS BOARD. Stated once here so the per-row sha has something to be
2512+
// compared against: a red row means "not this one", and a reader should not have to infer what
2513+
// "this one" is. Also counts the rows that are behind it, because one red pill in a long table is
2514+
// easy to miss and the count is the thing that decides whether the board is safely comparable.
2515+
if (state.data.benchmark_version) {
2516+
const behind = (state.data.gateways || []).filter((g) => g.engine && !g.engine.current).length;
2517+
const short = String(state.data.benchmark_version).slice(0, 7);
2518+
bits.push(behind
2519+
? `Benchmark version: ${short} (${behind} row${behind === 1 ? "" : "s"} measured on an older version)`
2520+
: `Benchmark version: ${short}`);
2521+
}
24782522
bits.push(`Site data generated: ${state.data.generated_at ? stampWithAge(state.data.generated_at) : "unknown"}`);
24792523
const rig = rigStamp();
24802524
if (rig) bits.push(rig);
@@ -2919,7 +2963,7 @@ if (NODE) {
29192963
/* Exports for the node smoke test (site/test.mjs). */
29202964
module.exports = {
29212965
newState, encodeUrl, decodeUrl, viewPath, applyFilters,
2922-
fmtStamp, fmtAge, stampWithAge, measuredBadge,
2966+
fmtStamp, fmtAge, stampWithAge, measuredBadge, engineBadge,
29232967
drawSweep, niceStep, fmtTick, COLUMN_SETS, columnsFor, PERF_VIEWS, TABLE_VIEWS, VIEW_SORT, LANES, naText, stripRigPaths,
29242968
cellState, matrixCellTip, cellPerfTip, passCell, xlateCell, streamCell, memCell, rssSparkline, hasTranslation, CATEGORIES, DEFAULT_CATEGORY, VIEWS,
29252969
CHOOSER_MODES, chooserCellPerf, chooserDialects, chooserPerfCell, chooserCellStream, chooserStreamCell, chooserHasCell, deltaToPeak, cellPopFull,

‎site/gen-data.mjs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,41 @@ const redirects = join(HERE, "_redirects");
765765
if (existsSync(redirects) && OUT !== HERE) copyFileSync(redirects, join(OUT, "_redirects"));
766766

767767
// ---- emit -------------------------------------------------------------------
768+
// THE BOARD'S OWN ENGINE, and each row's, surfaced for the reader.
769+
//
770+
// The engine commit already travelled into every row inside `rig.engine.commit`; nothing rendered
771+
// it, so "which harness measured this" was knowable only by opening the JSON. A row measured by an
772+
// older engine is not necessarily wrong, but it is not comparable to the rest, and a reader deciding
773+
// whether to trust a comparison needs to see that without being told.
774+
//
775+
// The board's version is the engine of the most recently measured row, which is the one a re-run
776+
// moves forward. A row whose engine differs from it is marked, and the site renders that in red.
777+
const engineOf = (g) => (g && g.rig && g.rig.engine && g.rig.engine.commit) || null;
778+
const newestRow = gateways
779+
.filter((g) => displayedMeasuredMs(g) > 0)
780+
.sort((a, b) => displayedMeasuredMs(b) - displayedMeasuredMs(a))[0];
781+
const boardEngine = engineOf(newestRow);
782+
for (const g of gateways) {
783+
const sha = engineOf(g);
784+
g.engine = sha
785+
? { sha, short: sha.slice(0, 7), current: boardEngine == null || sha === boardEngine }
786+
// A row with no engine stamp predates the stamp entirely; saying so is better than implying it
787+
// matches, and better than omitting the field so the render site has to guess.
788+
: { sha: null, short: null, current: false };
789+
}
790+
768791
const data = {
769792
category: "gateways", // which category bundle this is (see CATEGORIES in app.js)
770793
generated_at: generatedAt,
771794
hardware,
772795
// MED-1: the DISPLAYED-number freshness stamp (matrix-preferring), not the max across all suites.
773796
latest_measured_at: latestDisplayed,
797+
// WHICH HARNESS MEASURED THE BOARD, as a thing a reader can see rather than a thing a build guard
798+
// knows privately. C8 refuses to publish a board whose columns were measured by different engines,
799+
// which is the right call for a ranking - but it made the engine invisible when it passed, so a
800+
// reader had no way to tell WHICH harness produced the numbers or whether a row was measured by an
801+
// older one. The board states its own engine, and every row states the engine that measured it.
802+
benchmark_version: boardEngine,
774803
repo: "https://github.com/GetBusbar/benchmarking",
775804
gateways,
776805
charts,

‎site/style.css‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,3 +606,22 @@ td.memcurve.na { color: var(--fg-mute); }
606606
.site-header h1.brand { font-size: 1.2rem; }
607607
.tab { padding: .55rem .55rem; font-size: .9rem; }
608608
}
609+
610+
/* Benchmark version per row. Quiet when the row was measured by the same harness as the rest of the
611+
board; red when it was not, because numbers from two harnesses are not comparable and that has to
612+
be visible rather than known only to the build guard. */
613+
.engine-pill {
614+
display: inline-block;
615+
margin-left: .4rem;
616+
padding: 0 .35rem;
617+
border-radius: 3px;
618+
font: 500 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
619+
color: var(--muted, #6b7280);
620+
background: rgba(127, 127, 127, .12);
621+
vertical-align: baseline;
622+
}
623+
.engine-pill.old {
624+
color: #b42318;
625+
background: rgba(217, 45, 32, .12);
626+
font-weight: 600;
627+
}

‎site/test.mjs‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,4 +3219,37 @@ test("seal: matching a PACED upstream publishes the value; matching a CAPACITY s
32193219
assert.equal(sealMetric(500, { gated: true, paced: true, flag: false }).value, 500);
32203220
assert.equal(sealMetric(500, { gated: true, flag: false }).value, 500);
32213221
});
3222+
// ---- the benchmark version is visible, and an older one is loud -------------------------------
3223+
// The engine commit travelled into every row from the start and nothing rendered it, so "which
3224+
// version of the benchmark produced this number" was answerable only by opening the JSON. A row
3225+
// measured by an older harness is not necessarily wrong, but it is not comparable to the rest, and
3226+
// that has to be visible rather than known only to the build guard that refuses mixed boards.
3227+
test("benchmark version: current rows are quiet, older rows are marked red with what they should be", () => {
3228+
const board = "8f2af5ddc8980fce326ef140e4f75de36e8cfc72";
3229+
const current = { key: "a", measured_at: new Date().toISOString(),
3230+
engine: { sha: board, short: "8f2af5d", current: true } };
3231+
const behind = { key: "b", measured_at: new Date().toISOString(),
3232+
engine: { sha: "dd26a545026be44a0c38589242859138df05b2eb", short: "dd26a54", current: false } };
3233+
3234+
const cur = app.engineBadge(current, board);
3235+
assert.match(cur, /8f2af5d/, "a current row still shows which harness measured it");
3236+
assert.ok(!/engine-pill old/.test(cur), "and is not flagged");
3237+
3238+
const old = app.engineBadge(behind, board);
3239+
assert.match(old, /engine-pill old/, "a row measured by an older harness must be marked");
3240+
assert.match(old, /dd26a54/, "showing the version it WAS measured on");
3241+
assert.match(old, /8f2af5d/, "and the version the board is on, so the reader can see the gap");
3242+
assert.match(old, /not directly comparable/, "and why that matters");
3243+
3244+
// A row with no stamp at all predates the engine stamp entirely. Saying so beats implying it
3245+
// matches, and beats omitting the badge so the reader assumes it does.
3246+
const unstamped = app.engineBadge({ key: "c", engine: { sha: null, short: null, current: false } }, board);
3247+
assert.match(unstamped, /engine unknown/);
3248+
assert.match(unstamped, /engine-pill old/);
3249+
3250+
// Nothing to compare against: no board version and no row version renders nothing rather than an
3251+
// empty pill.
3252+
assert.equal(app.engineBadge({ key: "d", engine: { sha: null, short: null, current: false } }, null), "");
3253+
assert.equal(app.engineBadge({ key: "e" }, board), "", "a row with no engine field at all renders nothing");
3254+
});
32223255

0 commit comments

Comments
 (0)