ostia 0.2.12 → 0.3.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/LICENSE +21 -0
- package/README.md +50 -358
- package/docs/agent-protocol.md +210 -0
- package/docs/cli.md +1196 -0
- package/docs/config.md +233 -0
- package/docs/document-schema.md +224 -0
- package/docs/library.md +421 -0
- package/docs/preload-recipes.md +169 -0
- package/docs/statistics.md +218 -0
- package/index.d.ts +894 -677
- package/package.json +16 -14
- package/src/ab/ab-runner.ts +474 -0
- package/src/ab/index.ts +1086 -0
- package/src/baseline/index.ts +75 -0
- package/src/bench/index.ts +462 -0
- package/src/bench/projects.ts +39 -0
- package/src/bench/range.ts +27 -0
- package/src/bench/registry.ts +424 -0
- package/src/bench/run-tasks.ts +176 -0
- package/src/bench/run.ts +51 -0
- package/src/bench/runner.ts +147 -0
- package/src/bench/support.ts +161 -0
- package/src/bench/sweep.ts +39 -0
- package/src/cache/fingerprint.ts +59 -0
- package/src/cache/store.ts +28 -0
- package/src/capture/bunflags.ts +91 -0
- package/src/capture/cpu-parse.ts +119 -0
- package/src/capture/cpu.ts +44 -0
- package/src/capture/frames.ts +54 -0
- package/src/capture/heap-parse.ts +86 -0
- package/src/capture/heap.ts +32 -0
- package/src/capture/inspector.ts +46 -0
- package/src/capture/jsc-parse.ts +167 -0
- package/src/capture/jsc.ts +35 -0
- package/src/capture/sampling.ts +5 -0
- package/src/ci/index.ts +416 -0
- package/src/cli/flags.ts +264 -0
- package/{chunk-9sx15b08.js → src/cli/help.ts} +23 -11
- package/src/cli/main.ts +18 -0
- package/src/cli/output.ts +185 -0
- package/src/cli/run.ts +1110 -0
- package/src/compare/index.ts +617 -0
- package/src/config/index.ts +275 -0
- package/src/config/validate.ts +267 -0
- package/src/errors.ts +8 -0
- package/src/format.ts +36 -0
- package/src/glob.ts +48 -0
- package/src/index.ts +62 -0
- package/src/ir/cpu.ts +10 -0
- package/src/ir/document.ts +471 -0
- package/src/ir/fp.ts +31 -0
- package/src/ir/git.ts +36 -0
- package/src/ir/types.ts +615 -0
- package/src/measure/alloc.ts +57 -0
- package/src/measure/cpu.ts +99 -0
- package/src/measure/environment.ts +41 -0
- package/src/measure/inprocess.ts +191 -0
- package/src/measure/instructions.ts +133 -0
- package/src/measure/loop.ts +57 -0
- package/src/measure/noise.ts +55 -0
- package/src/measure/paired.ts +312 -0
- package/src/measure/peak.ts +202 -0
- package/src/measure/timing.ts +263 -0
- package/src/profile.ts +109 -0
- package/src/renderers/collapsed.ts +35 -0
- package/src/renderers/cpu-tree.ts +183 -0
- package/src/renderers/cpuprofile.ts +43 -0
- package/src/renderers/format.ts +142 -0
- package/src/renderers/index.ts +27 -0
- package/src/renderers/json.ts +10 -0
- package/src/renderers/jsonl.ts +15 -0
- package/src/renderers/markdown.ts +525 -0
- package/src/renderers/mermaid.ts +78 -0
- package/src/renderers/minimal.ts +602 -0
- package/src/renderers/paired.ts +229 -0
- package/src/renderers/relative.ts +64 -0
- package/src/renderers/select.ts +286 -0
- package/src/renderers/speedscope.ts +69 -0
- package/src/renderers/terminal.ts +466 -0
- package/src/renderers/types.ts +27 -0
- package/src/spawn/index.ts +396 -0
- package/src/stats/bootstrap.ts +153 -0
- package/src/stats/index.ts +140 -0
- package/src/stats/mannwhitney.ts +81 -0
- package/src/time.ts +325 -0
- package/src/version.ts +3 -0
- package/ab-runner.ts +0 -8
- package/chunk-05jfst35.js +0 -28
- package/chunk-1g1x9zz2.js +0 -15
- package/chunk-23g2rwrn.js +0 -3
- package/chunk-468h5412.js +0 -25
- package/chunk-4esjfc2m.js +0 -2
- package/chunk-ct2xsezd.js +0 -14
- package/cli.js +0 -3
- package/index.js +0 -2
- package/runner.ts +0 -7
package/docs/config.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
`ostia ci`, `ostia baseline` and `ostia compare` read a config file from
|
|
4
|
+
the current directory; `ostia bench` reads its `bench` section
|
|
5
|
+
when present.
|
|
6
|
+
Discovery checks `ostia.config.ts` first
|
|
7
|
+
(a default export, wrapped in `defineConfig` for type checking),
|
|
8
|
+
then `ostia.config.json`.
|
|
9
|
+
Both support the same fields, except that functions
|
|
10
|
+
and `RegExp` values only work in `.ts`.
|
|
11
|
+
`--config PATH` (on `bench`, `ab`, `compare`, `ci` and `baseline`) loads
|
|
12
|
+
a specific file instead; paths inside it
|
|
13
|
+
(`baselineDir`, `suites`, `inputs` and the rest) still resolve against
|
|
14
|
+
the current directory, not the file's.
|
|
15
|
+
|
|
16
|
+
If both `ostia.config.ts` and `ostia.config.json` exist,
|
|
17
|
+
the `.ts` file is used and the JSON one ignored,
|
|
18
|
+
with a warning on stderr.
|
|
19
|
+
A `.ts` config must have a default export.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// ostia.config.ts
|
|
23
|
+
import { defineConfig } from "ostia"
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
baseline: "main",
|
|
27
|
+
samples: 15,
|
|
28
|
+
warmup: 3,
|
|
29
|
+
thresholds: { timingPct: 5 },
|
|
30
|
+
workloads: [
|
|
31
|
+
{ label: "cold-start", command: ["bun", "src/cli.ts", "--help"], inputs: ["src/**/*.ts"] },
|
|
32
|
+
{ label: "spawn", command: ["bun", "-e", "1"], inputs: [] },
|
|
33
|
+
// Same command three ways: warm, one input touched, cold.
|
|
34
|
+
{ label: "build:warm", command: ["bun", "cli.ts", "build"], timeSource: { pattern: "in (\\d+)ms" } },
|
|
35
|
+
{ label: "build:incremental", command: ["bun", "cli.ts", "build"], timeSource: { pattern: "in (\\d+)ms" },
|
|
36
|
+
prepare: () => touch("posts/hello.md") },
|
|
37
|
+
{ label: "build:cold", command: ["bun", "cli.ts", "build"], timeSource: { pattern: "in (\\d+)ms" },
|
|
38
|
+
prepare: "rm -rf dist" },
|
|
39
|
+
{ label: "suites", suites: ["bench/*.ts"] },
|
|
40
|
+
],
|
|
41
|
+
bench: { suites: ["bench/*.ts"], budgetMs: 500, isolate: true },
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"baseline": "main",
|
|
48
|
+
"samples": 15,
|
|
49
|
+
"thresholds": { "timingPct": 5 },
|
|
50
|
+
"workloads": [
|
|
51
|
+
{ "label": "cold-start", "command": ["bun", "src/cli.ts", "--help"], "inputs": ["src/**/*.ts"] },
|
|
52
|
+
{ "label": "suites", "suites": ["bench/*.ts"] }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A config that isn't valid JSON, isn't an object,
|
|
58
|
+
has no default export (`.ts`), uses a renamed field,
|
|
59
|
+
or has a value of the wrong type fails with error code `config-invalid`
|
|
60
|
+
(exit 2); the message names the key
|
|
61
|
+
(`"bench.jobs" must be a positive integer or "auto", got "many"`).
|
|
62
|
+
The top-level `runs` field was renamed to `samples`;
|
|
63
|
+
a config that still has `runs` is rejected with a message saying so.
|
|
64
|
+
|
|
65
|
+
Validation covers the type and range of every documented field
|
|
66
|
+
(the tables below show them): counts are positive integers,
|
|
67
|
+
`warmup` a non-negative integer, `thresholds` fields non-negative
|
|
68
|
+
numbers (`alpha` at most 1), `workloads` an array
|
|
69
|
+
where each entry has exactly one of `command` (a non-empty argv array)
|
|
70
|
+
or `suites`, and so on.
|
|
71
|
+
A key set to `undefined` in `ostia.config.ts` counts as unset
|
|
72
|
+
and keeps its default.
|
|
73
|
+
|
|
74
|
+
Unknown keys (a typo like `baselineDirr`) and command-only keys
|
|
75
|
+
(`inputs`, `prepare`, `timeSource`, `ignoreExitCodes`) on a `suites`
|
|
76
|
+
workload don't fail: they are ignored with a one-line warning on stderr
|
|
77
|
+
naming the key.
|
|
78
|
+
Keys starting with `$` (`"$schema"`) are never reported.
|
|
79
|
+
|
|
80
|
+
## Top-level fields
|
|
81
|
+
|
|
82
|
+
| Field | Default | Meaning |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `workloads` | `[]` | What `ci` and `baseline save` measure. See below. |
|
|
85
|
+
| `samples` | unset | Command workloads: exact trial count. When unset, `budgetMs`/`minSamples` decide. |
|
|
86
|
+
| `budgetMs` | 3000 | Command workloads: sampling budget per workload, ms. |
|
|
87
|
+
| `minSamples` | 10 | Command workloads: floor on trials when `samples` is unset. |
|
|
88
|
+
| `warmup` | 3 | Command workloads: discarded warmup trials. |
|
|
89
|
+
| `baseline` | `"main"` | Default baseline name for `ci` and `baseline save`. |
|
|
90
|
+
| `baselineDir` | `.ostia/baselines` | Where baselines are stored. |
|
|
91
|
+
| `outDir` | `node_modules/.cache/ostia` | Cache, artifacts, scratch. Independent of `baselineDir`. |
|
|
92
|
+
| `thresholds` | see below | Regression thresholds for `ci` and `compare`. Partial objects merge over the defaults. |
|
|
93
|
+
| `onMissingBaseline` | unset | `"warn"` or `"fail"`; see [cli.md](cli.md#failures-and-missing-baselines). |
|
|
94
|
+
| `noiseCheck` | `true` | Measure the noise floor once per `ci` run. `--no-noise-check` overrides. |
|
|
95
|
+
| `bench` | unset | Settings for in-process suites. See below. |
|
|
96
|
+
| `ab` | unset | Settings for `ostia ab` only. See below. |
|
|
97
|
+
|
|
98
|
+
## `thresholds`
|
|
99
|
+
|
|
100
|
+
| Field | Default | Meaning |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `timingPct` | 5 | Minimum median change, in percent, to call a regression or improvement. |
|
|
103
|
+
| `alpha` | 0.01 | Mann-Whitney significance level. |
|
|
104
|
+
| `bootstrapIterations` | 2000 | Bootstrap rounds for the 95% CI. |
|
|
105
|
+
| `frameSelfPct` | 10 | A CPU frame whose self time grows by more than this fails. |
|
|
106
|
+
| `minFrameSelfUs` | 1000 | Frames below this self time on both sides are ignored. |
|
|
107
|
+
| `heapTypePct` | 10 | A heap object type whose count grows by more than this fails. Only the count is gated: `retainedBytes` is shown, never compared. |
|
|
108
|
+
|
|
109
|
+
How these are applied: [statistics.md](statistics.md).
|
|
110
|
+
|
|
111
|
+
## Workloads
|
|
112
|
+
|
|
113
|
+
Each workload has exactly one of `command` or `suites`.
|
|
114
|
+
|
|
115
|
+
| Field | Applies to | Meaning |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| `label` | both | Display name. Not part of the workload id. |
|
|
118
|
+
| `command` | command | Argv array, run without a shell. |
|
|
119
|
+
| `suites` | suites | Suite file globs, run via `bench()`. Every task is gated individually. |
|
|
120
|
+
| `inputs` | command | Globs of files the timing depends on, for caching. Absent: always rerun. `[]`: depends on nothing. |
|
|
121
|
+
| `prepare` | command | Runs before every trial, unmeasured: a command string, an argv array, or (`.ts` only) a function `({ phase, index }) => ...`. |
|
|
122
|
+
| `timeSource` | command | `{ pattern, group?, unit? }`: take the time from the command's output. `pattern` is a regex source string, or a `RegExp` in `.ts` (no `g`/`y`/`d` flags). `group` defaults to 1, `unit` to `"ms"`. |
|
|
123
|
+
| `timeoutMs` | both | `command`: kill a trial or prepare hook after this long. `suites`: kill a suite file's (or isolated task's) process after this long, overriding `bench.timeoutMs`. Default under `ci`: 10 minutes. |
|
|
124
|
+
| `ignoreExitCodes` | command | Exit codes treated as success. |
|
|
125
|
+
|
|
126
|
+
`prepare` and `timeSource` are part of the workload id;
|
|
127
|
+
`label`, `inputs`, `timeoutMs` and `ignoreExitCodes` are not,
|
|
128
|
+
so changing them doesn't orphan a baseline.
|
|
129
|
+
A function-form `prepare` can't be fingerprinted,
|
|
130
|
+
so that workload is never served from cache.
|
|
131
|
+
|
|
132
|
+
Caching rules for `inputs` are in [cli.md](cli.md#caching).
|
|
133
|
+
|
|
134
|
+
## `bench`
|
|
135
|
+
|
|
136
|
+
Used by `ostia bench` (as defaults under its flags)
|
|
137
|
+
and by `ostia ci`/`ostia baseline save` for `suites` workloads.
|
|
138
|
+
`ostia ab` reads `suites`, `filter`, `preload`, `bunFlags`,
|
|
139
|
+
`outDir` and `timeoutMs` from it.
|
|
140
|
+
|
|
141
|
+
| Field | Default | CLI flag |
|
|
142
|
+
|---|---|---|
|
|
143
|
+
| `suites` | unset | positional files (used by `ostia bench` only; `ci` uses each workload's own `suites`) |
|
|
144
|
+
| `projects` | unset | none; see [Projects](#projects) |
|
|
145
|
+
| `budgetMs` | 500 | `--budget` |
|
|
146
|
+
| `samples` | unset | `--samples` |
|
|
147
|
+
| `minSamples` | cost-aware | `--min-samples` |
|
|
148
|
+
| `jobs` | 1 | `--jobs` (number or `"auto"`) |
|
|
149
|
+
| `isolate` | `false` | `--isolate` / `--no-isolate` |
|
|
150
|
+
| `gc` | `false` | `--gc` / `--no-gc` |
|
|
151
|
+
| `cpu` | `false` | `--cpu` / `--no-cpu` |
|
|
152
|
+
| `cpuIntervalUs` | 100 | `--cpu-interval` |
|
|
153
|
+
| `alloc` | `false` | `--alloc` / `--no-alloc` |
|
|
154
|
+
| `peakMem` | `false` | `--peak-mem` / `--no-peak-mem` |
|
|
155
|
+
| `filter` | unset | `--filter` |
|
|
156
|
+
| `preload` | `[]` | `--preload` (CLI list replaces config list) |
|
|
157
|
+
| `bunFlags` | `[]` | `--bun-flags` (CLI list replaces config list), e.g. `["--conditions=browser"]` |
|
|
158
|
+
| `outDir` | `node_modules/.cache/ostia` (`ci`: top-level `outDir`) | `--out-dir` |
|
|
159
|
+
| `timeoutMs` | none (`ci`: 10 minutes) | `--timeout` |
|
|
160
|
+
|
|
161
|
+
### Projects
|
|
162
|
+
|
|
163
|
+
`preload` and `bunFlags` apply to every suite file,
|
|
164
|
+
so a repository that benchmarks both DOM components
|
|
165
|
+
and plain functions pays the DOM setup for the plain ones too.
|
|
166
|
+
On a benchmark suite of pure functions,
|
|
167
|
+
loading a jsdom preload added about 600ms to each suite file's run
|
|
168
|
+
and made its tasks read 2-5% slower.
|
|
169
|
+
`projects` gives each group of files its own launch settings:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
bench: {
|
|
173
|
+
jobs: "auto",
|
|
174
|
+
projects: [
|
|
175
|
+
{
|
|
176
|
+
suites: ["bench/*.dom.bench.ts"],
|
|
177
|
+
preload: ["./bench/dom-preload.ts"],
|
|
178
|
+
bunFlags: ["--conditions=browser"],
|
|
179
|
+
},
|
|
180
|
+
{ suites: ["bench/*.bench.ts"] }, // the rest: no preload
|
|
181
|
+
],
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
| Field | Meaning |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `suites` | Globs, matched against each suite file's path relative to the current directory. |
|
|
188
|
+
| `preload` | Replaces the top-level `preload` for these files. `[]` runs them with none. Unset: the top-level list applies. |
|
|
189
|
+
| `bunFlags` | Replaces the top-level `bunFlags` for these files, the same way. |
|
|
190
|
+
|
|
191
|
+
A suite file takes the first project that matches it,
|
|
192
|
+
so list the narrower globs first; a file no project matches gets the
|
|
193
|
+
top-level `preload` and `bunFlags`.
|
|
194
|
+
Projects apply to files named on the command line as well,
|
|
195
|
+
and to `ostia ab` and `suites` workloads in `ostia ci`.
|
|
196
|
+
With no files named, `ostia bench` and `ostia ab` run the config's
|
|
197
|
+
`suites` plus every file the projects' globs match.
|
|
198
|
+
`--preload` and `--bun-flags` still win:
|
|
199
|
+
each replaces its field for every file, projects included.
|
|
200
|
+
|
|
201
|
+
Suite globs resolve against the current directory.
|
|
202
|
+
Globs match dotfiles and dot directories (`.github/**`),
|
|
203
|
+
but a wildcard never descends into `node_modules`,
|
|
204
|
+
`.git` or `.ostia/ab` (`ostia ab`'s base trees) unless the pattern names
|
|
205
|
+
that directory (`node_modules/foo/**`).
|
|
206
|
+
The same rules apply to a command workload's `inputs`.
|
|
207
|
+
|
|
208
|
+
## `ab`
|
|
209
|
+
|
|
210
|
+
`ostia ab` takes everything else from `bench`.
|
|
211
|
+
|
|
212
|
+
| Field | Default | CLI flag |
|
|
213
|
+
|---|---|---|
|
|
214
|
+
| `setup` | unset | `--base-setup` (CLI list replaces config list) |
|
|
215
|
+
| `keepTrees` | 5 | `--keep-trees` |
|
|
216
|
+
| `metric` | `"time"` | `--metric` (`"time"` or `"instructions"`) |
|
|
217
|
+
| `alloc` | `false` | `--alloc` / `--no-alloc` |
|
|
218
|
+
| `peakMem` | `false` | `--peak-mem` / `--no-peak-mem` |
|
|
219
|
+
| `memThresholdPct` | 10 | `--mem-threshold` |
|
|
220
|
+
|
|
221
|
+
`setup` is a shell command, or a list run in order,
|
|
222
|
+
that runs once in each freshly extracted base tree, before it's used.
|
|
223
|
+
Use it to build files the suites import that git doesn't hold,
|
|
224
|
+
such as generated or gitignored sources:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{ "ab": { "setup": "bun scripts/generate.ts" } }
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
`bench.alloc` and `bench.peakMem` don't apply to `ab`:
|
|
231
|
+
memory readings add time to every A/B run, so `ab` has its own switches.
|
|
232
|
+
|
|
233
|
+
See [cli.md](cli.md#ostia-ab) for what the command can rely on.
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# ProfileDocument schema
|
|
2
|
+
|
|
3
|
+
Every command and library call produces a `ProfileDocument`:
|
|
4
|
+
one JSON object holding the workloads measured, their measurements,
|
|
5
|
+
and (after a comparison) the comparisons.
|
|
6
|
+
The TypeScript source of truth is
|
|
7
|
+
[`src/ir/types.ts`](../src/ir/types.ts); `ProfileDocument`, `Workload`,
|
|
8
|
+
`Comparison`, `Warning` and `WarningCode` are exported from `ostia`.
|
|
9
|
+
|
|
10
|
+
Units are fixed: nanoseconds for time, bytes for memory,
|
|
11
|
+
microseconds for sampling intervals.
|
|
12
|
+
|
|
13
|
+
## Versioning
|
|
14
|
+
|
|
15
|
+
`schemaVersion` is `2`.
|
|
16
|
+
`loadDocument` (and therefore `compare`, `report`, `ci`) rejects any
|
|
17
|
+
other version with `OstiaDocumentError` (`code: "unsupported-schema"`);
|
|
18
|
+
version 1 documents can't be loaded.
|
|
19
|
+
New optional fields are added without a version bump.
|
|
20
|
+
|
|
21
|
+
Documents written before ostia 0.2.4 lack `p25`/`p75`/`p99`/`mad`;
|
|
22
|
+
`loadDocument` recomputes them from the stored samples,
|
|
23
|
+
so every loaded `TimingStats` has them.
|
|
24
|
+
|
|
25
|
+
`ab` documents written by ostia 0.2.8-0.2.9 name the ratio quartiles of
|
|
26
|
+
`PairedEvidence` (and its `repeats`) `p25`/`p75`;
|
|
27
|
+
later versions name them `ratioP25`/`ratioP75`,
|
|
28
|
+
distinct from `TimingStats.p25`/`p75`, which are ns.
|
|
29
|
+
This did not bump `schemaVersion`: `loadDocument` reads the old names as
|
|
30
|
+
the new ones.
|
|
31
|
+
|
|
32
|
+
`ab` documents written before ostia 0.2.12 lack `ab.metric`;
|
|
33
|
+
`loadDocument` sets it to `"time"`, the only metric they could have
|
|
34
|
+
used.
|
|
35
|
+
|
|
36
|
+
`OstiaDocumentError.code` is `"invalid-json"`,
|
|
37
|
+
`"not-a-document"`
|
|
38
|
+
(no numeric `schemaVersion`, or `workloads`/`measurements` that aren't
|
|
39
|
+
arrays of well-formed objects) or `"unsupported-schema"`.
|
|
40
|
+
|
|
41
|
+
## Top level
|
|
42
|
+
|
|
43
|
+
| Field | Meaning |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `schemaVersion` | `2`. |
|
|
46
|
+
| `toolVersion`, `bunVersion` | ostia and Bun versions that produced the document. |
|
|
47
|
+
| `platform` | `{ os, arch }`. |
|
|
48
|
+
| `createdAt` | ISO timestamp. Metadata only. |
|
|
49
|
+
| `workloads` | `Workload[]`: what was measured. |
|
|
50
|
+
| `measurements` | `Measurement[]`: one per workload and phase. |
|
|
51
|
+
| `environment?` | `{ cpuModel, cores, loadAvg1, loadAvg5, noise: { floorPct, referenceMedianNs, samples, driftPct? } }`. Absent when the noise check was skipped. `driftPct`: how much slower the reference loop ran at the end of the run than at the start. |
|
|
52
|
+
| `git?` | `{ sha, branch, dirty }` from the process's cwd. Absent outside a repo. Never part of an id or cache key. |
|
|
53
|
+
| `comparisons?` | `Comparison[]`, on a candidate document written by `compare`/`ci`. |
|
|
54
|
+
| `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)). |
|
|
55
|
+
| `unmatched?` | `{ baseOnly: string[], candOnly: string[] }`: workload ids on only one side. |
|
|
56
|
+
| `compared?` | `ComparedTask[]`: one row per task on either side; see below. |
|
|
57
|
+
| `ab?` | From `ostia ab`/`ab()`: `{ base: { ref, sha }, newSuites?, rounds, metric, thresholdPct, geomeanThresholdPct, matched, regressed, improved, unchanged, unconfirmed, outputDiffers, notComparable, threw, memory?, geomeanPct, verdict }`. `metric` (`"time"` or `"instructions"`) is what the verdicts, confirmation and `geomeanPct` judge. `memory` (`{ thresholdPct, regressed, improved }`) is there when any task has a memory reading. |
|
|
58
|
+
|
|
59
|
+
## Workloads
|
|
60
|
+
|
|
61
|
+
| Field | Meaning |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `id` | Stable identity; see below. |
|
|
64
|
+
| `kind` | `"subprocess"` or `"inprocess"`. |
|
|
65
|
+
| `label?` | Display name. |
|
|
66
|
+
| `command?` | Argv, for subprocess workloads. |
|
|
67
|
+
| `prepare?` | Argv of a command-form prepare hook. |
|
|
68
|
+
| `timeSource?` | `{ pattern, group?, unit? }`. |
|
|
69
|
+
| `entry?` | `{ file, task, group? }` for suite tasks; `task` is the `group/name` id. |
|
|
70
|
+
| `baseline?` | The group's Relative reference. |
|
|
71
|
+
| `description?`, `groupDescription?` | From `task()`/`group()` options. |
|
|
72
|
+
| `isolated?` | Ran in a process of its own. |
|
|
73
|
+
| `params?` | From `task(..., { params })` or `sweep()`. |
|
|
74
|
+
| `formerIds?` | Ids the task had under its `aliases`; `compare` and `ab` match a base under any of them. Not part of the id. |
|
|
75
|
+
| `skipped?` | From `task.skip()`/`group.skip()`; there is no measurement. |
|
|
76
|
+
|
|
77
|
+
### Workload ids
|
|
78
|
+
|
|
79
|
+
Ids identify what was measured, not where or when:
|
|
80
|
+
|
|
81
|
+
- Subprocess command: a hash of the argv,
|
|
82
|
+
plus the `prepare` hook (its argv, or a function's source text)
|
|
83
|
+
and the `timeSource` spec when present.
|
|
84
|
+
The working directory is not included,
|
|
85
|
+
so a baseline saved in one checkout (a CI runner, another worktree)
|
|
86
|
+
matches a run from another.
|
|
87
|
+
- Suite task: a hash of the suite file path relative to the working
|
|
88
|
+
directory, the `group/name` task id, and `params` when present, so,
|
|
89
|
+
as with commands, moving the checkout doesn't change the id.
|
|
90
|
+
- `profile()` capture: a hash of the `name` option
|
|
91
|
+
when given (it is also the label), else of the function's name
|
|
92
|
+
and source text, so closures that differ only in captured values share
|
|
93
|
+
an id unless named.
|
|
94
|
+
|
|
95
|
+
`label`, `description`, `baseline`, `inputs`,
|
|
96
|
+
`timeoutMs` and `ignoreExitCodes` never affect the id.
|
|
97
|
+
(`profile()`'s `name` is the exception only because it is the workload's
|
|
98
|
+
identity; it is shown as the label too.)
|
|
99
|
+
|
|
100
|
+
## Measurements
|
|
101
|
+
|
|
102
|
+
| Field | Meaning |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `id` | Hash of the workload id, phase, config fingerprint, Bun and ostia versions. |
|
|
105
|
+
| `workloadId` | The workload measured. |
|
|
106
|
+
| `phase` | `"timing"`, `"cpu"`, `"heap"`, `"memstats"` or `"paired"` (`ab`). |
|
|
107
|
+
| `instrumented` | `true` for cpu/heap/memstats: a separate, profiled run, never mixed into timing. |
|
|
108
|
+
| `configFingerprint` | Hash of the sampling settings that produced it. |
|
|
109
|
+
| `trials` | `Trial[]`. |
|
|
110
|
+
| `timing?` | `TimingStats`, on timing measurements with at least one sample; on a paired measurement, the candidate side's per-call times, one sample per round. |
|
|
111
|
+
| `instructions?` | In-process timing, where the machine counts them: `{ samples, median }`, instructions retired per call on the thread that ran the task, user mode only, one sample per trial. |
|
|
112
|
+
| `paired?` | Paired measurements only; see below. |
|
|
113
|
+
| `threw?` | Paired measurements only: `{ side: "base" \| "cand" \| "both", message, repeat? }` for a task that threw. Usually instead of `timing` and `paired`; when it threw in a confirmation repeat, `repeat` (from 1) says which, and `timing`/`paired` keep the first process's numbers. Either way it's left out of `matched` and the geomean. |
|
|
114
|
+
| `interleaved?` | Trials were round-robined with other commands. |
|
|
115
|
+
| `diagnosticWallNs?` | Wall time of an instrumented run. |
|
|
116
|
+
| `cpu?`, `jit?` | CPU evidence (frames, call tree, per-frame totals, samples) and JIT tier counts (`llint`, `baseline`, `dfg`, `ftl`). |
|
|
117
|
+
| `heap?` | `{ typeCounts, objectCount?, heapSizeBytes? }` from a heap snapshot. |
|
|
118
|
+
| `memory?` | `maxRssBytes` (subprocess timing), `heapUsedBeforeBytes`/`heapUsedAfterBytes` (in-process timing: the JS heap as of its last GC just before the task's warmup and just after its last trial, read without forcing a GC), or on `memstats`: `kind: "retained"` with `bytesPerOp` (`--alloc`: heap each call keeps alive after a full GC) or `kind: "peak"` with `peakBytes` (`--peak-mem`: how far the task's first call raised RSS, median of 3 fresh processes). A `memstats` measurement without `kind` predates the field and is `"retained"`. |
|
|
119
|
+
| `warnings` | `Warning[]`. |
|
|
120
|
+
| `artifacts` | `{ kind, path, sha256, bytes }[]`: raw `.cpuprofile`/`.heapsnapshot` files. |
|
|
121
|
+
|
|
122
|
+
`Trial`:
|
|
123
|
+
`{ i, wallNs, exitCode?, userNs?, systemNs?, maxRssBytes?, reportedNs?, timedOut?, timeSourceNoMatch? }`.
|
|
124
|
+
`reportedNs` is the value parsed by a `timeSource`;
|
|
125
|
+
timed-out and unmatched trials contribute no sample.
|
|
126
|
+
|
|
127
|
+
`TimingStats`:
|
|
128
|
+
`{ unit: "ns", samples, mean, median, stddev, min, max, outliers: { mild, severe }, p25, p75, p99, mad, batch? }`.
|
|
129
|
+
For batched in-process tasks, `samples` are per-call times
|
|
130
|
+
and `batch` is the number of calls per trial.
|
|
131
|
+
|
|
132
|
+
`PairedEvidence` (`phase: "paired"`):
|
|
133
|
+
`{ rounds, batch, baseSamples, baseMedianNs, ratios, medianRatio, ratioP25, ratioP75, instructions?, flagged?, repeats?, confirmed?, verdict, sameOutput, suiteChanged?, retained?, peak? }`.
|
|
134
|
+
`baseSamples[i]` and `timing.samples[i]` are the two sides' per-call
|
|
135
|
+
times in round `i`, and `ratios[i]` is candidate over base.
|
|
136
|
+
`instructions`, where the machine counts them,
|
|
137
|
+
holds the same rounds' instructions per call:
|
|
138
|
+
`{ baseSamples, candSamples, baseMedian, candMedian, ratios, medianRatio, ratioP25, ratioP75 }`.
|
|
139
|
+
`flagged` is what the first process saw, by `ab.metric`'s ratios;
|
|
140
|
+
`repeats` are the fresh-process re-measurements of a flagged task
|
|
141
|
+
(`{ medianRatio, ratioP25, ratioP75, instructions?: { medianRatio, ratioP25, ratioP75 }, flagged? }`),
|
|
142
|
+
and `verdict` is `flagged` only when `confirmed`.
|
|
143
|
+
`suiteChanged` is `true` when the suite file differs from the base's
|
|
144
|
+
copy; with `sameOutput: false` too, `verdict` is `unchanged`.
|
|
145
|
+
`retained` (`--alloc`) and `peak` (`--peak-mem`) are `MemoryChange`s:
|
|
146
|
+
`{ baseBytes, candBytes, verdict, floorBytes }`,
|
|
147
|
+
where `verdict` counts only a change past both the memory threshold
|
|
148
|
+
and `floorBytes`.
|
|
149
|
+
See [cli.md](cli.md#ostia-ab).
|
|
150
|
+
|
|
151
|
+
## Comparisons
|
|
152
|
+
|
|
153
|
+
| Field | Meaning |
|
|
154
|
+
|---|---|
|
|
155
|
+
| `baselineMeasurementId`, `candidateMeasurementId` | The pair compared. |
|
|
156
|
+
| `timing?` | `{ medianDeltaPct, meanDeltaPct, ci95?, pValue?, seed?, verdict }`. |
|
|
157
|
+
| `frames?` | Per-frame `{ frameKey, name, baseSelfUs, candSelfUs, deltaPct }`, largest change first. |
|
|
158
|
+
| `heapTypes?` | Per-type `{ type, baseCount, candCount, baseBytes?, candBytes?, deltaPct }`. |
|
|
159
|
+
| `thresholds` | The thresholds applied, plus `effectiveTimingPct`. |
|
|
160
|
+
| `warnings?` | `thin-comparison`, `skipped`, `environment-mismatch`. |
|
|
161
|
+
| `verdict` | `"pass"` or `"fail"`. |
|
|
162
|
+
|
|
163
|
+
See [statistics.md](statistics.md) for how these are computed.
|
|
164
|
+
|
|
165
|
+
## Compared tasks
|
|
166
|
+
|
|
167
|
+
`compared` holds what the table and markdown formats print for a
|
|
168
|
+
comparison, one entry per task, flat for scripts:
|
|
169
|
+
matched tasks in the candidate's order, then candidate-only,
|
|
170
|
+
then base-only ones.
|
|
171
|
+
|
|
172
|
+
| Field | Meaning |
|
|
173
|
+
|---|---|
|
|
174
|
+
| `workloadId` | The candidate's workload id (the base's for a base-only task). |
|
|
175
|
+
| `task`, `group?` | Display name (label, else command, else id) and `group()` path. |
|
|
176
|
+
| `renamedFrom?` | `{ workloadId, task }` of the base, when matched through `aliases`. |
|
|
177
|
+
| `verdict` | `"improved"`, `"unchanged"`, `"regressed"`, `"missing-base"` (candidate only) or `"missing-cand"` (base only). |
|
|
178
|
+
| `comparisonId?`, `pass?` | The `Comparison` with this task's frames, heap types and warnings, and whether it passed the gate. Absent on one-sided tasks. |
|
|
179
|
+
| `timing?` | `{ unit: "ns", baseMedian, candMedian, baseSamples?, candSamples, medianDeltaPct, ci95?, pValue?, thresholdPct }`. Absent on one-sided and skipped tasks. |
|
|
180
|
+
| `memory?` | `{ reading, baseBytes, candBytes, deltaPct }[]` for each reading both sides have: `heapUsedBefore`, `heapUsedAfter`, `retained` (`--alloc`), `peak` (`--peak-mem`), `maxRss`. Informational, never gated. |
|
|
181
|
+
|
|
182
|
+
A document compared before `compared` existed renders rows rebuilt from
|
|
183
|
+
`comparisons`: no sample count for the base, no memory,
|
|
184
|
+
the base median derived from the change.
|
|
185
|
+
|
|
186
|
+
## Warnings
|
|
187
|
+
|
|
188
|
+
`Warning` is `{ code, message, data? }`.
|
|
189
|
+
The terminal table prints codes under each row and messages below the
|
|
190
|
+
table; `--format minimal` includes `code` and `data`.
|
|
191
|
+
|
|
192
|
+
| Code | Where | When |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| `slow-first-run` | timing | The first sample is both an outlier (above median + 3×IQR) and more than twice the median. |
|
|
195
|
+
| `outliers-detected` | subprocess timing | IQR outliers present. Not emitted for in-process tasks, whose GC tails are expected and don't move the median. |
|
|
196
|
+
| `fast-command` | subprocess timing | Median under 5ms: spawn overhead may dominate. |
|
|
197
|
+
| `nonzero-exit` | subprocess timing | A trial exited non-zero with a code that isn't ignored. `data.exitCodes`. |
|
|
198
|
+
| `timeout` | subprocess timing | Trials were killed by `timeoutMs`. |
|
|
199
|
+
| `time-source-no-match` | subprocess timing | Trials' output didn't match the `timeSource` pattern. `data: { pattern, trials, output }`. |
|
|
200
|
+
| `noisy-machine` | first measurement (`ci`: every executed one) | 1-minute load average above 75% of available cores. |
|
|
201
|
+
| `low-sample-count` | in-process timing, `--cpu` capture | Timing: fewer samples than the task's cost class calls for (explicit `minSamples` only). CPU: fewer than 1,000 samples; `data: { samples, target, intervalUs }`. |
|
|
202
|
+
| `jit-cold` | `--cpu` capture | More than 20% of samples in the llint/baseline tiers. |
|
|
203
|
+
| `empty-profile` | CPU capture | The profile recorded no samples (`--cpu` or `profile()`). |
|
|
204
|
+
| `artifact-missing` | CPU/heap capture | The expected `.cpuprofile`/`.heapsnapshot` file wasn't written. |
|
|
205
|
+
| `aborted` | last measurement | The run was cancelled; the document is partial. |
|
|
206
|
+
| `thin-comparison` | comparison | Fewer than 5 samples on a side; point-estimate verdict. |
|
|
207
|
+
| `skipped` | comparison | The candidate task was skipped; treated as unchanged. |
|
|
208
|
+
| `environment-mismatch` | comparison | The documents came from different platforms, Bun versions, or CPUs. |
|
|
209
|
+
| `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. |
|
|
210
|
+
| `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
|
+
|
|
212
|
+
## Files on disk
|
|
213
|
+
|
|
214
|
+
- `outDir` (default `node_modules/.cache/ostia`): the `ci` cache,
|
|
215
|
+
`artifacts/`, and `bench` and `ab` scratch files.
|
|
216
|
+
- `.ostia/ab/` at the project root: `<sha>/`
|
|
217
|
+
(or `<sha>-<hash>/` with setup commands),
|
|
218
|
+
the base trees `ab` extracts
|
|
219
|
+
(one per commit and setup, reused; the 5 most recently used are kept,
|
|
220
|
+
see `--keep-trees`), and a `.gitignore` that ignores them.
|
|
221
|
+
- `baselineDir` (default `.ostia/baselines`): `<name>.json` baselines.
|
|
222
|
+
|
|
223
|
+
Documents are written atomically (temp file, then rename),
|
|
224
|
+
so an interrupted write never leaves a truncated file.
|