ostia 0.4.0 → 0.6.0
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 +31 -30
- package/docs/agent-protocol.md +13 -9
- package/docs/cli.md +174 -126
- package/docs/config.md +2 -2
- package/docs/document-schema.md +15 -12
- package/docs/library.md +32 -21
- package/docs/preload-recipes.md +4 -4
- package/docs/statistics.md +14 -13
- package/index.d.ts +202 -60
- package/package.json +1 -1
- package/src/ab/ab-runner.ts +6 -6
- package/src/ab/index.ts +56 -6
- package/src/ab/unpaired.ts +54 -0
- package/src/bench/index.ts +40 -3
- package/src/bench/registry.ts +6 -4
- package/src/bench/run-tasks.ts +16 -2
- package/src/bench/runner.ts +10 -3
- package/src/bench/support.ts +8 -4
- package/src/bench/sweep.ts +2 -2
- package/src/cache/fingerprint.ts +2 -2
- package/src/capture/bunflags.ts +2 -2
- package/src/capture/cpu.ts +2 -2
- package/src/capture/heap-parse.ts +2 -2
- package/src/ci/index.ts +39 -48
- package/src/cli/agent.ts +54 -0
- package/src/cli/flags.ts +58 -9
- package/src/cli/help.ts +670 -245
- package/src/cli/main.ts +2 -3
- package/src/cli/output.ts +17 -14
- package/src/cli/run.ts +317 -92
- package/src/compare/index.ts +4 -4
- package/src/config/index.ts +14 -10
- package/src/config/validate.ts +4 -4
- package/src/glob.ts +2 -2
- package/src/index.ts +3 -2
- package/src/ir/document.ts +2 -2
- package/src/ir/types.ts +49 -24
- package/src/measure/alloc.ts +2 -2
- package/src/measure/cpu.ts +2 -2
- package/src/measure/environment.ts +11 -6
- package/src/measure/inprocess.ts +14 -10
- package/src/measure/instructions.ts +2 -2
- package/src/measure/noise.ts +51 -13
- package/src/measure/paired.ts +2 -2
- package/src/measure/peak.ts +4 -4
- package/src/measure/timing.ts +27 -6
- package/src/profile.ts +6 -4
- package/src/renderers/collapsed.ts +2 -2
- package/src/renderers/concise.ts +148 -0
- package/src/renderers/format.ts +13 -4
- package/src/renderers/human.ts +402 -0
- package/src/renderers/index.ts +9 -2
- package/src/renderers/markdown.ts +2 -2
- package/src/renderers/mermaid.ts +2 -2
- package/src/renderers/minimal.ts +8 -7
- package/src/renderers/relative.ts +2 -2
- package/src/renderers/select.ts +2 -2
- package/src/renderers/terminal.ts +1178 -383
- package/src/renderers/types.ts +3 -0
- package/src/spawn/index.ts +47 -14
- package/src/stats/bootstrap.ts +2 -2
- package/src/stats/index.ts +2 -2
- package/src/terminal.ts +321 -0
- package/src/time.ts +124 -20
package/docs/document-schema.md
CHANGED
|
@@ -30,13 +30,13 @@ This did not bump `schemaVersion`: `loadDocument` reads the old names as
|
|
|
30
30
|
the new ones.
|
|
31
31
|
|
|
32
32
|
`ab` documents written before ostia 0.2.12 lack `ab.metric`;
|
|
33
|
-
`loadDocument` sets it to `"time"`, the only metric they could
|
|
34
|
-
used.
|
|
33
|
+
`loadDocument` sets it to `"time"`, the only metric they could
|
|
34
|
+
have used.
|
|
35
35
|
|
|
36
36
|
`OstiaDocumentError.code` is `"invalid-json"`,
|
|
37
|
-
`"not-a-document"`
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
`"not-a-document"` (no numeric `schemaVersion`, or
|
|
38
|
+
`workloads`/`measurements` that aren't arrays of well-formed objects)
|
|
39
|
+
or `"unsupported-schema"`.
|
|
40
40
|
|
|
41
41
|
## Top level
|
|
42
42
|
|
|
@@ -48,7 +48,8 @@ arrays of well-formed objects) or `"unsupported-schema"`.
|
|
|
48
48
|
| `createdAt` | ISO timestamp. Metadata only. |
|
|
49
49
|
| `workloads` | `Workload[]`: what was measured. |
|
|
50
50
|
| `measurements` | `Measurement[]`: one per workload and phase. |
|
|
51
|
-
| `
|
|
51
|
+
| `shell?` | `{ command, startupNs }`: the shell `--shell` ran each command through, and its startup (`SH -c :`, median wall time), which the timings include. Absent without a shell. |
|
|
52
|
+
| `environment?` | `{ cpuModel, cores, loadAvg1, loadAvg5, noise: { floorPct, referenceMedianNs, samples, checkMs?, budgetMs?, driftPct? } }`. Absent when the noise check was skipped. `checkMs`: how long the start check sampled. `budgetMs`: the fixed budget `--noise-budget` asked for, absent for the default adaptive check. `driftPct`: how much slower the reference loop ran at the end of the run than at the start. |
|
|
52
53
|
| `git?` | `{ sha, branch, dirty }` from the process's cwd. Absent outside a repo. Never part of an id or cache key. |
|
|
53
54
|
| `comparisons?` | `Comparison[]`, on a candidate document written by `compare`/`ci`. |
|
|
54
55
|
| `comparisonSummary?` | `{ matched, regressed, improved, unchanged, geomeanPct, effectiveTimingPct, driftPct?, verdict }`. `driftPct` is the machine drift added to the timing threshold ([statistics.md](statistics.md#threshold-widening)). |
|
|
@@ -120,8 +121,9 @@ identity; it is shown as the label too.)
|
|
|
120
121
|
| `artifacts` | `{ kind, path, sha256, bytes }[]`: raw `.cpuprofile`/`.heapsnapshot` files. |
|
|
121
122
|
|
|
122
123
|
`Trial`:
|
|
123
|
-
`{ i, wallNs, exitCode?, userNs?, systemNs?, maxRssBytes?, reportedNs?, timedOut?, timeSourceNoMatch? }`.
|
|
124
|
+
`{ i, wallNs, exitCode?, userNs?, systemNs?, maxRssBytes?, reportedNs?, timedOut?, timeSourceNoMatch?, outputPath? }`.
|
|
124
125
|
`reportedNs` is the value parsed by a `timeSource`;
|
|
126
|
+
`outputPath`, the file `--save-output` wrote the trial's output to;
|
|
125
127
|
timed-out and unmatched trials contribute no sample.
|
|
126
128
|
|
|
127
129
|
`TimingStats`:
|
|
@@ -134,7 +136,8 @@ and `batch` is the number of calls per trial.
|
|
|
134
136
|
`baseSamples[i]` and `timing.samples[i]` are the two sides' per-call
|
|
135
137
|
times in round `i`, and `ratios[i]` is candidate over base.
|
|
136
138
|
`instructions`, where the machine counts them,
|
|
137
|
-
holds the same rounds' instructions per
|
|
139
|
+
holds the same rounds' instructions per
|
|
140
|
+
call:
|
|
138
141
|
`{ baseSamples, candSamples, baseMedian, candMedian, ratios, medianRatio, ratioP25, ratioP75 }`.
|
|
139
142
|
`flagged` is what the first process saw, by `ab.metric`'s ratios;
|
|
140
143
|
`repeats` are the fresh-process re-measurements of a flagged task
|
|
@@ -143,9 +146,8 @@ and `verdict` is `flagged` only when `confirmed`.
|
|
|
143
146
|
`suiteChanged` is `true` when the suite file differs from the base's
|
|
144
147
|
copy; with `sameOutput: false` too, `verdict` is `unchanged`.
|
|
145
148
|
`retained` (`--alloc`) and `peak` (`--peak-mem`) are `MemoryChange`s:
|
|
146
|
-
`{ baseBytes, candBytes, verdict, floorBytes }`,
|
|
147
|
-
|
|
148
|
-
and `floorBytes`.
|
|
149
|
+
`{ baseBytes, candBytes, verdict, floorBytes }`, where `verdict` counts
|
|
150
|
+
only a change past both the memory threshold and `floorBytes`.
|
|
149
151
|
See [cli.md](cli.md#ostia-ab).
|
|
150
152
|
|
|
151
153
|
## Comparisons
|
|
@@ -187,7 +189,7 @@ the base median derived from the change.
|
|
|
187
189
|
|
|
188
190
|
`Warning` is `{ code, message, data? }`.
|
|
189
191
|
The terminal table prints codes under each row and messages below the
|
|
190
|
-
table; `--format
|
|
192
|
+
table; `--format events` includes `code` and `data`.
|
|
191
193
|
|
|
192
194
|
| Code | Where | When |
|
|
193
195
|
|---|---|---|
|
|
@@ -207,6 +209,7 @@ table; `--format minimal` includes `code` and `data`.
|
|
|
207
209
|
| `skipped` | comparison | The candidate task was skipped; treated as unchanged. |
|
|
208
210
|
| `environment-mismatch` | comparison | The documents came from different platforms, Bun versions, or CPUs. |
|
|
209
211
|
| `suite-changed` | `ab` | The suite file's text differs from the base ref's copy, so each side may run a different benchmark. When the output differs too, the task is not comparable: verdict `unchanged`, left out of the geomean. |
|
|
212
|
+
| `repeats-disagree` | `ab` | A flagged task's fresh-process repeats sit 1.5× or more from its paired run, outside the paired rounds' middle half. Another task in the same process can shape how the JIT compiles a function they share; `--filter` measures the task alone. `data`: `factor`, `pairedRatio`, `repeatRatios`. The verdict is unchanged. |
|
|
210
213
|
| `peak-hidden` | `--peak-mem` | Earlier work in the process (module-scope setup, `before` hooks) freed 16 MiB or more that the allocator still held, which the call could reuse without RSS rising, so `peakBytes` can be that much low. `data: { slackBytes, processes }`. |
|
|
211
214
|
|
|
212
215
|
## Files on disk
|
package/docs/library.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Library API
|
|
2
2
|
|
|
3
3
|
The CLI is a thin wrapper over these functions;
|
|
4
|
-
both produce the same
|
|
5
|
-
([document-schema.md](document-schema.md)).
|
|
4
|
+
both produce the same
|
|
5
|
+
`ProfileDocument` ([document-schema.md](document-schema.md)).
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import {
|
|
@@ -14,16 +14,17 @@ import {
|
|
|
14
14
|
import type {
|
|
15
15
|
ProfileDocument, Workload, Comparison, Warning, WarningCode, CompareResult, Thresholds,
|
|
16
16
|
TaskOptions, GroupOptions, RunOptions, OstiaConfig, OstiaConfigInput, WorkloadConfig,
|
|
17
|
-
TimeOptions, CommandSpec, PrepareHook, PrepareFn, PrepareRun, TimeSource, TimeUnit,
|
|
18
|
-
BenchOptions, AbOptions, ProfileOptions, ProfileResult,
|
|
17
|
+
TimeOptions, TimeProgress, CommandSpec, PrepareHook, PrepareFn, PrepareRun, TimeSource, TimeUnit,
|
|
18
|
+
BenchOptions, BenchProgress, AbOptions, ProfileOptions, ProfileResult,
|
|
19
19
|
MinimalEvent, MinimalRenderOptions, MinimalProtocolContext, MermaidOptions, VizOptions,
|
|
20
|
+
TableOptions,
|
|
20
21
|
} from "ostia"
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
## `time(opts)` → `Promise<ProfileDocument>`
|
|
24
25
|
|
|
25
|
-
Subprocess timing; the same behavior as
|
|
26
|
-
([cli.md](cli.md#ostia-time)).
|
|
26
|
+
Subprocess timing; the same behavior as
|
|
27
|
+
`ostia time` ([cli.md](cli.md#ostia-time)).
|
|
27
28
|
|
|
28
29
|
```ts
|
|
29
30
|
const controller = new AbortController()
|
|
@@ -44,6 +45,7 @@ const doc = await time({
|
|
|
44
45
|
timeoutMs: 30_000, // no default
|
|
45
46
|
ignoreExitCodes: [1],
|
|
46
47
|
signal: controller.signal,
|
|
48
|
+
onProgress: (p) => console.error(p), // { command, commands, label, runs, doneRatio }
|
|
47
49
|
})
|
|
48
50
|
```
|
|
49
51
|
|
|
@@ -73,11 +75,11 @@ A `RegExp` `timeSource` pattern must not have the `g`, `y` or `d` flag;
|
|
|
73
75
|
`time()` rejects with a `RangeError` before running anything.
|
|
74
76
|
|
|
75
77
|
A command stops at its first non-ignored non-zero exit.
|
|
76
|
-
`time()` still resolves; check `Trial.exitCode`
|
|
77
|
-
warning.
|
|
78
|
+
`time()` still resolves; check `Trial.exitCode`
|
|
79
|
+
or the `nonzero-exit` warning.
|
|
78
80
|
Aborting `signal` kills in-flight children and resolves with the
|
|
79
|
-
measurements completed so far, the last one carrying an
|
|
80
|
-
warning.
|
|
81
|
+
measurements completed so far, the last one carrying an
|
|
82
|
+
`aborted` warning.
|
|
81
83
|
|
|
82
84
|
## `profile(fn, opts?)` → `Promise<{ result, measurement, document }>`
|
|
83
85
|
|
|
@@ -157,6 +159,8 @@ Each call keeps its scratch files in a directory of its own under
|
|
|
157
159
|
`outDir`, so concurrent calls can share one.
|
|
158
160
|
It also takes a `signal`: aborting kills in-flight suite processes
|
|
159
161
|
and resolves with the suites and tasks that had finished.
|
|
162
|
+
`onProgress` is called before each task is measured,
|
|
163
|
+
with `{ suite, suites, file, task, tasks, label }`.
|
|
160
164
|
|
|
161
165
|
### `TaskOptions`
|
|
162
166
|
|
|
@@ -164,8 +168,8 @@ and resolves with the suites and tasks that had finished.
|
|
|
164
168
|
|---|---|
|
|
165
169
|
| `budgetMs`, `samples`, `minSamples` | Override the suite-wide sampling settings for this task. |
|
|
166
170
|
| `isolate`, `gc`, `cpu`, `alloc`, `peakMem` | Override the suite-wide flag (and the group's) for this task. |
|
|
167
|
-
| `baseline` | This task is the group's
|
|
168
|
-
| `description` | Stored as `Workload.description` and shown in `
|
|
171
|
+
| `baseline` | This task is the group's reference for the table's `vs baseline` column (default: the group's fastest). |
|
|
172
|
+
| `description` | Stored as `Workload.description` and shown in `events` output. |
|
|
169
173
|
| `aliases` | Former names of the task in the same group. `compare`, `ci` and `ab` match a base measured under any of them, so a rename still compares. |
|
|
170
174
|
| `params` | Structured parameters; part of the workload id. Merged over the current `sweep()` point. |
|
|
171
175
|
| `before`, `after` | Run once, unmeasured, before the task's warmup and after its last trial, in the task's own process (works with `isolate`). |
|
|
@@ -247,8 +251,8 @@ task("parse then validate", () => {
|
|
|
247
251
|
|
|
248
252
|
`sweep()` calls `fn` once per point of the Cartesian product of `dims`;
|
|
249
253
|
`task()` calls inside inherit the point as `params`,
|
|
250
|
-
so each point is its own workload and `compare` matches points
|
|
251
|
-
runs.
|
|
254
|
+
so each point is its own workload and `compare` matches points
|
|
255
|
+
across runs.
|
|
252
256
|
|
|
253
257
|
```ts
|
|
254
258
|
group("parse", () => {
|
|
@@ -376,20 +380,27 @@ const doc = createDocument(
|
|
|
376
380
|
|
|
377
381
|
Each renderer is `{ name, render(doc, options) }` returning `{ text? }`
|
|
378
382
|
and/or `{ files? }`.
|
|
379
|
-
Names: `table`, `markdown`, `json`, `jsonl`,
|
|
383
|
+
Names: `table`, `markdown`, `json`, `jsonl`,
|
|
384
|
+
`events` (and `minimal`, its name until 0.5.0), `concise`, `collapsed`,
|
|
380
385
|
`mermaid`, `speedscope`, `cpuprofile`.
|
|
381
386
|
Each renderer's options are typed per format:
|
|
382
387
|
`collapsed`, `speedscope` and `cpuprofile` take `VizOptions`
|
|
383
388
|
(`{ measurementId? }`), `mermaid` takes `MermaidOptions`
|
|
384
|
-
(`VizOptions` plus `topN?`), `
|
|
389
|
+
(`VizOptions` plus `topN?`), `events`
|
|
390
|
+
and `minimal` take `MinimalRenderOptions`
|
|
385
391
|
(`{ protocol? }`, a `MinimalProtocolContext`, to emit the `unmatched`
|
|
386
|
-
and `summary` events),
|
|
392
|
+
and `summary` events), `table` takes `TableOptions`
|
|
393
|
+
(`{ paint?, ran?, elapsedMs?, compare?, ci? }`: color, the context line
|
|
394
|
+
and the closing line, all optional, plain when absent),
|
|
395
|
+
and the rest take no options (pass `{}`).
|
|
387
396
|
|
|
388
397
|
The `table` and `markdown` renderers agree on grouping
|
|
389
398
|
(a task's `group`, else the part of its id before the last `/`),
|
|
390
399
|
on percent deltas
|
|
391
|
-
(`+3.2%`, `-1.5%`, and `0.0%` with no sign when a delta rounds to zero
|
|
392
|
-
|
|
400
|
+
(`+3.2%`, `-1.5%`, and `0.0%` with no sign when a delta rounds to zero;
|
|
401
|
+
the table prints one past +900% as a multiple),
|
|
402
|
+
on byte counts
|
|
403
|
+
(1024-based `B`/`KiB`/`MiB`; the table puts a space before the unit),
|
|
393
404
|
and on naming a comparison or capture whose workload is missing from the
|
|
394
405
|
document by its raw id.
|
|
395
406
|
|
|
@@ -400,8 +411,8 @@ const { files } = await renderers.speedscope.render(doc, { measurementId })
|
|
|
400
411
|
|
|
401
412
|
## `defineConfig(config)`
|
|
402
413
|
|
|
403
|
-
Returns its argument unchanged; it exists to
|
|
404
|
-
`ostia.config.ts`.
|
|
414
|
+
Returns its argument unchanged; it exists to
|
|
415
|
+
type-check `ostia.config.ts`.
|
|
405
416
|
See [config.md](config.md).
|
|
406
417
|
|
|
407
418
|
## Coming from mitata or hyperfine
|
package/docs/preload-recipes.md
CHANGED
|
@@ -15,8 +15,8 @@ dependencies - install whichever one your suite needs.
|
|
|
15
15
|
|
|
16
16
|
## jsdom
|
|
17
17
|
|
|
18
|
-
The naive version of this script
|
|
19
|
-
`Object.assign(globalThis, { document, window })`
|
|
18
|
+
The naive version of this script
|
|
19
|
+
does `Object.assign(globalThis, { document, window })`
|
|
20
20
|
- see the tiny example in [cli.md](cli.md#--preload-and---bun-flags).
|
|
21
21
|
That's enough for suites that only ever touch `document`,
|
|
22
22
|
but it breaks the moment a suite does an `instanceof` check
|
|
@@ -69,8 +69,8 @@ Same global-copy pattern, different source object - `happy-dom`'s
|
|
|
69
69
|
`Window` class instead of `JSDOM`'s `.window`.
|
|
70
70
|
happy-dom trades some spec coverage
|
|
71
71
|
(fewer of the more obscure DOM APIs are implemented) for a noticeably
|
|
72
|
-
faster startup, which matters when `--preload` runs once per
|
|
73
|
-
subprocess.
|
|
72
|
+
faster startup, which matters when `--preload` runs once per
|
|
73
|
+
suite-file subprocess.
|
|
74
74
|
Reach for this first if your suite's DOM surface is simple
|
|
75
75
|
(rendering components, reading text content) and only fall back to jsdom
|
|
76
76
|
if something you need isn't implemented.
|
package/docs/statistics.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Statistics
|
|
2
2
|
|
|
3
|
-
How ostia samples, summarizes, and decides whether a change is
|
|
4
|
-
regression.
|
|
3
|
+
How ostia samples, summarizes, and decides whether a change is
|
|
4
|
+
a regression.
|
|
5
5
|
|
|
6
6
|
## Summary statistics
|
|
7
7
|
|
|
@@ -11,9 +11,10 @@ Every timing measurement stores its raw samples plus `mean`, `median`,
|
|
|
11
11
|
(mild: beyond 1.5×IQR from the quartiles; severe: beyond 3×IQR).
|
|
12
12
|
Percentiles interpolate linearly between order statistics.
|
|
13
13
|
|
|
14
|
-
Reports lead with the median
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Reports lead with the median, since wall-clock timings have a long right
|
|
15
|
+
tail that skews the mean and standard deviation.
|
|
16
|
+
The table shows noise as ± the MAD, a percent of the median;
|
|
17
|
+
markdown shows Spread as p75…p99.
|
|
17
18
|
|
|
18
19
|
## Sampling
|
|
19
20
|
|
|
@@ -58,8 +59,8 @@ For the most comparable numbers, run tasks with `isolate`.
|
|
|
58
59
|
|
|
59
60
|
Before measuring, `time()`, `bench()` and `ostia ci` each run a fixed,
|
|
60
61
|
allocation-free hash loop for about 200ms, once per call,
|
|
61
|
-
and record `mad / median` of its trial times
|
|
62
|
-
`environment.noise.floorPct`.
|
|
62
|
+
and record `mad / median` of its trial times
|
|
63
|
+
as `environment.noise.floorPct`.
|
|
63
64
|
This is how much this machine's timings vary at the moment,
|
|
64
65
|
independent of the workload.
|
|
65
66
|
`noiseCheck: false` / `--no-noise-check` skips it
|
|
@@ -89,8 +90,8 @@ each side, runs two tests on the raw samples:
|
|
|
89
90
|
first, which bounds the cost.
|
|
90
91
|
- **Mann-Whitney U test**, two-sided, tie-corrected,
|
|
91
92
|
normal approximation, reported as `pValue`.
|
|
92
|
-
It tests whether the two distributions differ without
|
|
93
|
-
normality.
|
|
93
|
+
It tests whether the two distributions differ without
|
|
94
|
+
assuming normality.
|
|
94
95
|
|
|
95
96
|
The bootstrap PRNG is seeded from a hash of the two sample arrays,
|
|
96
97
|
so the same two documents always produce the same interval and verdict.
|
|
@@ -108,8 +109,8 @@ Let `T = effectiveTimingPct` (below).
|
|
|
108
109
|
A large point estimate is not enough.
|
|
109
110
|
For example, `+21.4% median, 95% CI [+5.6%, +23.9%], p=0.023` against
|
|
110
111
|
`T = 10` and `alpha = 0.01` is `unchanged`:
|
|
111
|
-
the interval reaches below the threshold
|
|
112
|
-
`alpha`.
|
|
112
|
+
the interval reaches below the threshold
|
|
113
|
+
and the p-value is above `alpha`.
|
|
113
114
|
|
|
114
115
|
With fewer than 5 samples on either side,
|
|
115
116
|
the tests are skipped and the verdict uses the median change alone
|
|
@@ -214,5 +215,5 @@ which is why the quartile rule and confirmation stay.
|
|
|
214
215
|
When base and candidate differ in OS, architecture, Bun version,
|
|
215
216
|
or (when both have it) CPU model or core count,
|
|
216
217
|
every comparison carries an `environment-mismatch` warning with the
|
|
217
|
-
differing fields: the delta may reflect the machine rather than
|
|
218
|
-
code.
|
|
218
|
+
differing fields: the delta may reflect the machine rather than
|
|
219
|
+
the code.
|