ostia 0.4.0 → 0.5.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.
Files changed (59) hide show
  1. package/README.md +4 -4
  2. package/docs/agent-protocol.md +13 -9
  3. package/docs/cli.md +90 -73
  4. package/docs/config.md +2 -2
  5. package/docs/document-schema.md +14 -12
  6. package/docs/library.md +17 -15
  7. package/docs/preload-recipes.md +4 -4
  8. package/docs/statistics.md +10 -10
  9. package/index.d.ts +128 -58
  10. package/package.json +1 -1
  11. package/src/ab/ab-runner.ts +6 -6
  12. package/src/ab/index.ts +15 -6
  13. package/src/bench/index.ts +12 -3
  14. package/src/bench/registry.ts +6 -4
  15. package/src/bench/run-tasks.ts +2 -2
  16. package/src/bench/runner.ts +2 -2
  17. package/src/bench/support.ts +8 -4
  18. package/src/bench/sweep.ts +2 -2
  19. package/src/cache/fingerprint.ts +2 -2
  20. package/src/capture/bunflags.ts +2 -2
  21. package/src/capture/cpu.ts +2 -2
  22. package/src/capture/heap-parse.ts +2 -2
  23. package/src/ci/index.ts +7 -6
  24. package/src/cli/agent.ts +54 -0
  25. package/src/cli/flags.ts +50 -9
  26. package/src/cli/help.ts +29 -11
  27. package/src/cli/output.ts +6 -3
  28. package/src/cli/run.ts +29 -5
  29. package/src/compare/index.ts +4 -4
  30. package/src/config/index.ts +14 -10
  31. package/src/config/validate.ts +4 -4
  32. package/src/glob.ts +2 -2
  33. package/src/ir/document.ts +2 -2
  34. package/src/ir/types.ts +47 -24
  35. package/src/measure/alloc.ts +2 -2
  36. package/src/measure/cpu.ts +2 -2
  37. package/src/measure/environment.ts +11 -6
  38. package/src/measure/inprocess.ts +14 -10
  39. package/src/measure/instructions.ts +2 -2
  40. package/src/measure/noise.ts +51 -13
  41. package/src/measure/paired.ts +2 -2
  42. package/src/measure/peak.ts +4 -4
  43. package/src/measure/timing.ts +18 -3
  44. package/src/profile.ts +6 -4
  45. package/src/renderers/collapsed.ts +2 -2
  46. package/src/renderers/concise.ts +148 -0
  47. package/src/renderers/format.ts +13 -4
  48. package/src/renderers/index.ts +6 -0
  49. package/src/renderers/markdown.ts +2 -2
  50. package/src/renderers/mermaid.ts +2 -2
  51. package/src/renderers/minimal.ts +8 -7
  52. package/src/renderers/relative.ts +2 -2
  53. package/src/renderers/select.ts +2 -2
  54. package/src/renderers/terminal.ts +6 -3
  55. package/src/renderers/types.ts +3 -0
  56. package/src/spawn/index.ts +47 -14
  57. package/src/stats/bootstrap.ts +2 -2
  58. package/src/stats/index.ts +2 -2
  59. package/src/time.ts +75 -10
package/README.md CHANGED
@@ -85,7 +85,7 @@ ostia ci
85
85
  ostia time "bun a.ts" --cpu
86
86
 
87
87
  # One JSON object per line, for a script or an agent
88
- ostia bench suite.ts --format minimal
88
+ ostia bench suite.ts --format events
89
89
  ```
90
90
 
91
91
  These docs ship in the package, at `node_modules/ostia/docs/`.
@@ -114,14 +114,14 @@ const { text } = await renderers.markdown.render(doc, {})
114
114
 
115
115
  ## Docs
116
116
 
117
- - [CLI](https://github.com/metonym/ostia/blob/master/docs/cli.md):
118
- every command and flag
117
+ - [CLI](https://github.com/metonym/ostia/blob/master/docs/cli.md): every
118
+ command and flag
119
119
  - [Library](https://github.com/metonym/ostia/blob/master/docs/library.md):
120
120
  `time()`, `bench()`, `ab()`, `profile()`, and documents
121
121
  - [Config](https://github.com/metonym/ostia/blob/master/docs/config.md):
122
122
  `ostia.config` workloads, thresholds and baselines
123
123
  - [Machine-readable output](https://github.com/metonym/ostia/blob/master/docs/agent-protocol.md):
124
- `--format minimal`, exit codes and error codes, for scripts and agents
124
+ `--format events`, exit codes and error codes, for scripts and agents
125
125
  - [Statistics](https://github.com/metonym/ostia/blob/master/docs/statistics.md):
126
126
  how a comparison decides, and the noise floor
127
127
  - [Document schema](https://github.com/metonym/ostia/blob/master/docs/document-schema.md):
@@ -1,18 +1,21 @@
1
1
  # Machine-readable output
2
2
 
3
- `--format minimal` is a line protocol for scripts and LLM agents:
3
+ `--format events` is a line protocol for scripts
4
+ and LLM agents (`minimal`, its name until 0.5.0, still works):
4
5
  one JSON object per line on stdout, nothing else.
6
+ Without `--format`, an agent gets `concise` text instead,
7
+ so a script that parses the output asks for `events` by name.
5
8
  It drops the raw sample arrays and prose that make a full
6
9
  `ProfileDocument` large.
7
10
  It works on `time`, `bench`, `ab`, `compare`, `ci`,
8
11
  `report` and `baseline show`.
9
12
 
10
13
  ```sh
11
- ostia time --samples 10 "bun a.ts" --format minimal
12
- ostia bench bench/*.ts --format minimal
13
- ostia ab bench/*.ts --base origin/main --format minimal
14
- ostia compare before.json after.json --format minimal
15
- ostia ci --format minimal; echo $?
14
+ ostia time --samples 10 "bun a.ts" --format events
15
+ ostia bench bench/*.ts --format events
16
+ ostia ab bench/*.ts --base origin/main --format events
17
+ ostia compare before.json after.json --format events
18
+ ostia ci --format events; echo $?
16
19
  ```
17
20
 
18
21
  `ostia ab` can run for many minutes.
@@ -146,7 +149,7 @@ Never emitted for `time`, `bench` or `report`.
146
149
  | `verdict` | `"pass"` when `exitCode` is 0, `"fail"` when it is 1 (a regression), `"error"` otherwise: exit 2 (harness error) or 130 (cancelled), where no verdict was reached. |
147
150
  | `exitCode` | The process's exit code. |
148
151
 
149
- Example (`ostia ci --format minimal` after a regression):
152
+ Example (`ostia ci --format events` after a regression):
150
153
 
151
154
  ```
152
155
  {"event":"run","protocolVersion":2,"schemaVersion":2,"workloadId":"wl_11e8562f3622d528","task":"work","unit":"ns","samples":10,"batch":1,"mean":21012800,"median":20999900,"stddev":231456,"stddevPct":1.1015,"min":20664000,"max":21552300,"warnings":[{"code":"outliers-detected","data":{"mild":1,"severe":0}}],"p75":21086100,"p99":21517600,"mad":126625,"userNs":15519000,"systemNs":6015500,"noiseFloorPct":2.09286,"delta":{"medianPct":44.0989,"meanPct":43.9626,"verdict":"regressed","pass":false,"effectiveTimingPct":10,"matched":true,"ci95":[41.4394,45.5841],"pValue":0.000157103}}
@@ -170,8 +173,9 @@ and exits 2.
170
173
  ## Errors
171
174
 
172
175
  On exit 2, stderr gets a prose message.
173
- When stderr is not a TTY, or `--format` is `minimal`, `json` or `jsonl`,
174
- one more line follows it as the last line of stderr:
176
+ When stderr is not a TTY, or `--format` is `events`,
177
+ `json` or `jsonl` (or `--json`), one more line follows it as the last
178
+ line of stderr:
175
179
 
176
180
  ```json
177
181
  {"event":"error","protocolVersion":2,"code":"command-failed","message":"One or more commands failed to produce a clean measurement; see the report above for details."}
package/docs/cli.md CHANGED
@@ -10,14 +10,14 @@ ostia ci run configured workloads against a baseline, gate
10
10
  ostia baseline save|list|show manage baseline documents
11
11
  ```
12
12
 
13
- Every command takes `--help`; `ostia --version` (or `-v`) prints the
14
- version.
15
- A flag's value can follow it (`--format minimal`)
16
- or be attached (`--format=minimal`);
17
- `--ignore-failure[=CODES]` only takes the attached form.
13
+ Every command takes `--help`; `ostia --version` (or `-v`) prints
14
+ the version.
15
+ A flag's value can follow it (`--format events`)
16
+ or be attached (`--format=events`); `--ignore-failure[=CODES]` only
17
+ takes the attached form.
18
18
  A flag that needs a value and is given none is a usage error (exit 2).
19
- Exit codes and the machine-readable error line are described in
20
- [agent-protocol.md](agent-protocol.md).
19
+ Exit codes and the machine-readable error line are described
20
+ in [agent-protocol.md](agent-protocol.md).
21
21
 
22
22
  `bench`, `ab`, `compare`, `ci` and `baseline` read the config file
23
23
  ([config.md](config.md)): `ostia.config.ts`, else `ostia.config.json`,
@@ -35,9 +35,19 @@ or a flag with nothing to act on
35
35
  format) exits 2 with `invalid-flag`.
36
36
 
37
37
  Output formats shared by `time`, `bench`, `ab`, `compare` and `ci`:
38
- `table` (default), `json`, `jsonl`, `markdown`, `minimal`.
38
+ `table` (default), `concise`, `events`, `json`, `jsonl`, `markdown`.
39
+ `--json` is short for `--format json`.
40
+ `minimal` still names `events`, and `agent` names `concise`.
39
41
  `report` additionally accepts the CPU visualization formats.
40
42
 
43
+ With no `--format`, a command run by a coding agent prints `concise`:
44
+ one of `AGENT`, `AI_AGENT`, `CLAUDECODE`,
45
+ `CODEX_CI` or `CODEX_THREAD_ID` is set, and not to `0`,
46
+ the variables svelte-typecheck and svelte-lint read.
47
+ A line on stderr says so.
48
+ `OSTIA_FORMAT` sets the default for any caller,
49
+ and `--format` always wins.
50
+
41
51
  ## `ostia time`
42
52
 
43
53
  ```
@@ -53,6 +63,9 @@ ostia time [flags] -- <argv...>
53
63
  | `--warmup N` | Discarded warmup trials per command (default: 3). |
54
64
  | `--no-interleave` | Run each command's trials to completion before the next command starts. |
55
65
  | `--prepare CMD` | Run `CMD` before every trial, unmeasured. Once (all commands) or once per command. |
66
+ | `--shell SH` | Run each command, and `--prepare`, as `SH -c CMD` (`sh`, `bash`), so env prefixes, pipes, `&&` and `$(...)` work; without it, a command is split on whitespace and run with no shell. The shell's startup is measured, printed and stored as `shell`, and not subtracted: two commands under one shell pay it alike. |
67
+ | `--save-output DIR` | Save each trial's stdout and stderr under `DIR`, a folder per command, as `trial-N.log` and `warmup-N.log`, written after the trial's clock stops. Each trial's `outputPath` names its file. |
68
+ | `--show-output` | Pass each trial's output to stderr, for debugging; stdout keeps ostia's own output. |
56
69
  | `--time-source REGEX` | Take each trial's time from capture group 1 of the command's output. |
57
70
  | `--time-unit UNIT` | Unit of the `--time-source` number: `ns`, `us`, `ms` (default), `s`. Needs `--time-source`. |
58
71
  | `--cpu` | Capture one extra CPU-profile trial per command. |
@@ -61,9 +74,10 @@ ostia time [flags] -- <argv...>
61
74
  | `--timeout MS` | SIGKILL a trial or `--prepare` hook that runs longer than `MS`. No default. |
62
75
  | `--ignore-failure[=CODE,...]` | Treat these exit codes (bare: every code) as success. |
63
76
  | `--out-dir PATH` | Artifact directory (default: `node_modules/.cache/ostia`). |
64
- | `--no-noise-check` | Skip the ~200ms noise-floor measurement. |
77
+ | `--no-noise-check` | Skip the noise-floor checks: 25 to 50 ms at the start, until the reference loop's median holds, and 25 ms at the end, for drift. |
78
+ | `--noise-budget MS` | Sample the noise floor for exactly `MS` at the start and at the end, with no early stop. |
65
79
  | `--export-json PATH` | Write the document to `PATH`. |
66
- | `--format FORMAT` | `table`, `json`, `jsonl`, `markdown`, `minimal`. |
80
+ | `--format FORMAT` | `table`, `concise`, `events`, `json`, `jsonl`, `markdown`; `--json` for `--format json`. |
67
81
  | `--quiet` | Don't print the report. |
68
82
 
69
83
  ### Commands
@@ -88,15 +102,15 @@ With several commands, each gets its own N or its own budget.
88
102
 
89
103
  With 2+ commands, trials run round-robin
90
104
  (one trial of each command, repeated) so drift over the run
91
- (thermal throttling, a busy neighbor process) affects every command
92
- equally.
105
+ (thermal throttling, a busy neighbor process) affects every
106
+ command equally.
93
107
  Each such measurement carries `interleaved: true`.
94
108
  `--no-interleave` runs the commands one after another.
95
109
 
96
110
  ### Failures
97
111
 
98
- A command's trial loop stops at its first non-zero exit that isn't
99
- ignored.
112
+ A command's trial loop stops at its first non-zero exit that
113
+ isn't ignored.
100
114
  That trial's sample is kept, the measurement carries a `nonzero-exit`
101
115
  warning, and `ostia time` exits 2.
102
116
  The same rule applies in `ostia ci`: any non-ignored non-zero exit,
@@ -111,8 +125,8 @@ ostia time --ignore-failure "./flaky-exit.sh" # every exit code counts as s
111
125
  A timed-out trial contributes no sample and the measurement carries a
112
126
  `timeout` warning.
113
127
  If every trial of a command times out, the command has no timing stats,
114
- prints like a skipped workload, and the run exits 2 with error code
115
- `timeout`.
128
+ prints like a skipped workload, and the run exits 2 with error
129
+ code `timeout`.
116
130
  `--timeout` also applies to `--prepare` hooks;
117
131
  a hook that times out aborts the run.
118
132
  A timed-out trial has no exit code, so it is not a failing exit:
@@ -170,16 +184,16 @@ A match with no group 1, or a non-numeric capture, is an error.
170
184
  The budget always counts wall time.
171
185
 
172
186
  The time source is part of the workload id,
173
- so timing the same command both ways gives two workloads with two
174
- verdicts.
187
+ so timing the same command both ways gives two workloads with
188
+ two verdicts.
175
189
 
176
190
  ### `--cpu` / `--heap`
177
191
 
178
192
  Each adds one instrumented trial per command after the timing trials,
179
193
  labeled as a separate measurement (`phase: "cpu"` / `"heap"`)
180
194
  and never mixed into timing.
181
- The raw `.cpuprofile` / `.heapsnapshot` is written under
182
- `<out-dir>/artifacts/`.
195
+ The raw `.cpuprofile` / `.heapsnapshot` is written
196
+ under `<out-dir>/artifacts/`.
183
197
 
184
198
  ```
185
199
  CPU capture - bun fixtures/work.ts (instrumented, 1000µs interval, diagnostic wall 300.558ms)
@@ -226,9 +240,10 @@ ostia bench [flags] <suite.ts...>
226
240
  | `--timeout MS` | SIGKILL a suite (or isolated task) process after `MS`. No default. |
227
241
  | `--out-dir PATH` | Scratch directory (default: `node_modules/.cache/ostia`). |
228
242
  | `--config PATH` | Config file to read instead of discovery. |
229
- | `--no-noise-check` | Skip the ~200ms noise-floor measurement. |
243
+ | `--no-noise-check` | Skip the noise-floor checks: 25 to 50 ms at the start, until the reference loop's median holds, and 25 ms at the end, for drift. |
244
+ | `--noise-budget MS` | Sample the noise floor for exactly `MS` at the start and at the end, with no early stop. |
230
245
  | `--export-json PATH` | Write the document to `PATH`. |
231
- | `--format FORMAT` | `table`, `json`, `jsonl`, `markdown`, `minimal`. |
246
+ | `--format FORMAT` | `table`, `concise`, `events`, `json`, `jsonl`, `markdown`; `--json` for `--format json`. |
232
247
  | `--quiet` | Don't print the report. |
233
248
 
234
249
  With no suite files, `ostia bench` uses the config's `bench` section
@@ -312,11 +327,11 @@ and loops the task long enough to collect about 2,000 samples:
312
327
  and never less than one whole call.
313
328
  The header of each CPU section shows the sample count;
314
329
  below 1,000 the measurement carries a `low-sample-count` warning
315
- (`{ samples, target, intervalUs }`),
316
- since frame shares that thin move by several points between runs.
330
+ (`{ samples, target, intervalUs }`), since frame shares that thin move
331
+ by several points between runs.
317
332
  When more than 20% of its samples are in the llint/baseline tiers,
318
- it carries a `jit-cold` warning
319
- (`{ llintPct, baselinePct, dfgPct, ftlPct }`).
333
+ it carries a `jit-cold`
334
+ warning (`{ llintPct, baselinePct, dfgPct, ftlPct }`).
320
335
  With CPU evidence on both sides, `compare` reports per-frame deltas.
321
336
 
322
337
  Self time is attributed to the frame the JIT compiled,
@@ -404,8 +419,8 @@ A cache that grows the heap elsewhere in the process shows in
404
419
  `heapUsedBefore` of every task after it.
405
420
  `ostia compare` reports either reading when it moves 10%
406
421
  or more
407
- (`+9.4% median` next to
408
- `heap used before 12.00MiB → 16.80MiB (+40.0%)`).
422
+ (`+9.4% median` next
423
+ to `heap used before 12.00MiB → 16.80MiB (+40.0%)`).
409
424
  Bun exposes neither a JS allocation counter nor GC counts
410
425
  or pause times, so ostia can't report bytes allocated per call
411
426
  or GC activity.
@@ -429,14 +444,14 @@ Object.assign(globalThis, { document: dom.window.document, window: dom.window })
429
444
  ostia bench --preload ./bench/jsdom-setup.ts bench/*.dom.bench.ts
430
445
  ```
431
446
 
432
- Complete jsdom, happy-dom and Svelte-plugin setups are in
433
- [preload-recipes.md](preload-recipes.md).
447
+ Complete jsdom, happy-dom and Svelte-plugin setups are
448
+ in [preload-recipes.md](preload-recipes.md).
434
449
  To give only some suite files a preload (the DOM ones, say),
435
- set it per group with the config's
436
- [`bench.projects`](config.md#projects).
450
+ set it per group with the
451
+ config's [`bench.projects`](config.md#projects).
437
452
 
438
- `--bun-flags FLAGS` passes flags to the `bun` process that runs each
439
- suite.
453
+ `--bun-flags FLAGS` passes flags to the `bun` process that runs
454
+ each suite.
440
455
  The common case is a package whose `exports` map branches on a condition
441
456
  Bun doesn't set by default: Svelte 5 resolves to its server build
442
457
  without `--conditions=browser`, and mounting a component then fails.
@@ -490,9 +505,10 @@ ostia ab [flags] <suite.ts...>
490
505
  | `--keep-trees N` | Base trees to keep cached (default: 5). See "The base tree". |
491
506
  | `--clean` | Remove every cached base tree, then exit. |
492
507
  | `--config PATH` | Config file to read instead of discovery. |
493
- | `--no-noise-check` | Skip the ~200ms noise-floor measurement. |
508
+ | `--no-noise-check` | Skip the noise-floor checks: 25 to 50 ms at the start, until the reference loop's median holds, and 25 ms at the end, for drift. |
509
+ | `--noise-budget MS` | Sample the noise floor for exactly `MS` at the start and at the end, with no early stop. |
494
510
  | `--export-json PATH` | Write the document to `PATH`. |
495
- | `--format FORMAT` | `table`, `json`, `jsonl`, `markdown`, `minimal`. |
511
+ | `--format FORMAT` | `table`, `concise`, `events`, `json`, `jsonl`, `markdown`; `--json` for `--format json`. |
496
512
  | `--progress` / `--no-progress` | Print progress to stderr. Default: on when stderr is a terminal and `--quiet` isn't given. |
497
513
  | `--quiet` | Don't print the report. |
498
514
 
@@ -556,8 +572,8 @@ The base tree's paths are about 20 characters longer than the working
556
572
  tree's, so code that does string work on absolute paths
557
573
  (joining, relativizing, hashing them) does slightly more on the base
558
574
  side and can read as a few percent faster on the candidate;
559
- in one path-heavy task, each extra character cost 0.3–0.45% more
560
- instructions.
575
+ in one path-heavy task, each extra character cost 0.3–0.45%
576
+ more instructions.
561
577
  A suite file that doesn't exist at the ref has nothing to pair with:
562
578
  it's listed as a new suite, its tasks are candidate-only
563
579
  and aren't timed, and the run goes on with the other suites.
@@ -573,8 +589,8 @@ Use it when the suites import generated or gitignored files:
573
589
  ostia ab bench/*.ts --base-setup "bun scripts/generate.ts"
574
590
  ```
575
591
 
576
- Each command runs in the tree's counterpart of the current directory,
577
- with:
592
+ Each command runs in the tree's counterpart of the current
593
+ directory, with:
578
594
 
579
595
  - the project's `node_modules` linked into the tree,
580
596
  so build scripts that read `./node_modules/...`
@@ -585,8 +601,8 @@ with:
585
601
  - `OSTIA_AB_SHA`, the base commit, and `OSTIA_AB_CANDIDATE_DIR`,
586
602
  the current directory in the working tree.
587
603
  When the generated files don't depend on the base's code,
588
- copying them is cheaper than building them:
589
- `--base-setup 'cp -R "$OSTIA_AB_CANDIDATE_DIR/src/gen" src/'`.
604
+ copying them is cheaper than building
605
+ them: `--base-setup 'cp -R "$OSTIA_AB_CANDIDATE_DIR/src/gen" src/'`.
590
606
 
591
607
  The tree is cached under `.ostia/ab/<sha>-<hash>/`,
592
608
  where the hash covers the commands, so changing them builds a new tree.
@@ -595,8 +611,8 @@ when every command succeeds, so a failed or interrupted setup never
595
611
  leaves a half-built tree for a later run to reuse.
596
612
  Each command runs in its own process group,
597
613
  and the whole group is killed when the command ends,
598
- times out or is cancelled, so nothing it started in the background keeps
599
- running.
614
+ times out or is cancelled, so nothing it started in the background
615
+ keeps running.
600
616
  A command that exits non-zero (or runs past `--timeout`) stops the run
601
617
  with exit 2 (`command-failed`) and the last 20 lines of its stderr.
602
618
 
@@ -661,8 +677,8 @@ so the candidate was slower in at least three quarters of rounds;
661
677
  `improved` is the mirror image.
662
678
  Pairing can't cancel one thing: how the JIT happened to compile each
663
679
  side's copy of the code in that process,
664
- which can skew a small task by 20% in either direction with tight
665
- quartiles.
680
+ which can skew a small task by 20% in either direction with
681
+ tight quartiles.
666
682
  So each flagged task is measured again in `--confirm` fresh processes,
667
683
  and only counts when every repeat flags it the same way;
668
684
  otherwise it reads `unconfirmed` and counts as unchanged.
@@ -687,10 +703,10 @@ to mean anything.
687
703
  **Errors.**
688
704
  A task that throws, on either side, doesn't stop the suite.
689
705
  It isn't timed, reads `base threw`, `candidate threw`
690
- or `both threw` in the table, and the error's first line is listed under
691
- "Threw".
692
- A throw from a task's `before` or `after` hook counts for that hook's
693
- side.
706
+ or `both threw` in the table, and the error's first line is listed
707
+ under "Threw".
708
+ A throw from a task's `before` or `after` hook counts for that
709
+ hook's side.
694
710
  Each hook runs once: a side whose `before` threw isn't timed
695
711
  or torn down, and every side that was set up is torn down once,
696
712
  even when a hook throws.
@@ -726,8 +742,8 @@ with a load average of 4–6 on 8 cores,
726
742
  rounds of identical code spread −40%…+44%,
727
743
  and a real 5% change can't be told apart.
728
744
  The number of instructions a call retires barely moves with load,
729
- since another process taking the CPU doesn't change what this thread
730
- executes.
745
+ since another process taking the CPU doesn't change what this
746
+ thread executes.
731
747
  So where the machine can count them,
732
748
  `ostia ab` reads the hardware counter of the thread running the task
733
749
  around each batch, and shows the change in instructions per call next to
@@ -794,8 +810,8 @@ For `--peak-mem` it's 1 MiB
794
810
  when a `peak-hidden` warning says memory freed before the call could
795
811
  hide part of its peak, the size of that memory.
796
812
  A memory regression fails the run like a time regression.
797
- Task and group `alloc`/`peakMem` options apply under `ab` as under
798
- `bench`.
813
+ Task and group `alloc`/`peakMem` options apply under `ab` as
814
+ under `bench`.
799
815
  A task that's not comparable gets no memory verdict.
800
816
  The Change column leaves out the percent when the base reading is under
801
817
  the floor: a percent of almost nothing means little.
@@ -824,7 +840,7 @@ which is how a script or agent can tell a long run from a stuck one:
824
840
  [ab] memory · process 2/6 candidate search/regex
825
841
  ```
826
842
 
827
- Progress never goes to stdout, so `--format minimal` output stays clean.
843
+ Progress never goes to stdout, so `--format events` output stays clean.
828
844
 
829
845
  Exit codes: `0` pass, `1` a confirmed regression,
830
846
  a task that threw on the candidate side only,
@@ -840,8 +856,8 @@ or timed out (`spawn-failed`); `130` Ctrl-C.
840
856
  With no suite files, `ostia ab` uses the config's `bench.suites`,
841
857
  and its `filter`, `preload`, `bunFlags`, `outDir` and `timeoutMs`,
842
858
  and its setup commands from `ab.setup`
843
- (and `ab.metric`, `ab.alloc` and the other `ab` keys; see
844
- [config.md](config.md)).
859
+ (and `ab.metric`, `ab.alloc` and the other `ab` keys;
860
+ see [config.md](config.md)).
845
861
  The sampling settings (`budgetMs`, `samples`, `isolate` and the rest)
846
862
  don't apply.
847
863
 
@@ -857,7 +873,7 @@ ostia compare <candidate.json> --baseline <base.json>
857
873
  | `--baseline PATH` | The base document, when only the candidate is positional. |
858
874
  | `--config PATH` | Config file to take `thresholds` from, instead of discovery. |
859
875
  | `--export-json PATH` | Write the candidate document, with comparisons, to `PATH`. |
860
- | `--format FORMAT` | `table`, `json`, `jsonl`, `markdown`, `minimal`. |
876
+ | `--format FORMAT` | `table`, `concise`, `events`, `json`, `jsonl`, `markdown`; `--json` for `--format json`. |
861
877
  | `--quiet` | Don't print the report. |
862
878
 
863
879
  Exactly two document paths are taken (one with `--baseline`);
@@ -936,22 +952,22 @@ the same rows the table and markdown print:
936
952
  `verdict` is `improved`, `unchanged`, `regressed`,
937
953
  `missing-base` (candidate only) or `missing-cand` (base only).
938
954
  `pass` is whether the comparison passed the gate,
939
- frames and heap types included; one-sided tasks have neither `pass` nor
940
- `timing`.
955
+ frames and heap types included; one-sided tasks have neither `pass`
956
+ nor `timing`.
941
957
  Frame and heap-type deltas and warnings stay on the `Comparison` named
942
958
  by `comparisonId`.
943
959
 
944
960
  When the documents differ in OS, architecture, Bun version,
945
961
  CPU model or core count, every comparison carries an
946
- `environment-mismatch` warning; table and markdown print it once in the
947
- header.
962
+ `environment-mismatch` warning; table and markdown print it once in
963
+ the header.
948
964
 
949
965
  Workloads are compared, and listed, in the candidate document's order.
950
966
 
951
967
  Exit codes: `0` pass, `1` at least one workload failed
952
968
  (timing regression, or a CPU frame / heap type over its threshold),
953
- `2` zero workloads matched (`no-matches`) or a document failed to load
954
- (`document-load-failed`).
969
+ `2` zero workloads matched (`no-matches`) or a document failed to
970
+ load (`document-load-failed`).
955
971
  How verdicts are decided: [statistics.md](statistics.md).
956
972
 
957
973
  ## `ostia report`
@@ -975,14 +991,15 @@ error (exit 2).
975
991
  | `json` | The document, pretty-printed (same bytes as `--export-json`) |
976
992
  | `jsonl` | One `kind: "document"` header line, then one `kind: "measurement"` line per measurement |
977
993
  | `markdown` | Report for humans and agents |
978
- | `minimal` | One JSON object per timing measurement ([agent-protocol.md](agent-protocol.md)) |
994
+ | `concise` | One line per task, then its warnings; alias `agent` |
995
+ | `events` | One JSON object per timing measurement ([agent-protocol.md](agent-protocol.md)); alias `minimal` |
979
996
  | `collapsed` | Folded stacks, `root;a;b 42`, for `flamegraph.pl` and similar tools |
980
997
  | `mermaid` | Call tree, top 15 frames by total time |
981
998
  | `speedscope` | Sampled-profile JSON for speedscope.app |
982
999
  | `cpuprofile` | The original `.cpuprofile` artifact, verbatim (`cpu-prof`/`inspector` origins only) |
983
1000
 
984
- A visualization format on a document with no CPU evidence exits 2 with
985
- `no-cpu-evidence`.
1001
+ A visualization format on a document with no CPU evidence exits 2
1002
+ with `no-cpu-evidence`.
986
1003
 
987
1004
  ```
988
1005
  $ ostia report doc.json --format collapsed
@@ -1024,9 +1041,9 @@ ostia ci [flags]
1024
1041
  | `--baseline NAME` | Baseline to compare against (default: config `baseline`, or `main`). |
1025
1042
  | `--save-baseline` | After a pass, write this run as the new baseline at the same path. Always measures fresh (see below). |
1026
1043
  | `--config PATH` | Config file to read instead of discovery. |
1027
- | `--no-noise-check` | Skip the ~200ms noise-floor measurement. |
1044
+ | `--no-noise-check` | Skip the noise-floor checks: 25 to 50 ms at the start, until the reference loop's median holds, and 25 ms at the end, for drift. |
1028
1045
  | `--export-json PATH` | Write the candidate document, with comparisons, to `PATH`. |
1029
- | `--format FORMAT` | `table`, `json`, `jsonl`, `markdown`, `minimal`. |
1046
+ | `--format FORMAT` | `table`, `concise`, `events`, `json`, `jsonl`, `markdown`; `--json` for `--format json`. |
1030
1047
  | `--quiet` | Don't print the report. |
1031
1048
 
1032
1049
  `ostia ci` loads the config ([config.md](config.md)),
@@ -1070,8 +1087,8 @@ and the contents of the files matched by `inputs`:
1070
1087
  - no `inputs` field: never cached, always reruns;
1071
1088
  - `inputs: []`: depends on nothing, cached until the command
1072
1089
  or settings change;
1073
- - `inputs: ["src/**/*.ts", "/abs/path/data.bin"]`:
1074
- reused while the matched files' contents are unchanged.
1090
+ - `inputs: ["src/**/*.ts", "/abs/path/data.bin"]`: reused
1091
+ while the matched files' contents are unchanged.
1075
1092
  Absolute paths work.
1076
1093
  Globs match dotfiles, but wildcards skip `node_modules`,
1077
1094
  `.git` and `.ostia/ab` (`ostia ab`'s base trees)
@@ -1178,8 +1195,8 @@ An option that means the same thing has the same name everywhere:
1178
1195
  the CLI flag is its kebab-case form
1179
1196
  (`timeoutMs` is `--timeout`, `outDir` is `--out-dir`, `cpuIntervalUs` is
1180
1197
  `--cpu-interval`), and the config key and library option are identical.
1181
- The defaults differ on purpose where the commands measure different
1182
- things:
1198
+ The defaults differ on purpose where the commands measure
1199
+ different things:
1183
1200
 
1184
1201
  | Setting | `time` | `bench` / `ci` suites | `ab` |
1185
1202
  |---|---|---|---|
package/docs/config.md CHANGED
@@ -57,8 +57,8 @@ export default defineConfig({
57
57
  A config that isn't valid JSON, isn't an object,
58
58
  has no default export (`.ts`), uses a renamed field,
59
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"`).
60
+ (exit 2); the message names the
61
+ key (`"bench.jobs" must be a positive integer or "auto", got "many"`).
62
62
  The top-level `runs` field was renamed to `samples`;
63
63
  a config that still has `runs` is rejected with a message saying so.
64
64
 
@@ -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 have
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
- (no numeric `schemaVersion`, or `workloads`/`measurements` that aren't
39
- arrays of well-formed objects) or `"unsupported-schema"`.
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
- | `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. |
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 call:
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
- where `verdict` counts only a change past both the memory threshold
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 minimal` includes `code` and `data`.
192
+ table; `--format events` includes `code` and `data`.
191
193
 
192
194
  | Code | Where | When |
193
195
  |---|---|---|
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 `ProfileDocument`
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 {
@@ -22,8 +22,8 @@ import type {
22
22
 
23
23
  ## `time(opts)` → `Promise<ProfileDocument>`
24
24
 
25
- Subprocess timing; the same behavior as `ostia time`
26
- ([cli.md](cli.md#ostia-time)).
25
+ Subprocess timing; the same behavior as
26
+ `ostia time` ([cli.md](cli.md#ostia-time)).
27
27
 
28
28
  ```ts
29
29
  const controller = new AbortController()
@@ -73,11 +73,11 @@ A `RegExp` `timeSource` pattern must not have the `g`, `y` or `d` flag;
73
73
  `time()` rejects with a `RangeError` before running anything.
74
74
 
75
75
  A command stops at its first non-ignored non-zero exit.
76
- `time()` still resolves; check `Trial.exitCode` or the `nonzero-exit`
77
- warning.
76
+ `time()` still resolves; check `Trial.exitCode`
77
+ or the `nonzero-exit` warning.
78
78
  Aborting `signal` kills in-flight children and resolves with the
79
- measurements completed so far, the last one carrying an `aborted`
80
- warning.
79
+ measurements completed so far, the last one carrying an
80
+ `aborted` warning.
81
81
 
82
82
  ## `profile(fn, opts?)` → `Promise<{ result, measurement, document }>`
83
83
 
@@ -165,7 +165,7 @@ and resolves with the suites and tasks that had finished.
165
165
  | `budgetMs`, `samples`, `minSamples` | Override the suite-wide sampling settings for this task. |
166
166
  | `isolate`, `gc`, `cpu`, `alloc`, `peakMem` | Override the suite-wide flag (and the group's) for this task. |
167
167
  | `baseline` | This task is the group's Relative reference (default: the group's fastest). |
168
- | `description` | Stored as `Workload.description` and shown in `minimal` output. |
168
+ | `description` | Stored as `Workload.description` and shown in `events` output. |
169
169
  | `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
170
  | `params` | Structured parameters; part of the workload id. Merged over the current `sweep()` point. |
171
171
  | `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 +247,8 @@ task("parse then validate", () => {
247
247
 
248
248
  `sweep()` calls `fn` once per point of the Cartesian product of `dims`;
249
249
  `task()` calls inside inherit the point as `params`,
250
- so each point is its own workload and `compare` matches points across
251
- runs.
250
+ so each point is its own workload and `compare` matches points
251
+ across runs.
252
252
 
253
253
  ```ts
254
254
  group("parse", () => {
@@ -376,12 +376,14 @@ const doc = createDocument(
376
376
 
377
377
  Each renderer is `{ name, render(doc, options) }` returning `{ text? }`
378
378
  and/or `{ files? }`.
379
- Names: `table`, `markdown`, `json`, `jsonl`, `minimal`, `collapsed`,
379
+ Names: `table`, `markdown`, `json`, `jsonl`,
380
+ `events` (and `minimal`, its name until 0.5.0), `concise`, `collapsed`,
380
381
  `mermaid`, `speedscope`, `cpuprofile`.
381
382
  Each renderer's options are typed per format:
382
383
  `collapsed`, `speedscope` and `cpuprofile` take `VizOptions`
383
384
  (`{ measurementId? }`), `mermaid` takes `MermaidOptions`
384
- (`VizOptions` plus `topN?`), `minimal` takes `MinimalRenderOptions`
385
+ (`VizOptions` plus `topN?`), `events`
386
+ and `minimal` take `MinimalRenderOptions`
385
387
  (`{ protocol? }`, a `MinimalProtocolContext`, to emit the `unmatched`
386
388
  and `summary` events), and the rest take no options (pass `{}`).
387
389
 
@@ -400,8 +402,8 @@ const { files } = await renderers.speedscope.render(doc, { measurementId })
400
402
 
401
403
  ## `defineConfig(config)`
402
404
 
403
- Returns its argument unchanged; it exists to type-check
404
- `ostia.config.ts`.
405
+ Returns its argument unchanged; it exists to
406
+ type-check `ostia.config.ts`.
405
407
  See [config.md](config.md).
406
408
 
407
409
  ## Coming from mitata or hyperfine
@@ -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 does
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 suite-file
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.