ostia 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +62 -35
- package/package.json +1 -1
- package/src/ab/ab-runner.ts +57 -44
- package/src/ab/index.ts +186 -112
- package/src/baseline/index.ts +3 -9
- package/src/bench/index.ts +177 -123
- package/src/bench/projects.ts +14 -10
- package/src/bench/registry.ts +68 -66
- package/src/bench/run-tasks.ts +26 -23
- package/src/bench/run.ts +2 -1
- package/src/bench/runner.ts +20 -5
- package/src/bench/support.ts +26 -26
- package/src/bench/sweep.ts +6 -4
- package/src/cache/fingerprint.ts +9 -6
- package/src/cache/store.ts +17 -5
- package/src/capture/bunflags.ts +12 -11
- package/src/capture/cpu-parse.ts +36 -24
- package/src/capture/cpu.ts +7 -4
- package/src/capture/frames.ts +7 -1
- package/src/capture/heap-parse.ts +30 -5
- package/src/capture/heap.ts +9 -5
- package/src/capture/inspector.ts +8 -7
- package/src/capture/jsc-parse.ts +8 -8
- package/src/capture/jsc.ts +4 -4
- package/src/ci/index.ts +64 -40
- package/src/cli/flags.ts +42 -43
- package/src/cli/output.ts +29 -35
- package/src/cli/run.ts +95 -95
- package/src/compare/index.ts +39 -32
- package/src/config/env.ts +13 -0
- package/src/config/index.ts +31 -23
- package/src/config/validate.ts +33 -27
- package/src/format.ts +5 -6
- package/src/glob.ts +9 -12
- package/src/index.ts +1 -3
- package/src/ir/cpu.ts +2 -2
- package/src/ir/defined.ts +12 -0
- package/src/ir/document.ts +93 -73
- package/src/ir/fp.ts +7 -10
- package/src/ir/git.ts +4 -3
- package/src/measure/alloc.ts +7 -8
- package/src/measure/cpu.ts +12 -20
- package/src/measure/environment.ts +5 -8
- package/src/measure/inprocess.ts +15 -15
- package/src/measure/instructions.ts +22 -16
- package/src/measure/loop.ts +24 -17
- package/src/measure/noise.ts +8 -8
- package/src/measure/paired.ts +39 -47
- package/src/measure/peak.ts +20 -21
- package/src/measure/timing.ts +23 -23
- package/src/profile.ts +2 -1
- package/src/renderers/collapsed.ts +28 -21
- package/src/renderers/cpu-tree.ts +43 -35
- package/src/renderers/format.ts +16 -26
- package/src/renderers/index.ts +14 -4
- package/src/renderers/json.ts +2 -2
- package/src/renderers/jsonl.ts +11 -7
- package/src/renderers/markdown.ts +54 -36
- package/src/renderers/mermaid.ts +43 -31
- package/src/renderers/minimal.ts +12 -12
- package/src/renderers/paired.ts +31 -37
- package/src/renderers/relative.ts +10 -14
- package/src/renderers/select.ts +17 -39
- package/src/renderers/speedscope.ts +52 -48
- package/src/renderers/terminal.ts +37 -33
- package/src/spawn/index.ts +38 -47
- package/src/stats/bootstrap.ts +56 -58
- package/src/stats/index.ts +16 -12
- package/src/stats/mannwhitney.ts +11 -10
- package/src/time.ts +51 -39
|
@@ -89,43 +89,49 @@ function warningBullets(label: string, warnings: Warning[]): string[] {
|
|
|
89
89
|
return warnings.map((w) => `- **${label}**: ${warningNote(w)}`);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* two (a `sweep()` over two dimensions): the shape a pivot table needs. */
|
|
92
|
+
// The two param keys every workload shares, when each has exactly those
|
|
93
|
+
// two (a `sweep()` over two dimensions): the shape a pivot table needs.
|
|
95
94
|
function pivotKeysFor(
|
|
96
95
|
workloads: (Workload | undefined)[],
|
|
97
96
|
): [string, string] | undefined {
|
|
98
|
-
let keys: string
|
|
97
|
+
let keys: [string, string] | undefined;
|
|
99
98
|
for (const w of workloads) {
|
|
100
|
-
const k = w?.params ? Object.keys(w.params) :
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
|
|
99
|
+
const k = w?.params ? Object.keys(w.params) : [];
|
|
100
|
+
const [first, second] = k;
|
|
101
|
+
if (k.length !== 2 || first === undefined || second === undefined) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
if (keys === undefined) keys = [first, second];
|
|
105
|
+
else if (keys[0] !== first || keys[1] !== second) return undefined;
|
|
104
106
|
}
|
|
105
|
-
return keys
|
|
107
|
+
return keys;
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
export const markdownRenderer: Renderer = {
|
|
109
111
|
name: "markdown",
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
render(doc: ProfileDocument): Promise<RenderResult> {
|
|
113
|
+
return Promise.try(() => {
|
|
114
|
+
const byWorkload = workloadsById(doc);
|
|
115
|
+
const gitSuffix = doc.git ? ` · ${formatGit(doc.git)}` : "";
|
|
116
|
+
const mismatch = environmentMismatch(doc);
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
const lines = [
|
|
119
|
+
"# Profile Report",
|
|
120
|
+
"",
|
|
121
|
+
`Bun ${doc.bunVersion} · ostia ${doc.toolVersion} · ${doc.platform.os}/${doc.platform.arch} · ${doc.createdAt}${gitSuffix}`,
|
|
122
|
+
"",
|
|
123
|
+
...(doc.environment
|
|
124
|
+
? [formatEnvironmentLine(doc.environment), ""]
|
|
125
|
+
: []),
|
|
126
|
+
...(mismatch ? [`> ⚠ ${mismatch.message}`, ""] : []),
|
|
127
|
+
// Only `ab()` writes paired measurements, and it always stamps `ab`.
|
|
128
|
+
...(doc.ab ? abSection(doc, doc.ab, byWorkload) : []),
|
|
129
|
+
...timingSection(doc, byWorkload),
|
|
130
|
+
...captureSections(doc, byWorkload),
|
|
131
|
+
...comparisonSection(doc),
|
|
132
|
+
];
|
|
133
|
+
return { text: lines.join("\n") };
|
|
134
|
+
});
|
|
129
135
|
},
|
|
130
136
|
};
|
|
131
137
|
|
|
@@ -190,7 +196,10 @@ function abSection(
|
|
|
190
196
|
if (threw.length > 0) {
|
|
191
197
|
lines.push(`Threw (${threw.length}):`, "");
|
|
192
198
|
for (const run of threw) {
|
|
193
|
-
const message = run.threw.message.split("\n")[0]
|
|
199
|
+
const message = (run.threw.message.split("\n")[0] ?? "").replaceAll(
|
|
200
|
+
"`",
|
|
201
|
+
"'",
|
|
202
|
+
);
|
|
194
203
|
lines.push(
|
|
195
204
|
`- **${taskCell(byWorkload.get(run.workloadId), run.workloadId)}**: ${formatThrew(run.threw)}: \`${message}\``,
|
|
196
205
|
);
|
|
@@ -226,8 +235,6 @@ function timingSection(
|
|
|
226
235
|
const runs = timingRuns(doc);
|
|
227
236
|
const noSamples = noSampleRuns(doc);
|
|
228
237
|
const memory = memoryReadings(doc);
|
|
229
|
-
// Rows with nothing to tabulate: `task.skip()`'d and sample-less
|
|
230
|
-
// workloads.
|
|
231
238
|
const empty: {
|
|
232
239
|
id: string;
|
|
233
240
|
workload: Workload | undefined;
|
|
@@ -259,8 +266,12 @@ function timingSection(
|
|
|
259
266
|
const flat: TimingRow[] = [];
|
|
260
267
|
for (const row of rows) {
|
|
261
268
|
const group = groupOf(row.workload);
|
|
262
|
-
if (group === undefined)
|
|
263
|
-
|
|
269
|
+
if (group === undefined) {
|
|
270
|
+
flat.push(row);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
const groupRows = byGroup.get(group);
|
|
274
|
+
if (groupRows) groupRows.push(row);
|
|
264
275
|
else byGroup.set(group, [row]);
|
|
265
276
|
}
|
|
266
277
|
const pivots: { group: string; keys: [string, string]; rows: TimingRow[] }[] =
|
|
@@ -302,8 +313,12 @@ function timingSection(
|
|
|
302
313
|
if (ratios) {
|
|
303
314
|
optional.push({
|
|
304
315
|
header: "Relative",
|
|
305
|
-
cell: (row) =>
|
|
306
|
-
|
|
316
|
+
cell: (row) => {
|
|
317
|
+
const ratio = ratios.get(row);
|
|
318
|
+
return ratio === undefined
|
|
319
|
+
? "-"
|
|
320
|
+
: formatRelative(ratio, !!row.workload?.baseline);
|
|
321
|
+
},
|
|
307
322
|
});
|
|
308
323
|
}
|
|
309
324
|
|
|
@@ -356,8 +371,11 @@ function timingSection(
|
|
|
356
371
|
const colValues: ParamValue[] = [];
|
|
357
372
|
const medianAt = new Map<string, number>();
|
|
358
373
|
for (const { run, workload } of groupRows) {
|
|
359
|
-
const v1 = workload
|
|
360
|
-
const v2 = workload
|
|
374
|
+
const v1 = workload?.params?.[key1];
|
|
375
|
+
const v2 = workload?.params?.[key2];
|
|
376
|
+
// invariant: `pivotKeysFor` pivots only rows whose params hold both
|
|
377
|
+
// keys.
|
|
378
|
+
if (v1 === undefined || v2 === undefined) continue;
|
|
361
379
|
if (!rowValues.includes(v1)) rowValues.push(v1);
|
|
362
380
|
if (!colValues.includes(v2)) colValues.push(v2);
|
|
363
381
|
medianAt.set(`${v1} ${v2}`, run.timing.median);
|
package/src/renderers/mermaid.ts
CHANGED
|
@@ -17,7 +17,8 @@ function label(name: string, selfUs: number, totalUs: number): string {
|
|
|
17
17
|
return `${name.replace(/"/g, "'")} (self ${formatUsAsMs(selfUs)}ms, total ${formatUsAsMs(totalUs)}ms)`;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// Insertion into a sorted window
|
|
20
|
+
// Insertion into a sorted window instead of a full sort, since n is
|
|
21
|
+
// small: O(count * n).
|
|
21
22
|
function topNBySelf(
|
|
22
23
|
selfUs: Float64Array,
|
|
23
24
|
count: number,
|
|
@@ -26,12 +27,14 @@ function topNBySelf(
|
|
|
26
27
|
): number[] {
|
|
27
28
|
const top: number[] = [];
|
|
28
29
|
if (n <= 0) return top;
|
|
30
|
+
const selfAt = (ix: number | undefined) =>
|
|
31
|
+
ix === undefined ? 0 : (selfUs[ix] ?? 0);
|
|
29
32
|
for (let i = 0; i < count; i++) {
|
|
30
33
|
if (i === exclude) continue;
|
|
31
|
-
const v =
|
|
32
|
-
if (top.length === n && v <=
|
|
34
|
+
const v = selfAt(i);
|
|
35
|
+
if (top.length === n && v <= selfAt(top[n - 1])) continue;
|
|
33
36
|
let j = top.length;
|
|
34
|
-
while (j > 0 &&
|
|
37
|
+
while (j > 0 && selfAt(top[j - 1]) < v) j--;
|
|
35
38
|
top.splice(j, 0, i);
|
|
36
39
|
if (top.length > n) top.pop();
|
|
37
40
|
}
|
|
@@ -40,39 +43,48 @@ function topNBySelf(
|
|
|
40
43
|
|
|
41
44
|
export const mermaidRenderer: Renderer<MermaidOptions> = {
|
|
42
45
|
name: "mermaid",
|
|
43
|
-
|
|
46
|
+
render(
|
|
44
47
|
doc: ProfileDocument,
|
|
45
48
|
options: MermaidOptions = {},
|
|
46
49
|
): Promise<RenderResult> {
|
|
47
|
-
|
|
50
|
+
return Promise.try(() => {
|
|
51
|
+
const topN = options.topN ?? DEFAULT_TOP_N;
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
return renderCpuFiles(doc, options, "mermaid.md", ({ cpu }) => {
|
|
54
|
+
const { nodes, frames } = cpu;
|
|
55
|
+
const tree = buildDenseTree(cpu);
|
|
56
|
+
const { selfUs, totalUs } = computeDenseNodeTimes(cpu, tree);
|
|
57
|
+
const { parentIx } = tree;
|
|
58
|
+
const rootIx = tree.roots[0] ?? -1;
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
// The top-N self-time nodes plus every ancestor, so each has a path to the
|
|
61
|
+
// root.
|
|
62
|
+
const included = new Set<number>(rootIx !== -1 ? [rootIx] : []);
|
|
63
|
+
for (const ix of topNBySelf(selfUs, tree.count, rootIx, topN)) {
|
|
64
|
+
const path: number[] = [];
|
|
65
|
+
for (let cur = ix; cur !== -1; cur = parentIx[cur] ?? -1) {
|
|
66
|
+
path.push(cur);
|
|
67
|
+
}
|
|
68
|
+
for (const p of path.toReversed()) included.add(p);
|
|
69
|
+
}
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
const id = (ix: number) => `n${nodes[ix]?.id}`;
|
|
72
|
+
const lines = ["graph TD"];
|
|
73
|
+
for (const ix of included) {
|
|
74
|
+
const node = nodes[ix];
|
|
75
|
+
if (node === undefined) continue;
|
|
76
|
+
const name = frameName(frames[node.frameIx]);
|
|
77
|
+
lines.push(
|
|
78
|
+
` ${id(ix)}["${label(name, selfUs[ix] ?? 0, totalUs[ix] ?? 0)}"]`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
for (const ix of included) {
|
|
82
|
+
const p = parentIx[ix] ?? -1;
|
|
83
|
+
if (p !== -1 && included.has(p))
|
|
84
|
+
lines.push(` ${id(p)} --> ${id(ix)}`);
|
|
85
|
+
}
|
|
86
|
+
return `${lines.join("\n")}\n`;
|
|
87
|
+
});
|
|
76
88
|
});
|
|
77
89
|
},
|
|
78
90
|
};
|
package/src/renderers/minimal.ts
CHANGED
|
@@ -232,6 +232,7 @@ interface MinimalSummaryLine {
|
|
|
232
232
|
exitCode: number;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
/** One parsed line of `--format minimal` output; narrow on `event`. */
|
|
235
236
|
export type MinimalEvent =
|
|
236
237
|
MinimalRunLine | MinimalUnmatchedLine | MinimalSummaryLine;
|
|
237
238
|
|
|
@@ -310,9 +311,6 @@ function deltaFrom(
|
|
|
310
311
|
return delta;
|
|
311
312
|
}
|
|
312
313
|
|
|
313
|
-
/**
|
|
314
|
-
* A `run` line with no stats: a `task.skip()`'d workload, or one whose
|
|
315
|
-
* trials produced no samples (`samples: 0`). */
|
|
316
314
|
function statlessLine(
|
|
317
315
|
doc: ProfileDocument,
|
|
318
316
|
workload: Workload,
|
|
@@ -428,7 +426,7 @@ function runLines(doc: ProfileDocument): MinimalRunLine[] {
|
|
|
428
426
|
line.userNs = sig(times.userNs);
|
|
429
427
|
line.systemNs = sig(times.systemNs);
|
|
430
428
|
}
|
|
431
|
-
//
|
|
429
|
+
// invariant: an `ab` run's stats are the candidate's, memory included.
|
|
432
430
|
const readings = memory.get(run.workloadId);
|
|
433
431
|
const retained = readings?.retained ?? run.paired?.retained?.candBytes;
|
|
434
432
|
if (retained !== undefined) line.retainedBytesPerOp = Math.round(retained);
|
|
@@ -587,16 +585,18 @@ function summaryLine(
|
|
|
587
585
|
|
|
588
586
|
export const minimalRenderer: Renderer<MinimalRenderOptions> = {
|
|
589
587
|
name: "minimal",
|
|
590
|
-
|
|
588
|
+
render(
|
|
591
589
|
doc: ProfileDocument,
|
|
592
590
|
options: MinimalRenderOptions = {},
|
|
593
591
|
): Promise<RenderResult> {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
592
|
+
return Promise.try(() => {
|
|
593
|
+
const events: MinimalEvent[] = [...runLines(doc)];
|
|
594
|
+
if (options.protocol) {
|
|
595
|
+
events.push(...unmatchedLines(options.protocol));
|
|
596
|
+
events.push(summaryLine(doc, options.protocol));
|
|
597
|
+
}
|
|
598
|
+
const lines = events.map((l) => JSON.stringify(l));
|
|
599
|
+
return { text: lines.length > 0 ? `${lines.join("\n")}\n` : "" };
|
|
600
|
+
});
|
|
601
601
|
},
|
|
602
602
|
};
|
package/src/renderers/paired.ts
CHANGED
|
@@ -20,16 +20,16 @@ export type PairedRun = Measurement & {
|
|
|
20
20
|
paired: PairedEvidence;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
type ThrewRun = Measurement & {
|
|
24
24
|
threw: NonNullable<Measurement["threw"]>;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// Matches a throw on either side, in the first process or a repeat, since
|
|
28
|
+
// both set `threw`.
|
|
28
29
|
function isThrewRun(m: Measurement): m is ThrewRun {
|
|
29
30
|
return m.phase === "paired" && m.threw !== undefined;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
/** A task judged on its time: measured, and it never threw. */
|
|
33
33
|
function isPairedRun(m: Measurement): m is PairedRun {
|
|
34
34
|
return (
|
|
35
35
|
m.phase === "paired" &&
|
|
@@ -43,15 +43,13 @@ export function pairedRuns(doc: ProfileDocument): PairedRun[] {
|
|
|
43
43
|
return doc.measurements.filter(isPairedRun);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/** An `ab()` document's tasks that threw. */
|
|
47
46
|
export function threwRuns(doc: ProfileDocument): ThrewRun[] {
|
|
48
47
|
return doc.measurements.filter(isThrewRun);
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
type AbRow =
|
|
52
51
|
{ kind: "timed"; run: PairedRun } | { kind: "threw"; run: ThrewRun };
|
|
53
52
|
|
|
54
|
-
/** Every row of an A/B table, timed or threw, in document order. */
|
|
55
53
|
export function abRows(doc: ProfileDocument): AbRow[] {
|
|
56
54
|
const rows: AbRow[] = [];
|
|
57
55
|
for (const m of doc.measurements) {
|
|
@@ -61,14 +59,10 @@ export function abRows(doc: ProfileDocument): AbRow[] {
|
|
|
61
59
|
return rows;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
/**
|
|
65
|
-
* `base threw`, `candidate threw`, `both threw`, with `(repeat 1)` when it
|
|
66
|
-
* threw in a confirmation repeat. */
|
|
67
62
|
export function formatThrew(threw: ThrewRun["threw"]): string {
|
|
68
63
|
return `${sideLabel(threw.side)} threw${threw.repeat ? ` (repeat ${threw.repeat})` : ""}`;
|
|
69
64
|
}
|
|
70
65
|
|
|
71
|
-
/** A candidate/base ratio as a signed percent change: `1.032` is `+3.2%`. */
|
|
72
66
|
function formatRatio(ratio: number): string {
|
|
73
67
|
return formatSignedPct((ratio - 1) * 100);
|
|
74
68
|
}
|
|
@@ -86,17 +80,26 @@ function pairedVerdict(p: PairedEvidence, metric: AbSummary["metric"]): string {
|
|
|
86
80
|
return `${p.confirmed ? `${p.flagged}, confirmed` : `${p.flagged}? unconfirmed`}${repeats}`;
|
|
87
81
|
}
|
|
88
82
|
|
|
89
|
-
/** `New suites, not at HEAD: bench/new.bench.ts`, or nothing. */
|
|
90
83
|
export function formatNewSuites(ab: AbSummary): string | undefined {
|
|
91
84
|
if (!ab.newSuites?.length) return undefined;
|
|
92
85
|
return `New suite${ab.newSuites.length > 1 ? "s" : ""}, not at ${ab.base.ref}: ${ab.newSuites.join(", ")}`;
|
|
93
86
|
}
|
|
94
87
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
interface PairedCells {
|
|
89
|
+
base: string;
|
|
90
|
+
candidate: string;
|
|
91
|
+
change: string;
|
|
92
|
+
spread: string;
|
|
93
|
+
also: string;
|
|
94
|
+
verdict: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// `also` is the other metric's change (see `alsoHeader`), blank on a task
|
|
98
|
+
// without an instruction count.
|
|
99
|
+
export function pairedCells(
|
|
100
|
+
run: PairedRun,
|
|
101
|
+
metric: AbSummary["metric"],
|
|
102
|
+
): PairedCells {
|
|
100
103
|
const p = run.paired;
|
|
101
104
|
const i = p.instructions;
|
|
102
105
|
const judged = metricRatios(p, metric);
|
|
@@ -123,9 +126,6 @@ export function pairedCells(run: PairedRun, metric: AbSummary["metric"]) {
|
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
/**
|
|
127
|
-
* The header of `pairedCells`'s `also` column, or undefined when no row
|
|
128
|
-
* would fill it. */
|
|
129
129
|
export function alsoHeader(
|
|
130
130
|
doc: ProfileDocument,
|
|
131
131
|
metric: AbSummary["metric"],
|
|
@@ -136,13 +136,12 @@ export function alsoHeader(
|
|
|
136
136
|
: undefined;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
interface MemoryRow {
|
|
140
140
|
run: PairedRun;
|
|
141
141
|
reading: "retained/op" | "peak";
|
|
142
142
|
change: MemoryChange;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/** Each timed task's memory readings, retained before peak. */
|
|
146
145
|
export function memoryRows(doc: ProfileDocument): MemoryRow[] {
|
|
147
146
|
return pairedRuns(doc).flatMap((run) => {
|
|
148
147
|
const rows: MemoryRow[] = [];
|
|
@@ -153,9 +152,8 @@ export function memoryRows(doc: ProfileDocument): MemoryRow[] {
|
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
* the noise floor, where it would be huge and meaningless. */
|
|
155
|
+
// No percent when the base is under the noise floor, where it would be
|
|
156
|
+
// huge and meaningless.
|
|
159
157
|
function formatByteChange(c: MemoryChange): string {
|
|
160
158
|
const base = Math.round(c.baseBytes);
|
|
161
159
|
const diff = Math.round(c.candBytes) - base;
|
|
@@ -165,8 +163,15 @@ function formatByteChange(c: MemoryChange): string {
|
|
|
165
163
|
return `${bytes} (${formatSignedPct((diff / base) * 100)})`;
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
interface MemoryCells {
|
|
167
|
+
reading: MemoryRow["reading"];
|
|
168
|
+
base: string;
|
|
169
|
+
candidate: string;
|
|
170
|
+
change: string;
|
|
171
|
+
verdict: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function memoryCells({ reading, change: c }: MemoryRow): MemoryCells {
|
|
170
175
|
return {
|
|
171
176
|
reading,
|
|
172
177
|
base: formatBytes(c.baseBytes),
|
|
@@ -176,10 +181,6 @@ export function memoryCells({ reading, change: c }: MemoryRow) {
|
|
|
176
181
|
};
|
|
177
182
|
}
|
|
178
183
|
|
|
179
|
-
/**
|
|
180
|
-
* `working tree vs HEAD (26e7d0d) · 15 rounds · threshold 10% · geomean
|
|
181
|
-
* threshold 1.5%`, with `· by instructions/call` after the rounds when
|
|
182
|
-
* that's the metric. */
|
|
183
184
|
export function formatAbHeader(ab: AbSummary): string {
|
|
184
185
|
const metric = ab.metric === "instructions" ? " · by instructions/call" : "";
|
|
185
186
|
const memory = ab.memory
|
|
@@ -188,10 +189,6 @@ export function formatAbHeader(ab: AbSummary): string {
|
|
|
188
189
|
return `working tree vs ${ab.base.ref} (${ab.base.sha.slice(0, 7)}) · ${ab.rounds} rounds${metric} · threshold ${ab.thresholdPct}% · geomean threshold ${ab.geomeanThresholdPct}%${memory}`;
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
/**
|
|
192
|
-
* `Geomean +2.1% (threshold 1.5%) · 1 regressed, 0 improved, 47 unchanged
|
|
193
|
-
* of 48 (1 unconfirmed) · memory: 0 regressed, 1 improved · fail`
|
|
194
|
-
*/
|
|
195
192
|
export function formatAbSummary(ab: AbSummary): string {
|
|
196
193
|
const geomean =
|
|
197
194
|
ab.geomeanPct === null
|
|
@@ -209,9 +206,6 @@ export function formatAbSummary(ab: AbSummary): string {
|
|
|
209
206
|
return `${geomean} · ${ab.regressed} regressed, ${ab.improved} improved, ${ab.unchanged} unchanged of ${ab.matched}${unconfirmed}${memory} · ${ab.verdict}`;
|
|
210
207
|
}
|
|
211
208
|
|
|
212
|
-
/**
|
|
213
|
-
* Labels of workloads whose output differed between sides, and of those
|
|
214
|
-
* present on only one side. */
|
|
215
209
|
export function abNotes(doc: ProfileDocument): {
|
|
216
210
|
outputDiffers: string[];
|
|
217
211
|
baseOnly: string[];
|
|
@@ -6,10 +6,9 @@ export interface TimingRow {
|
|
|
6
6
|
workload: Workload | undefined;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* existed). */
|
|
9
|
+
// The explicit `entry.group` the bench runner records, else the
|
|
10
|
+
// "group/name" id split on its last "/" (documents from before that field
|
|
11
|
+
// existed).
|
|
13
12
|
export function groupOf(workload: Workload | undefined): string | undefined {
|
|
14
13
|
if (!workload?.entry) return undefined;
|
|
15
14
|
if (workload.entry.group !== undefined) return workload.entry.group;
|
|
@@ -18,21 +17,18 @@ export function groupOf(workload: Workload | undefined): string | undefined {
|
|
|
18
17
|
return idx === -1 ? undefined : id.slice(0, idx);
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
* A row's label under its group's header: the task name alone, since the
|
|
23
|
-
* header already shows the group. */
|
|
20
|
+
// The task name alone, since the group's header already shows the group.
|
|
24
21
|
export function labelInGroup(label: string, group: string | undefined): string {
|
|
25
22
|
return group !== undefined && label.startsWith(`${group}/`)
|
|
26
23
|
? label.slice(group.length + 1)
|
|
27
24
|
: label;
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* means nothing. */
|
|
27
|
+
// Each row's reference median is its group's
|
|
28
|
+
// `task(..., { baseline: true })` task, else the group's fastest.
|
|
29
|
+
// Ungrouped rows use the fastest in the document; tasks never compare
|
|
30
|
+
// across groups. Undefined with fewer than two rows, where "relative"
|
|
31
|
+
// means nothing.
|
|
36
32
|
export function relativeRatios<R extends TimingRow>(
|
|
37
33
|
rows: R[],
|
|
38
34
|
): Map<R, number> | undefined {
|
|
@@ -52,7 +48,7 @@ export function relativeRatios<R extends TimingRow>(
|
|
|
52
48
|
const key = groupOf(row.workload);
|
|
53
49
|
let reference = fastestMedian;
|
|
54
50
|
if (key !== undefined) {
|
|
55
|
-
const siblings = siblingsByGroup.get(key)
|
|
51
|
+
const siblings = siblingsByGroup.get(key) ?? [row];
|
|
56
52
|
const baselineRow = siblings.find((s) => s.workload?.baseline);
|
|
57
53
|
reference = baselineRow
|
|
58
54
|
? baselineRow.run.timing.median
|
package/src/renderers/select.ts
CHANGED
|
@@ -14,15 +14,16 @@ import {
|
|
|
14
14
|
workloadLabel,
|
|
15
15
|
} from "./format.ts";
|
|
16
16
|
|
|
17
|
-
// Below this absolute percent a frame/heap-type delta is noise,
|
|
17
|
+
// Below this absolute percent a frame/heap-type delta is noise, so it gets
|
|
18
|
+
// no row.
|
|
18
19
|
const MIN_DISPLAY_DELTA_PCT = 0.5;
|
|
19
20
|
|
|
20
21
|
export type TimingRun = Measurement & {
|
|
21
22
|
timing: NonNullable<Measurement["timing"]>;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
type FrameDelta = NonNullable<Comparison["frames"]>[number];
|
|
26
|
+
type HeapTypeDelta = NonNullable<Comparison["heapTypes"]>[number];
|
|
26
27
|
|
|
27
28
|
export function workloadsById(doc: ProfileDocument): Map<string, Workload> {
|
|
28
29
|
return new Map(doc.workloads.map((w) => [w.id, w]));
|
|
@@ -34,20 +35,14 @@ export function timingRuns(doc: ProfileDocument): TimingRun[] {
|
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* missed the `timeSource` pattern). Renderers show them as "no samples"
|
|
40
|
-
* rows so their warnings stay visible. */
|
|
38
|
+
// Every trial timed out or missed the `timeSource` pattern. Renderers show
|
|
39
|
+
// these as "no samples" rows so their warnings stay visible.
|
|
41
40
|
export function noSampleRuns(doc: ProfileDocument): Measurement[] {
|
|
42
41
|
return doc.measurements.filter(
|
|
43
42
|
(r) => r.phase === "timing" && r.timing === undefined,
|
|
44
43
|
);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
/**
|
|
48
|
-
* `task.skip()`'d workloads with no measurement, rendered as "- skipped"
|
|
49
|
-
* rows.
|
|
50
|
-
*/
|
|
51
46
|
export function skippedWorkloads(
|
|
52
47
|
doc: ProfileDocument,
|
|
53
48
|
runs: { workloadId: string }[],
|
|
@@ -56,10 +51,9 @@ export function skippedWorkloads(
|
|
|
56
51
|
return doc.workloads.filter((w) => w.skipped && !measured.has(w.id));
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* row. */
|
|
54
|
+
// `environment-mismatch` is the same on every comparison because it
|
|
55
|
+
// concerns the base/cand pair, so renderers print it once, from here, and
|
|
56
|
+
// drop it per row.
|
|
63
57
|
export function environmentMismatch(doc: ProfileDocument): Warning | undefined {
|
|
64
58
|
for (const c of doc.comparisons ?? []) {
|
|
65
59
|
const w = c.warnings?.find((w) => w.code === "environment-mismatch");
|
|
@@ -72,11 +66,9 @@ export function rowComparisonWarnings(cmp: Comparison): Warning[] {
|
|
|
72
66
|
return (cmp.warnings ?? []).filter((w) => w.code !== "environment-mismatch");
|
|
73
67
|
}
|
|
74
68
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
* workload). A skipped candidate has no measurement, so
|
|
79
|
-
* `candidateMeasurementId` then holds the workload id itself. */
|
|
69
|
+
// The workload id is the display fallback when the document lacks the
|
|
70
|
+
// workload. A skipped candidate has no measurement, so
|
|
71
|
+
// `candidateMeasurementId` then holds the workload id itself.
|
|
80
72
|
function comparisonResolver(doc: ProfileDocument) {
|
|
81
73
|
const workloads = workloadsById(doc);
|
|
82
74
|
const runs = new Map(doc.measurements.map((m) => [m.id, m]));
|
|
@@ -102,7 +94,7 @@ export function shownHeapDeltas(
|
|
|
102
94
|
.filter((h) => Math.abs(h.deltaPct) >= MIN_DISPLAY_DELTA_PCT);
|
|
103
95
|
}
|
|
104
96
|
|
|
105
|
-
|
|
97
|
+
interface MemoryReadings {
|
|
106
98
|
/** `--alloc`: heap each call retains, bytes. */
|
|
107
99
|
retained?: number;
|
|
108
100
|
/** `--peak-mem`: RSS rise of one call, bytes. */
|
|
@@ -127,7 +119,6 @@ export function memoryReadings(
|
|
|
127
119
|
return byWorkload;
|
|
128
120
|
}
|
|
129
121
|
|
|
130
|
-
/** A timing run's warnings plus its workload's `memstats` warnings. */
|
|
131
122
|
export function runWarnings(
|
|
132
123
|
run: Measurement,
|
|
133
124
|
memory: Map<string, MemoryReadings>,
|
|
@@ -136,16 +127,12 @@ export function runWarnings(
|
|
|
136
127
|
return extra?.length ? [...run.warnings, ...extra] : run.warnings;
|
|
137
128
|
}
|
|
138
129
|
|
|
139
|
-
|
|
130
|
+
interface MemoryColumn {
|
|
140
131
|
header: string;
|
|
141
132
|
/** Formatted bytes, or undefined when this workload has no reading. */
|
|
142
133
|
cell: (workloadId: string) => string | undefined;
|
|
143
134
|
}
|
|
144
135
|
|
|
145
|
-
/**
|
|
146
|
-
* `Retained/op` and `Peak mem` columns, each only when some workload has
|
|
147
|
-
* it.
|
|
148
|
-
*/
|
|
149
136
|
export function memoryColumns(
|
|
150
137
|
memory: Map<string, MemoryReadings>,
|
|
151
138
|
): MemoryColumn[] {
|
|
@@ -168,11 +155,9 @@ export function memoryColumns(
|
|
|
168
155
|
}));
|
|
169
156
|
}
|
|
170
157
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
* rebuilt from `comparisons` and `unmatched`: no sample counts or memory,
|
|
175
|
-
* the base median derived from the change, base-only tasks named by id. */
|
|
158
|
+
// A document compared before `compared` existed gets rows rebuilt from
|
|
159
|
+
// `comparisons` and `unmatched`: no sample counts or memory, the base
|
|
160
|
+
// median derived from the change, base-only tasks named by id.
|
|
176
161
|
export function comparedRows(
|
|
177
162
|
doc: ProfileDocument,
|
|
178
163
|
): { row: ComparedTask; cmp: Comparison | undefined }[] {
|
|
@@ -251,9 +236,6 @@ const MEMORY_READING_LABELS: Record<MemoryDelta["reading"], string> = {
|
|
|
251
236
|
maxRss: "max RSS",
|
|
252
237
|
};
|
|
253
238
|
|
|
254
|
-
/**
|
|
255
|
-
* `heap used before 12.00MiB → 16.80MiB (+40.0%)` for each memory reading
|
|
256
|
-
* that moved at least 10%. */
|
|
257
239
|
export function shownMemoryDeltas(row: ComparedTask, arrow = "→"): string[] {
|
|
258
240
|
return (row.memory ?? [])
|
|
259
241
|
.filter((m) => !(Math.abs(m.deltaPct) < MIN_MEMORY_DISPLAY_PCT))
|
|
@@ -263,9 +245,6 @@ export function shownMemoryDeltas(row: ComparedTask, arrow = "→"): string[] {
|
|
|
263
245
|
);
|
|
264
246
|
}
|
|
265
247
|
|
|
266
|
-
/**
|
|
267
|
-
* `Timing threshold 5.0%, widened to 17.3% by machine noise and drift
|
|
268
|
-
* (12.3%)`, when noise or drift widened it; else undefined. */
|
|
269
248
|
export function thresholdNote(doc: ProfileDocument): string | undefined {
|
|
270
249
|
const summary = doc.comparisonSummary;
|
|
271
250
|
const base = doc.comparisons?.[0]?.thresholds.timingPct;
|
|
@@ -278,7 +257,6 @@ export function thresholdNote(doc: ProfileDocument): string | undefined {
|
|
|
278
257
|
return `Timing threshold ${base.toFixed(1)}%, widened to ${summary.effectiveTimingPct.toFixed(1)}% by machine noise${drift}`;
|
|
279
258
|
}
|
|
280
259
|
|
|
281
|
-
/** "base only" / "candidate only", and what that usually means. */
|
|
282
260
|
export function oneSidedNote(verdict: "missing-base" | "missing-cand"): string {
|
|
283
261
|
return verdict === "missing-base"
|
|
284
262
|
? "candidate only (new, or renamed without `aliases`)"
|