ostia 0.2.10 → 0.2.12
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/README.md +16 -7
- package/ab-runner.ts +6 -6
- package/chunk-05jfst35.js +28 -0
- package/chunk-1g1x9zz2.js +15 -0
- package/chunk-23g2rwrn.js +3 -0
- package/chunk-468h5412.js +25 -0
- package/chunk-4esjfc2m.js +2 -0
- package/{chunk-qwhvzj0v.js → chunk-9sx15b08.js} +21 -15
- package/chunk-ct2xsezd.js +14 -0
- package/cli.js +1 -1
- package/index.d.ts +173 -8
- package/index.js +1 -1
- package/package.json +1 -1
- package/runner.ts +5 -5
- package/chunk-9cr8k2g1.js +0 -2
- package/chunk-jvjh4223.js +0 -27
- package/chunk-jzfv4c07.js +0 -15
- package/chunk-rhk7gwaa.js +0 -28
- package/chunk-w9pvsd7y.js +0 -14
- package/chunk-zf3y6chk.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var cn=`ostia time [flags] <command...>
|
|
3
3
|
ostia time [flags] -- <argv...>
|
|
4
4
|
|
|
5
5
|
Time commands as subprocesses. Each <command> is whitespace-split into argv (no shell);
|
|
@@ -35,7 +35,7 @@ Examples:
|
|
|
35
35
|
ostia time --prepare "rm -rf dist" "bun build.ts"
|
|
36
36
|
ostia time --time-source "built in (\\d+)ms" "bun build.ts"
|
|
37
37
|
ostia time -- bun -e "console.log('a b')"
|
|
38
|
-
`,
|
|
38
|
+
`,Ke=`ostia bench [flags] <suite.ts...>
|
|
39
39
|
|
|
40
40
|
Run in-process group()/task() suites, each file in its own child process. With no files,
|
|
41
41
|
uses ostia.config's "bench" section; each flag overrides its config field.
|
|
@@ -72,7 +72,7 @@ Examples:
|
|
|
72
72
|
ostia bench bench/*.ts
|
|
73
73
|
ostia bench bench/*.ts --filter parse --cpu --alloc
|
|
74
74
|
ostia bench --preload ./bench/dom-setup.ts --bun-flags="--conditions=browser" bench/*.ts
|
|
75
|
-
`,
|
|
75
|
+
`,qe=`ostia ab [flags] <suite.ts...>
|
|
76
76
|
|
|
77
77
|
Pair every task on a git ref's committed tree (base) against the working tree (candidate), in
|
|
78
78
|
one process, alternating ~10ms batches, and gate on the per-round time ratio. Drift between
|
|
@@ -84,6 +84,8 @@ Flags:
|
|
|
84
84
|
--base-setup CMD shell command run once in a freshly extracted base tree, e.g. to build
|
|
85
85
|
gitignored files the suites import (repeatable, in order)
|
|
86
86
|
--rounds N base/candidate rounds per task (default: 15)
|
|
87
|
+
--metric METRIC judge each round's time or instructions ratio (default: time);
|
|
88
|
+
instructions retired per call barely move on a loaded machine
|
|
87
89
|
--threshold PCT flag a task whose median ratio moves past PCT (default: 10)
|
|
88
90
|
--geomean-threshold PCT fail when the geometric mean of all ratios is slower than PCT
|
|
89
91
|
(default: 1.5)
|
|
@@ -97,7 +99,7 @@ Flags:
|
|
|
97
99
|
--preload PATH import before each suite file (repeatable, in order)
|
|
98
100
|
--bun-flags FLAGS extra flags for the bun process running each suite (repeatable)
|
|
99
101
|
--timeout MS kill a suite (or repeat) process after MS
|
|
100
|
-
--out-dir PATH scratch directory
|
|
102
|
+
--out-dir PATH scratch directory (default: node_modules/.cache/ostia)
|
|
101
103
|
--keep-trees N base trees to keep cached, least recently used go first (default: 5)
|
|
102
104
|
--clean remove every cached base tree, then exit
|
|
103
105
|
--config PATH read this config file instead of ostia.config.ts/.json
|
|
@@ -109,10 +111,11 @@ Flags:
|
|
|
109
111
|
--quiet don't print the report
|
|
110
112
|
--help show this message
|
|
111
113
|
|
|
112
|
-
The base tree is cached per commit (and --base-setup commands) under
|
|
114
|
+
The base tree is cached per commit (and --base-setup commands) under .ostia/ab. Setup runs
|
|
113
115
|
with the project's node_modules linked in, and OSTIA_AB_SHA and OSTIA_AB_CANDIDATE_DIR (the
|
|
114
|
-
working tree) set.
|
|
115
|
-
|
|
116
|
+
working tree) set. Instructions per call are counted where the machine allows (macOS;
|
|
117
|
+
Linux with perf_event_paranoid <= 2 and a hardware counter) and shown next to time. A
|
|
118
|
+
flagged task counts only when every fresh-process repeat flags it the same way. A task that throws isn't timed; one that throws on the candidate side only fails
|
|
116
119
|
the run. A task whose suite file and output both changed reads "not comparable" and stays
|
|
117
120
|
out of the verdict. Exit codes: 0 pass, 1 a confirmed regression, a candidate-only throw,
|
|
118
121
|
the geomean over its threshold or a memory regression, 2 nothing paired or a harness error (not a git repo,
|
|
@@ -122,13 +125,16 @@ Examples:
|
|
|
122
125
|
ostia ab bench/parse.bench.ts
|
|
123
126
|
ostia ab bench/*.ts --base origin/main --rounds 21
|
|
124
127
|
ostia ab bench/*.ts --filter parse --format minimal
|
|
128
|
+
ostia ab bench/*.ts --metric instructions --threshold 3
|
|
125
129
|
ostia ab bench/*.ts --base-setup "bun scripts/generate.ts"
|
|
126
130
|
ostia ab bench/paint.bench.ts --alloc --peak-mem
|
|
127
|
-
`,
|
|
131
|
+
`,Ye=`ostia compare <base.json> <candidate.json>
|
|
128
132
|
ostia compare <candidate.json> --baseline <base.json>
|
|
129
133
|
|
|
130
|
-
Compare two ProfileDocuments by workload id
|
|
131
|
-
present (the same ones "ostia ci"
|
|
134
|
+
Compare two ProfileDocuments by workload id (or a task's former names, from its
|
|
135
|
+
"aliases"). Gates on ostia.config's "thresholds" when present (the same ones "ostia ci"
|
|
136
|
+
uses), else the defaults, widened by machine noise and drift. Tasks on only one side are
|
|
137
|
+
listed under "Not compared"; with --format json, "compared" holds one row per task.
|
|
132
138
|
|
|
133
139
|
Flags:
|
|
134
140
|
--baseline PATH the base document, when only the candidate is positional
|
|
@@ -140,7 +146,7 @@ Flags:
|
|
|
140
146
|
|
|
141
147
|
Exactly two document paths (one with --baseline); anything more is an error.
|
|
142
148
|
Exit codes: 0 pass, 1 a workload regressed, 2 nothing matched or a harness error.
|
|
143
|
-
`,
|
|
149
|
+
`,Ze=`ostia report <document.json> [flags]
|
|
144
150
|
|
|
145
151
|
Render a saved ProfileDocument. Files, not a GUI for the visualization formats -
|
|
146
152
|
hand the output to speedscope.app, flamegraph.pl, or a Mermaid renderer.
|
|
@@ -168,7 +174,7 @@ Examples:
|
|
|
168
174
|
ostia report doc.json --format markdown
|
|
169
175
|
ostia report doc.json --format speedscope --out-dir node_modules/.cache/ostia/viz
|
|
170
176
|
ostia report doc.json --format collapsed | flamegraph.pl > flame.svg
|
|
171
|
-
`,
|
|
177
|
+
`,un=`ostia ci [flags]
|
|
172
178
|
|
|
173
179
|
Run ostia.config's workloads (reusing cached runs whose declared inputs are unchanged),
|
|
174
180
|
compare against a saved baseline, and gate on regressions.
|
|
@@ -188,7 +194,7 @@ Flags:
|
|
|
188
194
|
Exit codes: 0 pass, 1 regression, 2 harness error (missing config/baseline, a workload
|
|
189
195
|
failed or produced no samples, or an onMissingBaseline "fail" mismatch), 130 Ctrl-C (the
|
|
190
196
|
partial document is exported; nothing is compared or saved).
|
|
191
|
-
`,
|
|
197
|
+
`,re=`ostia baseline <save|list|show> [args]
|
|
192
198
|
|
|
193
199
|
Manage the baseline ProfileDocuments "ostia ci" gates against and "ostia compare --baseline"
|
|
194
200
|
reads.
|
|
@@ -211,7 +217,7 @@ Examples:
|
|
|
211
217
|
ostia baseline list
|
|
212
218
|
ostia baseline show main
|
|
213
219
|
ostia baseline show main --format markdown
|
|
214
|
-
`,
|
|
220
|
+
`,mn=`ostia - profiling and benchmarking for Bun
|
|
215
221
|
|
|
216
222
|
Commands:
|
|
217
223
|
time Time commands N times and report timing/CPU/heap
|
|
@@ -224,4 +230,4 @@ Commands:
|
|
|
224
230
|
|
|
225
231
|
Run "ostia <command> --help" for details.
|
|
226
232
|
`;
|
|
227
|
-
export{
|
|
233
|
+
export{cn,Ke,qe,Ye,Ze,un,re,mn};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{V}from"./chunk-1g1x9zz2.js";import{dlopen as g,FFIType as l,ptr as B}from"bun:ffi";import{heapStats as S}from"bun:jsc";function J(){let{heapSize:n,extraMemorySize:e}=S(),s=process.memoryUsage.rss();return{rssBytes:s,residentBytes:h()??s,liveBytes:n+e}}function h(){if(process.platform!=="darwin")return;return u??=b(),u()}var u;function b(){let{symbols:n}=g("/usr/lib/libSystem.B.dylib",{proc_pid_rusage:{args:[l.i32,l.i32,l.ptr],returns:l.i32}}),e=new BigUint64Array(12);return()=>n.proc_pid_rusage(process.pid,0,B(e))===0?Number(e[8]):void 0}var t={ready:1,go:2,sampling:3,stop:4},A=`self.onmessage = (event) => {
|
|
3
|
+
const slots = new Int32Array(event.data)
|
|
4
|
+
Atomics.store(slots, 0, ${t.ready})
|
|
5
|
+
Atomics.wait(slots, 0, ${t.ready})
|
|
6
|
+
if (Atomics.compareExchange(slots, 0, ${t.go}, ${t.sampling}) === ${t.go}) {
|
|
7
|
+
while (Atomics.load(slots, 0) === ${t.sampling}) {
|
|
8
|
+
const kib = (process.memoryUsage.rss() / 1024) | 0
|
|
9
|
+
if (kib > Atomics.load(slots, 1)) Atomics.store(slots, 1, kib)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
postMessage(0)
|
|
13
|
+
}`,y=1e4;async function z(n=A){let e=new Int32Array(new SharedArrayBuffer(8)),s=new Worker(URL.createObjectURL(new Blob([n],{type:"application/javascript"}))),a=new Promise((r,c)=>{let o=(m)=>c(Error(`RSS sampler worker failed: ${m}`));s.onerror=(m)=>o(m.message||"uncaught error"),s.addEventListener("close",()=>o("worker exited unexpectedly"))});a.catch(()=>{});let i=new Promise((r)=>{s.onmessage=r});try{s.postMessage(e.buffer);let r=Date.now()+y;while(Atomics.load(e,0)!==t.ready){if(Date.now()>r)throw Error("RSS sampler worker failed: did not start in time");await Promise.race([Bun.sleep(1),a])}}catch(r){throw s.terminate(),r}return{async during(r){try{Atomics.store(e,0,t.go),Atomics.notify(e,0);let c=Bun.nanoseconds()+50000000;while(Atomics.load(e,0)!==t.sampling&&Bun.nanoseconds()<c);let o=Date.now()+y;while(Atomics.load(e,0)!==t.sampling){if(Date.now()>o)throw Error("RSS sampler worker failed: did not start sampling");await Promise.race([Bun.sleep(1),a])}return await r(),Atomics.store(e,0,t.stop),await Promise.race([i,a]),Atomics.load(e,1)*1024}finally{s.terminate()}}}}async function se(n,e,s){let a=s??await z();Bun.gc(!0);let i=J(),r=process.resourceUsage().maxRSS*1024,c=Bun.nanoseconds(),o=0,m=await a.during(async()=>{let p=n();if(V(p))await p;o=Bun.nanoseconds()-c}),d=process.resourceUsage().maxRSS*1024,w=Math.max(m,d>r?d:0),f=e?i.residentBytes-e.residentBytes-(i.liveBytes-e.liveBytes):0;return{peakBytes:Math.max(0,w-i.rssBytes),slackBytes:Math.max(0,f),wallNs:o}}
|
|
14
|
+
export{J,z,se};
|
package/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var t=process.argv[2];if(t===void 0||t==="--help"||t==="-h"){let{MAIN_HELP:i}=await import("./chunk-
|
|
3
|
+
var t=process.argv[2];if(t===void 0||t==="--help"||t==="-h"){let{MAIN_HELP:i}=await import("./chunk-4esjfc2m.js");await Bun.write(Bun.stdout,i),process.exit(t===void 0?2:0)}var{main:e}=await import("./chunk-468h5412.js");process.exit(await e());
|
package/index.d.ts
CHANGED
|
@@ -25,11 +25,29 @@ export interface WorkloadConfig {
|
|
|
25
25
|
ignoreExitCodes?: number[];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export interface BenchProject {
|
|
29
|
+
/** Globs against the current directory. A suite file takes the first
|
|
30
|
+
* project one of these matches; `ostia bench` with no files also runs
|
|
31
|
+
* every file they expand to. */
|
|
32
|
+
suites: string[];
|
|
33
|
+
/** Replaces the top-level `preload` for these files; `[]` runs them with
|
|
34
|
+
* none. Unset: the top-level list applies. */
|
|
35
|
+
preload?: string[];
|
|
36
|
+
/** Replaces the top-level `bunFlags` for these files, as `preload` does. */
|
|
37
|
+
bunFlags?: string[];
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
interface BenchConfig {
|
|
29
41
|
/** Suite file globs, resolved against the config's directory (e.g.
|
|
30
42
|
* "bench/**\/*.bench.ts"). Suite files given on the command line replace
|
|
31
43
|
* this list. */
|
|
32
44
|
suites?: string[];
|
|
45
|
+
/** Per-suite `preload`/`bunFlags`, so one tier (e.g. DOM-dependent suites)
|
|
46
|
+
* can pay for a setup the others don't need. The first project whose
|
|
47
|
+
* `suites` match a file wins; a file no project matches gets the top-level
|
|
48
|
+
* `preload`/`bunFlags`. `--preload` / `--bun-flags` replace the matching
|
|
49
|
+
* field for every file. */
|
|
50
|
+
projects?: BenchProject[];
|
|
33
51
|
preload?: string[];
|
|
34
52
|
/** Extra flags for the `bun` process that runs each suite file; see
|
|
35
53
|
* `BenchOptions.bunFlags`. `--bun-flags` replaces this list. */
|
|
@@ -59,6 +77,9 @@ export interface AbConfig {
|
|
|
59
77
|
/** Base trees to keep cached; see `AbOptions.keepTrees`. `--keep-trees`
|
|
60
78
|
* overrides. Default: 5. */
|
|
61
79
|
keepTrees?: number;
|
|
80
|
+
/** Judge rounds by `"time"` or `"instructions"`; see `AbOptions.metric`.
|
|
81
|
+
* `--metric` overrides. Default: `"time"`. */
|
|
82
|
+
metric?: "time" | "instructions";
|
|
62
83
|
/** Compare retained heap per call; see `AbOptions.alloc`. `--alloc` /
|
|
63
84
|
* `--no-alloc` override. `bench.alloc` doesn't apply to `ab`. */
|
|
64
85
|
alloc?: boolean;
|
|
@@ -120,6 +141,8 @@ export interface CompareResult {
|
|
|
120
141
|
baseOnly: Workload[];
|
|
121
142
|
candOnly: Workload[];
|
|
122
143
|
};
|
|
144
|
+
/** Every task on either side; see `ProfileDocument.compared`. */
|
|
145
|
+
compared: ComparedTask[];
|
|
123
146
|
summary: ComparisonSummary;
|
|
124
147
|
}
|
|
125
148
|
|
|
@@ -146,6 +169,10 @@ export interface ProfileDocument {
|
|
|
146
169
|
baseOnly: string[];
|
|
147
170
|
candOnly: string[];
|
|
148
171
|
};
|
|
172
|
+
/** Every task on either side of the comparison, one entry each: what
|
|
173
|
+
* `--format markdown` prints, flat for scripts. Present wherever
|
|
174
|
+
* `comparisons` is. */
|
|
175
|
+
compared?: ComparedTask[];
|
|
149
176
|
/** Machine conditions at measurement time; absent when the noise check was
|
|
150
177
|
* skipped. */
|
|
151
178
|
environment?: Environment;
|
|
@@ -169,6 +196,10 @@ interface NoiseFloor {
|
|
|
169
196
|
floorPct: number;
|
|
170
197
|
referenceMedianNs: number;
|
|
171
198
|
samples: number;
|
|
199
|
+
/** How much slower (positive) the reference ran at the end of the run than
|
|
200
|
+
* at the start, percent: the machine's drift over the run. Absent when the
|
|
201
|
+
* run didn't re-measure it (`profile()`, older documents). */
|
|
202
|
+
driftPct?: number;
|
|
172
203
|
}
|
|
173
204
|
|
|
174
205
|
interface Environment {
|
|
@@ -218,6 +249,10 @@ export interface Workload {
|
|
|
218
249
|
/** From `task(..., { params })` or a `sweep()` point. Part of the id, so
|
|
219
250
|
* points sharing a task name don't collide. */
|
|
220
251
|
params?: Record<string, string | number | boolean>;
|
|
252
|
+
/** Ids this task had under its former names (`task(..., { aliases })`), so
|
|
253
|
+
* `compare` and `ab` match a base measured before a rename. Never part of
|
|
254
|
+
* the id. */
|
|
255
|
+
formerIds?: string[];
|
|
221
256
|
/** From `task.skip()` / `group.skip()`: never measured, so no `Measurement`.
|
|
222
257
|
* Renderers print a "- skipped" row; `compare` treats it as `unchanged` with
|
|
223
258
|
* a `skipped` warning. */
|
|
@@ -239,6 +274,9 @@ interface Measurement {
|
|
|
239
274
|
heap?: HeapEvidence;
|
|
240
275
|
memory?: MemoryEvidence;
|
|
241
276
|
jit?: JitTierBreakdown;
|
|
277
|
+
/** In-process timing, where the machine counts them: instructions the
|
|
278
|
+
* task retired per call, one sample per trial (see `InstructionStats`). */
|
|
279
|
+
instructions?: InstructionStats;
|
|
242
280
|
/** `phase: "paired"` only; `timing` is then the candidate side. */
|
|
243
281
|
paired?: PairedEvidence;
|
|
244
282
|
/** `phase: "paired"` only: the task threw on one side or both
|
|
@@ -301,6 +339,11 @@ interface TimingStats {
|
|
|
301
339
|
batch?: number;
|
|
302
340
|
}
|
|
303
341
|
|
|
342
|
+
interface InstructionStats {
|
|
343
|
+
samples: number[];
|
|
344
|
+
median: number;
|
|
345
|
+
}
|
|
346
|
+
|
|
304
347
|
interface Frame {
|
|
305
348
|
key: string;
|
|
306
349
|
name: string;
|
|
@@ -358,6 +401,11 @@ interface MemoryEvidence {
|
|
|
358
401
|
/** `--peak-mem`: how far one call raised RSS, garbage included; median over
|
|
359
402
|
* 3 fresh processes. A `peak-hidden` warning says when it may read low. */
|
|
360
403
|
peakBytes?: number;
|
|
404
|
+
/** In-process timing: the JS heap's size as of its last collection, just
|
|
405
|
+
* before the task's warmup and just after its last trial. Read without
|
|
406
|
+
* forcing a GC, so it never perturbs the timing. */
|
|
407
|
+
heapUsedBeforeBytes?: number;
|
|
408
|
+
heapUsedAfterBytes?: number;
|
|
361
409
|
}
|
|
362
410
|
|
|
363
411
|
interface JitTierBreakdown {
|
|
@@ -390,14 +438,23 @@ interface PairedEvidence {
|
|
|
390
438
|
/** 25th/75th percentile of `ratios`. */
|
|
391
439
|
ratioP25: number;
|
|
392
440
|
ratioP75: number;
|
|
393
|
-
/**
|
|
394
|
-
*
|
|
441
|
+
/** Instructions retired per call on each side, where the machine counts
|
|
442
|
+
* them; what `AbSummary.metric: "instructions"` judges. */
|
|
443
|
+
instructions?: PairedInstructions;
|
|
444
|
+
/** `AbSummary.metric`'s median ratio past `1 ± threshold` and on the same
|
|
445
|
+
* side of 1 in at least three quarters of rounds. */
|
|
395
446
|
flagged?: "regressed" | "improved";
|
|
396
|
-
/** Each fresh-process re-measurement of a flagged workload
|
|
447
|
+
/** Each fresh-process re-measurement of a flagged workload; `flagged` by
|
|
448
|
+
* `AbSummary.metric`. */
|
|
397
449
|
repeats?: {
|
|
398
450
|
medianRatio: number;
|
|
399
451
|
ratioP25: number;
|
|
400
452
|
ratioP75: number;
|
|
453
|
+
instructions?: {
|
|
454
|
+
medianRatio: number;
|
|
455
|
+
ratioP25: number;
|
|
456
|
+
ratioP75: number;
|
|
457
|
+
};
|
|
401
458
|
flagged?: "regressed" | "improved";
|
|
402
459
|
}[];
|
|
403
460
|
/** Set when `flagged` is: whether every repeat flagged the same way. */
|
|
@@ -420,6 +477,19 @@ interface PairedEvidence {
|
|
|
420
477
|
peak?: MemoryChange;
|
|
421
478
|
}
|
|
422
479
|
|
|
480
|
+
interface PairedInstructions {
|
|
481
|
+
/** Per round, index-aligned with `PairedEvidence.baseSamples`. */
|
|
482
|
+
baseSamples: number[];
|
|
483
|
+
candSamples: number[];
|
|
484
|
+
baseMedian: number;
|
|
485
|
+
candMedian: number;
|
|
486
|
+
/** Candidate/base instructions per round. */
|
|
487
|
+
ratios: number[];
|
|
488
|
+
medianRatio: number;
|
|
489
|
+
ratioP25: number;
|
|
490
|
+
ratioP75: number;
|
|
491
|
+
}
|
|
492
|
+
|
|
423
493
|
interface MemoryChange {
|
|
424
494
|
baseBytes: number;
|
|
425
495
|
candBytes: number;
|
|
@@ -441,6 +511,9 @@ interface AbSummary {
|
|
|
441
511
|
* are all candidate-only. */
|
|
442
512
|
newSuites?: string[];
|
|
443
513
|
rounds: number;
|
|
514
|
+
/** What verdicts, confirmation and `geomeanPct` judge: each round's time
|
|
515
|
+
* ratio, or its instruction ratio (`PairedEvidence.instructions`). */
|
|
516
|
+
metric: "time" | "instructions";
|
|
444
517
|
thresholdPct: number;
|
|
445
518
|
geomeanThresholdPct: number;
|
|
446
519
|
/** Workloads measured on both sides. */
|
|
@@ -468,9 +541,9 @@ interface AbSummary {
|
|
|
468
541
|
regressed: number;
|
|
469
542
|
improved: number;
|
|
470
543
|
};
|
|
471
|
-
/** Geometric mean of the workloads' median ratios, signed
|
|
472
|
-
* candidate faster); a flagged workload contributes its
|
|
473
|
-
* run and repeats. `null` when nothing was paired. */
|
|
544
|
+
/** Geometric mean of the workloads' median `metric` ratios, signed
|
|
545
|
+
* percent (negative: candidate faster); a flagged workload contributes its
|
|
546
|
+
* median over its main run and repeats. `null` when nothing was paired. */
|
|
474
547
|
geomeanPct: number | null;
|
|
475
548
|
/** `"fail"` when any workload regressed (confirmed), threw on the
|
|
476
549
|
* candidate side only, or `geomeanPct` exceeds `geomeanThresholdPct`, or
|
|
@@ -554,10 +627,63 @@ interface ComparisonSummary {
|
|
|
554
627
|
/** `Comparison.thresholds.effectiveTimingPct`, which is the same for the
|
|
555
628
|
* whole document pair. */
|
|
556
629
|
effectiveTimingPct: number;
|
|
630
|
+
/** The machine's drift, percent, added to the timing threshold: the
|
|
631
|
+
* largest of each run's own drift (`NoiseFloor.driftPct`) and how far the
|
|
632
|
+
* reference loop's speed moved between the two runs. Absent when either
|
|
633
|
+
* document lacks a noise check. */
|
|
634
|
+
driftPct?: number;
|
|
557
635
|
/** `"fail"` when any comparison's verdict is `"fail"`. */
|
|
558
636
|
verdict: "pass" | "fail";
|
|
559
637
|
}
|
|
560
638
|
|
|
639
|
+
interface ComparedTask {
|
|
640
|
+
/** The candidate's workload id; the base's on a `missing-cand` task. */
|
|
641
|
+
workloadId: string;
|
|
642
|
+
/** Display name: the label, else the command, else the id. */
|
|
643
|
+
task: string;
|
|
644
|
+
group?: string;
|
|
645
|
+
/** Set when the base was matched through one of the task's `aliases`: the
|
|
646
|
+
* base's workload id and display name. */
|
|
647
|
+
renamedFrom?: {
|
|
648
|
+
workloadId: string;
|
|
649
|
+
task: string;
|
|
650
|
+
};
|
|
651
|
+
verdict: "improved" | "unchanged" | "regressed" | "missing-base" | "missing-cand";
|
|
652
|
+
/** The `Comparison` holding this task's frame and heap-type deltas and
|
|
653
|
+
* warnings; absent on a one-sided task. */
|
|
654
|
+
comparisonId?: string;
|
|
655
|
+
/** Whether the comparison passed the gate (timing, frames, heap types);
|
|
656
|
+
* absent on a one-sided task, which never fails it. */
|
|
657
|
+
pass?: boolean;
|
|
658
|
+
/** Absent on a one-sided or skipped task. */
|
|
659
|
+
timing?: {
|
|
660
|
+
unit: "ns";
|
|
661
|
+
baseMedian: number;
|
|
662
|
+
candMedian: number;
|
|
663
|
+
/** Absent on a document compared before ostia recorded it. */
|
|
664
|
+
baseSamples?: number;
|
|
665
|
+
candSamples: number;
|
|
666
|
+
medianDeltaPct: number;
|
|
667
|
+
/** Absent on a thin (<5 samples a side) comparison, with `pValue`. */
|
|
668
|
+
ci95?: [number, number];
|
|
669
|
+
pValue?: number;
|
|
670
|
+
/** `Comparison.thresholds.effectiveTimingPct`. */
|
|
671
|
+
thresholdPct: number;
|
|
672
|
+
};
|
|
673
|
+
/** Memory readings present on both sides; informational, never gated. */
|
|
674
|
+
memory?: MemoryDelta[];
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
interface MemoryDelta {
|
|
678
|
+
/** `heapUsedBefore`/`heapUsedAfter`: in-process heap around the timing
|
|
679
|
+
* run; `retained`: `--alloc`; `peak`: `--peak-mem`; `maxRss`: subprocess
|
|
680
|
+
* timing. */
|
|
681
|
+
reading: "heapUsedBefore" | "heapUsedAfter" | "retained" | "peak" | "maxRss";
|
|
682
|
+
baseBytes: number;
|
|
683
|
+
candBytes: number;
|
|
684
|
+
deltaPct: number;
|
|
685
|
+
}
|
|
686
|
+
|
|
561
687
|
export interface PrepareRun {
|
|
562
688
|
phase: "warmup" | "timing" | "cpu" | "heap";
|
|
563
689
|
index: number;
|
|
@@ -610,6 +736,13 @@ export interface AbOptions {
|
|
|
610
736
|
/** Rounds per workload, each one base batch and one candidate batch of
|
|
611
737
|
* about 10ms (default: 15). */
|
|
612
738
|
rounds?: number;
|
|
739
|
+
/** What to judge each round by: the candidate/base time ratio
|
|
740
|
+
* (`"time"`, the default), or the ratio of instructions each side retired
|
|
741
|
+
* per call (`"instructions"`), which a loaded machine barely moves, so a
|
|
742
|
+
* lower `thresholdPct` holds. Instructions are recorded either way where
|
|
743
|
+
* the machine counts them (see `PairedEvidence.instructions`); asking to
|
|
744
|
+
* judge by them where it can't throws an `OstiaUsageError`. */
|
|
745
|
+
metric?: "time" | "instructions";
|
|
613
746
|
/** Flag a workload whose median candidate/base ratio moves past this many
|
|
614
747
|
* percent (default: 10). */
|
|
615
748
|
thresholdPct?: number;
|
|
@@ -623,6 +756,8 @@ export interface AbOptions {
|
|
|
623
756
|
filter?: string;
|
|
624
757
|
preload?: string[];
|
|
625
758
|
bunFlags?: string[];
|
|
759
|
+
/** Per-suite `preload` / `bunFlags`; see `BenchOptions.projects`. */
|
|
760
|
+
projects?: BenchProject[];
|
|
626
761
|
outDir?: string;
|
|
627
762
|
cwd?: string;
|
|
628
763
|
noiseCheck?: boolean;
|
|
@@ -643,7 +778,7 @@ export interface AbOptions {
|
|
|
643
778
|
* `OSTIA_AB_SHA` / `OSTIA_AB_CANDIDATE_DIR` (the working tree's `cwd`) in
|
|
644
779
|
* its environment. The tree is cached per commit and command list. */
|
|
645
780
|
baseSetup?: string | string[];
|
|
646
|
-
/** Base trees to keep under
|
|
781
|
+
/** Base trees to keep under `.ostia/ab`, counting this run's: after a
|
|
647
782
|
* run, older ones go, least recently used first, unless one was used in
|
|
648
783
|
* the last hour (another run may still need it). Default: 5. */
|
|
649
784
|
keepTrees?: number;
|
|
@@ -722,6 +857,12 @@ export interface BenchOptions {
|
|
|
722
857
|
/** Extra flags for the `bun` invocation that runs each suite file (e.g.
|
|
723
858
|
* `["--conditions", "browser"]`), placed before the runner script path. */
|
|
724
859
|
bunFlags?: string[];
|
|
860
|
+
/** Per-suite `preload` / `bunFlags`: the first project whose `suites` globs
|
|
861
|
+
* match a suite file (by its path relative to `cwd`) replaces those two
|
|
862
|
+
* fields for that file, so suites that need no setup don't pay for the
|
|
863
|
+
* others'. A field a project leaves unset keeps the top-level value above;
|
|
864
|
+
* `[]` clears it. */
|
|
865
|
+
projects?: BenchProject[];
|
|
725
866
|
/** Measure this machine's noise floor once, before any suite runs
|
|
726
867
|
* (default: true), and stamp it on the document as `environment`. */
|
|
727
868
|
noiseCheck?: boolean;
|
|
@@ -753,6 +894,10 @@ export interface TaskOptions {
|
|
|
753
894
|
/** Per-task hard floor on trials; overrides the suite-wide `--min-samples` /
|
|
754
895
|
* `minSamples`. */
|
|
755
896
|
minSamples?: number;
|
|
897
|
+
/** Former names of this task in the same group, so `compare` and `ab`
|
|
898
|
+
* match a base measured before a rename instead of reporting the old name
|
|
899
|
+
* as removed and the new one as new. */
|
|
900
|
+
aliases?: string[];
|
|
756
901
|
/** What this task measures and why. Flows into `Workload.description` so the
|
|
757
902
|
* intent travels with the numbers instead of living only in a source comment. */
|
|
758
903
|
description?: string;
|
|
@@ -984,6 +1129,8 @@ interface MinimalWarning {
|
|
|
984
1129
|
}
|
|
985
1130
|
|
|
986
1131
|
interface MinimalDelta {
|
|
1132
|
+
/** The base's median, ns: the row's own `median` is the candidate's. */
|
|
1133
|
+
baseMedian?: number;
|
|
987
1134
|
medianPct: number;
|
|
988
1135
|
meanPct: number;
|
|
989
1136
|
verdict: "improved" | "regressed" | "unchanged";
|
|
@@ -995,6 +1142,8 @@ interface MinimalDelta {
|
|
|
995
1142
|
/** The threshold actually tested against, after machine noise widened it. */
|
|
996
1143
|
effectiveTimingPct: number;
|
|
997
1144
|
matched: true;
|
|
1145
|
+
/** The base task's name, when it was matched through an alias. */
|
|
1146
|
+
renamedFrom?: string;
|
|
998
1147
|
}
|
|
999
1148
|
|
|
1000
1149
|
interface MinimalPaired {
|
|
@@ -1009,8 +1158,16 @@ interface MinimalPaired {
|
|
|
1009
1158
|
/** What the first process saw, before confirmation. */
|
|
1010
1159
|
flagged?: "regressed" | "improved";
|
|
1011
1160
|
confirmed?: boolean;
|
|
1012
|
-
/** Median ratio of each fresh-process repeat
|
|
1161
|
+
/** Median ratio of each fresh-process repeat, by the summary's `metric`. */
|
|
1013
1162
|
repeats?: number[];
|
|
1163
|
+
/** Where the machine counts them: the base's median instructions per call
|
|
1164
|
+
* and the candidate/base instruction ratios. */
|
|
1165
|
+
instructions?: {
|
|
1166
|
+
baseMedian: number;
|
|
1167
|
+
medianRatio: number;
|
|
1168
|
+
ratioP25: number;
|
|
1169
|
+
ratioP75: number;
|
|
1170
|
+
};
|
|
1014
1171
|
sameOutput: boolean;
|
|
1015
1172
|
/** The suite file differs from the base's copy. */
|
|
1016
1173
|
suiteChanged?: true;
|
|
@@ -1064,6 +1221,9 @@ interface MinimalRunLine {
|
|
|
1064
1221
|
retainedBytesPerOp?: number;
|
|
1065
1222
|
/** `--peak-mem`: how far the task's first call raised RSS, bytes. */
|
|
1066
1223
|
peakBytes?: number;
|
|
1224
|
+
/** In-process tasks, where the machine counts them: median instructions
|
|
1225
|
+
* retired per call (`ab`: the candidate's). */
|
|
1226
|
+
instructions?: number;
|
|
1067
1227
|
/** Median over the group's reference median (its baseline task, else its
|
|
1068
1228
|
* fastest); only when the document has more than one timing run. */
|
|
1069
1229
|
relative?: number;
|
|
@@ -1110,6 +1270,8 @@ interface MinimalSummaryLine {
|
|
|
1110
1270
|
missingBaseline?: number;
|
|
1111
1271
|
geomeanPct: number | null;
|
|
1112
1272
|
effectiveTimingPct: number;
|
|
1273
|
+
/** `compare`/`ci`: the machine's drift, added to the timing threshold. */
|
|
1274
|
+
driftPct?: number;
|
|
1113
1275
|
noiseFloorPct?: number;
|
|
1114
1276
|
/** `ci` only. */
|
|
1115
1277
|
baseline?: {
|
|
@@ -1121,6 +1283,9 @@ interface MinimalSummaryLine {
|
|
|
1121
1283
|
ref: string;
|
|
1122
1284
|
sha: string;
|
|
1123
1285
|
};
|
|
1286
|
+
/** `ab` only: what the verdicts and `geomeanPct` judge, each round's time
|
|
1287
|
+
* or instruction ratio. */
|
|
1288
|
+
metric?: "time" | "instructions";
|
|
1124
1289
|
/** `ab` only: the gate on `geomeanPct`. */
|
|
1125
1290
|
geomeanThresholdPct?: number;
|
|
1126
1291
|
/** `ab` only: flagged in the first process but not reproduced; counted in `unchanged`. */
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{M,we,L,K,q,ke,Z,Pe,Pn,R,b,xn,Mn,Rn,Tn}from"./chunk-05jfst35.js";import"./chunk-23g2rwrn.js";import{s,p,N,a,Sn,vn,Cn}from"./chunk-1g1x9zz2.js";export{L as AbBaseError,q as AbSetupError,K as AbSuiteError,M as DEFAULT_THRESHOLDS,R as MINIMAL_PROTOCOL_VERSION,N as OstiaDocumentError,ke as ab,Z as bench,we as compareDocuments,s as createDocument,Tn as defineConfig,Sn as group,Cn as keep,a as loadDocument,Rn as profile,Pn as range,b as renderers,xn as run,p as saveDocument,Mn as sweep,vn as task,Pe as time};
|
package/package.json
CHANGED
package/runner.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{
|
|
4
|
-
`),2;let t=i?JSON.parse(i):{},
|
|
5
|
-
`),2;let a;try{a=
|
|
6
|
-
`),2}let n=(e)=>
|
|
7
|
-
`),2;await
|
|
3
|
+
import{p,pe,B,fe,on,ge,h,U,W,be}from"./chunk-1g1x9zz2.js";import{J,z,se}from"./chunk-ct2xsezd.js";async function c(){let[r,o,i]=process.argv.slice(2);if(!r||!o)return process.stderr.write(`bench runner: usage: runner.ts <suiteFile> <outputPath> [optsJson]
|
|
4
|
+
`),2;let t=i?JSON.parse(i):{},l,d;if(t.peakMemFor)d=await z(),await import("./index.js"),l=J();for(let e of t.preload??[])await import(e);fe(),await import(r);let u=B();if(u.length===0)return process.stderr.write(`bench runner: ${r} registered no tasks (no task() calls found).${pe}
|
|
5
|
+
`),2;let a;try{a=U(u,t.filter,r,!t.workloadIds&&!t.peakMemFor)}catch(e){return process.stderr.write(`bench runner: ${e.message}
|
|
6
|
+
`),2}let n=(e)=>W(r,e).id;if(t.workloadIds){let e=new Set(t.workloadIds);a=a.filter((s)=>e.has(n(s)))}if(t.peakMemFor){let e=a.find((f)=>n(f)===t.peakMemFor);if(!e)return process.stderr.write(`bench runner: no task with workload id ${t.peakMemFor} in ${r}.
|
|
7
|
+
`),2;await h(e,"before"),await e.opts?.before?.();let s=await se(e.fn,l,d);return await e.opts?.after?.(),await h(e,"after"),await Bun.write(o,JSON.stringify(s)),0}if(t.planPath){let e=a.map((s)=>({workloadId:n(s),isolate:on(s,t.isolate??!1),peakMem:!s.skipped&&ge(s,t.peakMem??!1)}));await Bun.write(t.planPath,JSON.stringify({tasks:e}))}let k=t.workloadIds?a:a.filter((e)=>!on(e,t.isolate??!1)),m=await be(r,k,t);return await p(m,o),0}c().then((r)=>process.exit(r));
|
package/chunk-9cr8k2g1.js
DELETED