ostia 0.3.1 → 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.
- package/README.md +4 -4
- package/docs/agent-protocol.md +13 -9
- package/docs/cli.md +90 -73
- package/docs/config.md +2 -2
- package/docs/document-schema.md +14 -12
- package/docs/library.md +17 -15
- package/docs/preload-recipes.md +4 -4
- package/docs/statistics.md +10 -10
- package/index.d.ts +197 -126
- package/package.json +1 -1
- package/src/ab/ab-runner.ts +6 -6
- package/src/ab/index.ts +15 -6
- package/src/bench/index.ts +12 -3
- package/src/bench/registry.ts +9 -7
- package/src/bench/run-tasks.ts +2 -2
- package/src/bench/runner.ts +2 -2
- package/src/bench/support.ts +8 -4
- package/src/bench/sweep.ts +3 -3
- 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 +7 -6
- package/src/cli/agent.ts +54 -0
- package/src/cli/flags.ts +50 -9
- package/src/cli/help.ts +29 -11
- package/src/cli/output.ts +6 -3
- package/src/cli/run.ts +29 -5
- 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 +18 -1
- package/src/ir/document.ts +2 -2
- package/src/ir/types.ts +50 -27
- 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 +18 -3
- 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/index.ts +6 -0
- package/src/renderers/markdown.ts +2 -2
- package/src/renderers/mermaid.ts +2 -2
- package/src/renderers/minimal.ts +11 -10
- package/src/renderers/relative.ts +2 -2
- package/src/renderers/select.ts +2 -2
- package/src/renderers/terminal.ts +6 -3
- 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/time.ts +75 -10
package/index.d.ts
CHANGED
|
@@ -31,15 +31,19 @@ export interface AbOptions {
|
|
|
31
31
|
outDir?: string;
|
|
32
32
|
cwd?: string;
|
|
33
33
|
noiseCheck?: boolean;
|
|
34
|
+
/** Sample the noise floor for exactly this many ms instead. */
|
|
35
|
+
noiseBudgetMs?: number;
|
|
34
36
|
/** Also compare each side's retained heap per call (see
|
|
35
37
|
* `bench({ alloc })`) and how far its first call raises RSS (see
|
|
36
38
|
* `bench({ peakMem })`), each the median of 3 fresh processes per side.
|
|
37
39
|
* Task/group options override these. */
|
|
38
40
|
alloc?: boolean;
|
|
39
41
|
peakMem?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
42
|
+
/**
|
|
43
|
+
* Flag a memory reading that moves past this many percent of the base's
|
|
44
|
+
* and past its noise floor (default: 10). A memory regression fails
|
|
45
|
+
* the run.
|
|
46
|
+
*/
|
|
43
47
|
memThresholdPct?: number;
|
|
44
48
|
/** Shell commands run once, in order, in a freshly extracted base tree
|
|
45
49
|
* before it's used: to build what the suites import but git doesn't hold
|
|
@@ -64,8 +68,9 @@ export interface AbOptions {
|
|
|
64
68
|
onProgress?: (progress: AbProgress) => void;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
|
-
* Launch settings for the suite files matching `suites`;
|
|
68
|
-
* `BenchOptions.projects`.
|
|
71
|
+
* Launch settings for the suite files matching `suites`;
|
|
72
|
+
* see `BenchOptions.projects`.
|
|
73
|
+
*/
|
|
69
74
|
export interface BenchProject {
|
|
70
75
|
/**
|
|
71
76
|
* Globs against the current directory. A suite file takes the first
|
|
@@ -106,7 +111,7 @@ export type AbProgress = {
|
|
|
106
111
|
side: Side;
|
|
107
112
|
label: string;
|
|
108
113
|
};
|
|
109
|
-
type Side = "base" | "cand";
|
|
114
|
+
export type Side = "base" | "cand";
|
|
110
115
|
/** Paired A/B timing of suite files against a git ref: every task runs on
|
|
111
116
|
* the ref's committed tree (base) and the working tree (candidate) in one
|
|
112
117
|
* process, alternating short batches, and is judged on the per-round time
|
|
@@ -143,17 +148,28 @@ export interface ProfileDocument {
|
|
|
143
148
|
* `comparisons` is. */
|
|
144
149
|
compared?: ComparedTask[];
|
|
145
150
|
/**
|
|
146
|
-
* Machine conditions at measurement time; absent when the noise check
|
|
147
|
-
* skipped.
|
|
151
|
+
* Machine conditions at measurement time; absent when the noise check
|
|
152
|
+
* was skipped.
|
|
153
|
+
*/
|
|
148
154
|
environment?: Environment;
|
|
149
155
|
/**
|
|
150
|
-
*
|
|
151
|
-
* `
|
|
156
|
+
* The shell `time({ shell })` ran each string command through, and its
|
|
157
|
+
* startup (`shell -c :`, median wall time, ns), which the timings include
|
|
158
|
+
* and nothing subtracts. Absent without a shell. */
|
|
159
|
+
shell?: {
|
|
160
|
+
command: string;
|
|
161
|
+
startupNs: number;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Run-level result of `ostia ab` / `ab()`, whose measurements
|
|
165
|
+
* are `phase: "paired"`.
|
|
166
|
+
*/
|
|
152
167
|
ab?: AbSummary;
|
|
153
168
|
/**
|
|
154
169
|
* Repo state of the process's cwd; absent outside a git repo. Never part
|
|
155
|
-
* of an id or fingerprint, so a commit or dirty tree doesn't orphan
|
|
156
|
-
* baseline.
|
|
170
|
+
* of an id or fingerprint, so a commit or dirty tree doesn't orphan
|
|
171
|
+
* a baseline.
|
|
172
|
+
*/
|
|
157
173
|
git?: GitMetadata;
|
|
158
174
|
}
|
|
159
175
|
export interface Workload {
|
|
@@ -212,7 +228,7 @@ export interface Workload {
|
|
|
212
228
|
* `unchanged` with a `skipped` warning. */
|
|
213
229
|
skipped?: boolean;
|
|
214
230
|
}
|
|
215
|
-
interface Measurement {
|
|
231
|
+
export interface Measurement {
|
|
216
232
|
id: string;
|
|
217
233
|
workloadId: string;
|
|
218
234
|
phase: Phase;
|
|
@@ -253,6 +269,8 @@ type Phase = "timing" | "cpu" | "heap" | "memstats" | "paired";
|
|
|
253
269
|
interface Trial {
|
|
254
270
|
i: number;
|
|
255
271
|
wallNs: number;
|
|
272
|
+
/** The file `--save-output` wrote this trial's stdout and stderr to. */
|
|
273
|
+
outputPath?: string;
|
|
256
274
|
/**
|
|
257
275
|
* The command's self-reported time (ns) under a `timeSource`; these, not
|
|
258
276
|
* `wallNs`, are then the `timing.samples`. */
|
|
@@ -338,8 +356,9 @@ interface MemoryEvidence {
|
|
|
338
356
|
origin: "resourceUsage" | "heapStats";
|
|
339
357
|
/**
|
|
340
358
|
* `memstats` only: `"retained"` (`--alloc`, `bytesPerOp`) or `"peak"`
|
|
341
|
-
* (`--peak-mem`, `peakBytes`). Absent means `"retained"` on
|
|
342
|
-
* documents.
|
|
359
|
+
* (`--peak-mem`, `peakBytes`). Absent means `"retained"` on
|
|
360
|
+
* older documents.
|
|
361
|
+
*/
|
|
343
362
|
kind?: "retained" | "peak";
|
|
344
363
|
/** Largest `Trial.maxRssBytes` across a timing measurement's trials. */
|
|
345
364
|
maxRssBytes?: number;
|
|
@@ -385,7 +404,7 @@ interface InstructionStats {
|
|
|
385
404
|
/**
|
|
386
405
|
* Evidence of a `phase: "paired"` measurement: base and candidate
|
|
387
406
|
* alternate in batches in one process, so drift cancels in the ratio. */
|
|
388
|
-
interface PairedEvidence {
|
|
407
|
+
export interface PairedEvidence {
|
|
389
408
|
/** One base batch and one candidate batch per round, alternating order. */
|
|
390
409
|
rounds: number;
|
|
391
410
|
/** Calls per side per round. */
|
|
@@ -410,8 +429,9 @@ interface PairedEvidence {
|
|
|
410
429
|
* side of 1 in at least three quarters of rounds. */
|
|
411
430
|
flagged?: "regressed" | "improved";
|
|
412
431
|
/**
|
|
413
|
-
* Each fresh-process re-measurement of a flagged workload; `flagged`
|
|
414
|
-
* `AbSummary.metric`.
|
|
432
|
+
* Each fresh-process re-measurement of a flagged workload; `flagged`
|
|
433
|
+
* by `AbSummary.metric`.
|
|
434
|
+
*/
|
|
415
435
|
repeats?: {
|
|
416
436
|
medianRatio: number;
|
|
417
437
|
ratioP25: number;
|
|
@@ -482,10 +502,10 @@ export interface Warning {
|
|
|
482
502
|
}
|
|
483
503
|
export type WarningCode = (typeof WARNING_CODES)[number];
|
|
484
504
|
/**
|
|
485
|
-
* Every `Warning.code`. A runtime array so a test can assert each
|
|
486
|
-
* emitted.
|
|
505
|
+
* Every `Warning.code`. A runtime array so a test can assert each
|
|
506
|
+
* is emitted.
|
|
487
507
|
*/
|
|
488
|
-
declare const WARNING_CODES: readonly [
|
|
508
|
+
export declare const WARNING_CODES: readonly [
|
|
489
509
|
"slow-first-run",
|
|
490
510
|
"outliers-detected",
|
|
491
511
|
"fast-command",
|
|
@@ -529,8 +549,8 @@ export interface Comparison {
|
|
|
529
549
|
verdict: "improved" | "regressed" | "unchanged";
|
|
530
550
|
};
|
|
531
551
|
/**
|
|
532
|
-
* Caveats about this comparison, e.g. a thin-sample
|
|
533
|
-
* verdict.
|
|
552
|
+
* Caveats about this comparison, e.g. a thin-sample
|
|
553
|
+
* point-estimate verdict.
|
|
534
554
|
*/
|
|
535
555
|
warnings?: Warning[];
|
|
536
556
|
frames?: {
|
|
@@ -556,15 +576,15 @@ export interface Comparison {
|
|
|
556
576
|
alpha: number;
|
|
557
577
|
bootstrapIterations: number;
|
|
558
578
|
/**
|
|
559
|
-
* `max(timingPct, both documents' noise floors)`: what timing was
|
|
560
|
-
* against.
|
|
579
|
+
* `max(timingPct, both documents' noise floors)`: what timing was
|
|
580
|
+
* tested against.
|
|
561
581
|
*/
|
|
562
582
|
effectiveTimingPct: number;
|
|
563
583
|
};
|
|
564
584
|
verdict: "pass" | "fail";
|
|
565
585
|
}
|
|
566
586
|
/** Aggregate view over a `compareDocuments` call's `Comparison[]`. */
|
|
567
|
-
interface ComparisonSummary {
|
|
587
|
+
export interface ComparisonSummary {
|
|
568
588
|
/** `comparisons.length`. */
|
|
569
589
|
matched: number;
|
|
570
590
|
regressed: number;
|
|
@@ -591,7 +611,7 @@ interface ComparisonSummary {
|
|
|
591
611
|
* One task of a `compare`/`ci` run: matched on both sides, or present on
|
|
592
612
|
* only one (`missing-base`: new, or renamed without an alias;
|
|
593
613
|
* `missing-cand`: removed, or renamed). Times in ns, memory in bytes. */
|
|
594
|
-
interface ComparedTask {
|
|
614
|
+
export interface ComparedTask {
|
|
595
615
|
/** The candidate's workload id; the base's on a `missing-cand` task. */
|
|
596
616
|
workloadId: string;
|
|
597
617
|
/** Display name: the label, else the command, else the id. */
|
|
@@ -635,14 +655,15 @@ interface ComparedTask {
|
|
|
635
655
|
interface MemoryDelta {
|
|
636
656
|
/**
|
|
637
657
|
* `heapUsedBefore`/`heapUsedAfter`: in-process heap around the timing
|
|
638
|
-
* run; `retained`: `--alloc`; `peak`: `--peak-mem`; `maxRss`:
|
|
639
|
-
* timing.
|
|
658
|
+
* run; `retained`: `--alloc`; `peak`: `--peak-mem`; `maxRss`:
|
|
659
|
+
* subprocess timing.
|
|
660
|
+
*/
|
|
640
661
|
reading: "heapUsedBefore" | "heapUsedAfter" | "retained" | "peak" | "maxRss";
|
|
641
662
|
baseBytes: number;
|
|
642
663
|
candBytes: number;
|
|
643
664
|
deltaPct: number;
|
|
644
665
|
}
|
|
645
|
-
interface Environment {
|
|
666
|
+
export interface Environment {
|
|
646
667
|
cpuModel: string;
|
|
647
668
|
cores: number;
|
|
648
669
|
loadAvg1: number;
|
|
@@ -656,6 +677,14 @@ interface NoiseFloor {
|
|
|
656
677
|
floorPct: number;
|
|
657
678
|
referenceMedianNs: number;
|
|
658
679
|
samples: number;
|
|
680
|
+
/**
|
|
681
|
+
* How long the check sampled, in milliseconds: 25 to 50 by default, as
|
|
682
|
+
* long as the median took to hold. Absent in older documents. */
|
|
683
|
+
checkMs?: number;
|
|
684
|
+
/**
|
|
685
|
+
* The fixed budget `--noise-budget` asked for, in milliseconds; absent
|
|
686
|
+
* for the default, adaptive check. */
|
|
687
|
+
budgetMs?: number;
|
|
659
688
|
/**
|
|
660
689
|
* How much slower (positive) the reference ran at the end of the run than
|
|
661
690
|
* at the start, percent: the machine's drift over the run. Absent when the
|
|
@@ -663,7 +692,7 @@ interface NoiseFloor {
|
|
|
663
692
|
driftPct?: number;
|
|
664
693
|
}
|
|
665
694
|
/** Run-level result of `ab()`, stamped on the document as `ab`. */
|
|
666
|
-
interface AbSummary {
|
|
695
|
+
export interface AbSummary {
|
|
667
696
|
base: {
|
|
668
697
|
ref: string;
|
|
669
698
|
sha: string;
|
|
@@ -686,15 +715,17 @@ interface AbSummary {
|
|
|
686
715
|
improved: number;
|
|
687
716
|
unchanged: number;
|
|
688
717
|
/**
|
|
689
|
-
* Flagged in-process, but a fresh-process repeat disagreed; counted
|
|
690
|
-
* `unchanged`.
|
|
718
|
+
* Flagged in-process, but a fresh-process repeat disagreed; counted
|
|
719
|
+
* in `unchanged`.
|
|
720
|
+
*/
|
|
691
721
|
unconfirmed: number;
|
|
692
722
|
/** Workloads whose first call returned different values on each side. */
|
|
693
723
|
outputDiffers: number;
|
|
694
724
|
/**
|
|
695
725
|
* Workloads whose suite file and output both changed (see
|
|
696
|
-
* `PairedEvidence.suiteChanged`); counted in `unchanged`, left out
|
|
697
|
-
* `geomeanPct`.
|
|
726
|
+
* `PairedEvidence.suiteChanged`); counted in `unchanged`, left out
|
|
727
|
+
* of `geomeanPct`.
|
|
728
|
+
*/
|
|
698
729
|
notComparable: number;
|
|
699
730
|
/**
|
|
700
731
|
* Workloads that threw on either side or both, and so weren't timed;
|
|
@@ -719,7 +750,7 @@ interface AbSummary {
|
|
|
719
750
|
* any task's memory regressed. */
|
|
720
751
|
verdict: "pass" | "fail";
|
|
721
752
|
}
|
|
722
|
-
interface GitMetadata {
|
|
753
|
+
export interface GitMetadata {
|
|
723
754
|
sha: string;
|
|
724
755
|
branch: string;
|
|
725
756
|
dirty: boolean;
|
|
@@ -730,7 +761,7 @@ export declare class AbBaseError extends OstiaUsageError {
|
|
|
730
761
|
/** The caller's input can't be run as given (missing suite, bad ref, absent
|
|
731
762
|
* baseline): the CLI reports it as a usage error (exit 2) rather than an
|
|
732
763
|
* internal failure. */
|
|
733
|
-
declare class OstiaUsageError extends Error {
|
|
764
|
+
export declare class OstiaUsageError extends Error {
|
|
734
765
|
}
|
|
735
766
|
/** A `baseSetup` command exited non-zero or timed out. The message names
|
|
736
767
|
* the command and ends with the tail of its output. */
|
|
@@ -806,6 +837,8 @@ export interface BenchOptions {
|
|
|
806
837
|
* Measure this machine's noise floor once, before any suite runs
|
|
807
838
|
* (default: true), and stamp it on the document as `environment`. */
|
|
808
839
|
noiseCheck?: boolean;
|
|
840
|
+
/** Sample the noise floor for exactly this many ms instead. */
|
|
841
|
+
noiseBudgetMs?: number;
|
|
809
842
|
/**
|
|
810
843
|
* SIGKILLs a suite file's subprocess (or, under `isolate`, one task's)
|
|
811
844
|
* that hasn't finished after this many ms. No default. */
|
|
@@ -869,7 +902,7 @@ export interface GroupOptions {
|
|
|
869
902
|
after?: Hook;
|
|
870
903
|
}
|
|
871
904
|
/** A task body or hook; it may return a promise, which the runner awaits. */
|
|
872
|
-
type Hook = () => unknown;
|
|
905
|
+
export type Hook = () => unknown;
|
|
873
906
|
export interface TaskOptions {
|
|
874
907
|
/**
|
|
875
908
|
* Marks this task as the Relative reference for its group in the table
|
|
@@ -892,8 +925,9 @@ export interface TaskOptions {
|
|
|
892
925
|
aliases?: string[];
|
|
893
926
|
/**
|
|
894
927
|
* What this task measures and why. Flows into `Workload.description` so
|
|
895
|
-
* the intent travels with the numbers instead of living only in a
|
|
896
|
-
* comment.
|
|
928
|
+
* the intent travels with the numbers instead of living only in a
|
|
929
|
+
* source comment.
|
|
930
|
+
*/
|
|
897
931
|
description?: string;
|
|
898
932
|
/**
|
|
899
933
|
* Give this task its own subprocess instead of sharing its suite file's,
|
|
@@ -941,13 +975,12 @@ export interface TaskOptions {
|
|
|
941
975
|
* process/no-per-trial caveats as `before`. */
|
|
942
976
|
after?: Hook;
|
|
943
977
|
}
|
|
944
|
-
|
|
945
|
-
export declare const group: GroupFn;
|
|
946
|
-
interface GroupFn extends GroupRegistrar {
|
|
978
|
+
export interface GroupFn extends GroupRegistrar {
|
|
947
979
|
/**
|
|
948
980
|
* Registers every task inside as skipped: the runner never measures
|
|
949
|
-
* them, but the document still carries their workloads
|
|
950
|
-
* `Workload.skipped`).
|
|
981
|
+
* them, but the document still carries their workloads
|
|
982
|
+
* (marked `Workload.skipped`).
|
|
983
|
+
*/
|
|
951
984
|
skip: GroupRegistrar;
|
|
952
985
|
/**
|
|
953
986
|
* When any task or group in the suite uses `.only`, the runner restricts
|
|
@@ -956,9 +989,7 @@ interface GroupFn extends GroupRegistrar {
|
|
|
956
989
|
only: GroupRegistrar;
|
|
957
990
|
}
|
|
958
991
|
type GroupRegistrar = (name: string, fn: () => void, opts?: GroupOptions) => void;
|
|
959
|
-
|
|
960
|
-
export declare const task: TaskFn;
|
|
961
|
-
interface TaskFn extends TaskRegistrar {
|
|
992
|
+
export interface TaskFn extends TaskRegistrar {
|
|
962
993
|
/**
|
|
963
994
|
* Registers the task as skipped: the runner never measures it, but the
|
|
964
995
|
* document still carries its workload (marked `Workload.skipped`) so a
|
|
@@ -972,15 +1003,11 @@ interface TaskFn extends TaskRegistrar {
|
|
|
972
1003
|
only: TaskRegistrar;
|
|
973
1004
|
}
|
|
974
1005
|
type TaskRegistrar = (name: string, fn: Hook, opts?: TaskOptions) => void;
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
/** Renderer used for the printed report (default: `"table"`). */
|
|
981
|
-
format?: FormatName;
|
|
982
|
-
}
|
|
983
|
-
interface MeasureTasksOpts extends InprocessTimingOptions {
|
|
1006
|
+
/** Registers the tasks `fn` declares under the group `name`. */
|
|
1007
|
+
export declare const group: GroupFn;
|
|
1008
|
+
/** Registers `fn` as a benchmark task named `name` in the current group. */
|
|
1009
|
+
export declare const task: TaskFn;
|
|
1010
|
+
export interface MeasureTasksOpts extends InprocessTimingOptions {
|
|
984
1011
|
/**
|
|
985
1012
|
* Suite-wide default for capturing an extra `phase: "cpu"` measurement per
|
|
986
1013
|
* task (task/group `cpu` still wins). */
|
|
@@ -1006,13 +1033,25 @@ interface InprocessTimingOptions {
|
|
|
1006
1033
|
/** Keep sampling past the budget until this many trials exist. When unset
|
|
1007
1034
|
* the floor is cost-aware (see `defaultSampleFloor`). */
|
|
1008
1035
|
minSamples?: number;
|
|
1009
|
-
/**
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1036
|
+
/**
|
|
1037
|
+
* Warmup budget as a fraction of `budgetMs` (default: 0.1); unlike
|
|
1038
|
+
* `time()`'s `warmup`, which is a trial count. Always runs at least
|
|
1039
|
+
* one call.
|
|
1040
|
+
*/
|
|
1012
1041
|
warmup?: number;
|
|
1013
1042
|
gc?: boolean;
|
|
1014
1043
|
}
|
|
1015
|
-
|
|
1044
|
+
export interface RunOptions extends MeasureTasksOpts {
|
|
1045
|
+
/** Regex matched against "group/name" task ids, as in `bench({ filter })`. */
|
|
1046
|
+
filter?: string;
|
|
1047
|
+
/** Skip printing the report to stdout; still returns the document. */
|
|
1048
|
+
quiet?: boolean;
|
|
1049
|
+
/** Renderer used for the printed report (default: `"table"`). */
|
|
1050
|
+
format?: FormatName;
|
|
1051
|
+
}
|
|
1052
|
+
export type FormatName = "table" | "json" | "markdown" | "jsonl" | "events"
|
|
1053
|
+
/** `events`, by the name it had until 0.5.0. */
|
|
1054
|
+
| "minimal" | "concise" | "collapsed" | "mermaid" | "speedscope" | "cpuprofile";
|
|
1016
1055
|
/** In-file entrypoint: call at the bottom of a suite file run directly with
|
|
1017
1056
|
* `bun suite.ts` to measure every registered `group()`/`task()`, print a
|
|
1018
1057
|
* report, and return the document.
|
|
@@ -1021,6 +1060,9 @@ type FormatName = "table" | "json" | "markdown" | "jsonl" | "minimal" | "collaps
|
|
|
1021
1060
|
* ignored. Prefer `ostia bench`/`bench()` for numbers you'll
|
|
1022
1061
|
* `compare`/`ci` against. */
|
|
1023
1062
|
export declare function run(opts?: RunOptions): Promise<ProfileDocument>;
|
|
1063
|
+
export type SweepPoint<T extends Record<string, readonly unknown[]>> = {
|
|
1064
|
+
[K in keyof T]: T[K][number];
|
|
1065
|
+
};
|
|
1024
1066
|
/** Cartesian product over `dims`, calling `fn` once per point. Inside `fn`,
|
|
1025
1067
|
* `task()` calls automatically inherit the point as their params (an
|
|
1026
1068
|
* explicit `TaskOptions.params` merges over it, explicit keys win):
|
|
@@ -1033,9 +1075,6 @@ export declare function run(opts?: RunOptions): Promise<ProfileDocument>;
|
|
|
1033
1075
|
* })
|
|
1034
1076
|
*/
|
|
1035
1077
|
export declare function sweep<T extends Record<string, readonly unknown[]>>(dims: T, fn: (point: SweepPoint<T>) => void): void;
|
|
1036
|
-
type SweepPoint<T extends Record<string, readonly unknown[]>> = {
|
|
1037
|
-
[K in keyof T]: T[K][number];
|
|
1038
|
-
};
|
|
1039
1078
|
export interface CompareResult {
|
|
1040
1079
|
comparisons: Comparison[];
|
|
1041
1080
|
unmatched: {
|
|
@@ -1079,8 +1118,9 @@ export interface AbConfig {
|
|
|
1079
1118
|
* `--base-setup` replaces this list. */
|
|
1080
1119
|
setup?: string | string[];
|
|
1081
1120
|
/**
|
|
1082
|
-
* Base trees to keep cached; see `AbOptions.keepTrees`.
|
|
1083
|
-
* overrides. Default: 5.
|
|
1121
|
+
* Base trees to keep cached; see `AbOptions.keepTrees`.
|
|
1122
|
+
* `--keep-trees` overrides. Default: 5.
|
|
1123
|
+
*/
|
|
1084
1124
|
keepTrees?: number;
|
|
1085
1125
|
/**
|
|
1086
1126
|
* Judge rounds by `"time"` or `"instructions"`; see `AbOptions.metric`.
|
|
@@ -1100,6 +1140,41 @@ export interface AbConfig {
|
|
|
1100
1140
|
* `--mem-threshold` overrides. Default: 10. */
|
|
1101
1141
|
memThresholdPct?: number;
|
|
1102
1142
|
}
|
|
1143
|
+
export interface BenchConfig {
|
|
1144
|
+
/**
|
|
1145
|
+
* Suite file globs, resolved against the config's directory (e.g.
|
|
1146
|
+
* "bench/**\/*.bench.ts"). Suite files given on the command line replace
|
|
1147
|
+
* this list. */
|
|
1148
|
+
suites?: string[];
|
|
1149
|
+
/**
|
|
1150
|
+
* Per-suite `preload`/`bunFlags`, so one tier (e.g. DOM-dependent suites)
|
|
1151
|
+
* can pay for a setup the others don't need. The first project whose
|
|
1152
|
+
* `suites` match a file wins; a file no project matches gets the top-level
|
|
1153
|
+
* `preload`/`bunFlags`. `--preload` / `--bun-flags` replace the matching
|
|
1154
|
+
* field for every file. */
|
|
1155
|
+
projects?: BenchProject[];
|
|
1156
|
+
preload?: string[];
|
|
1157
|
+
/**
|
|
1158
|
+
* Extra flags for the `bun` process that runs each suite file; see
|
|
1159
|
+
* `BenchOptions.bunFlags`. `--bun-flags` replaces this list. */
|
|
1160
|
+
bunFlags?: string[];
|
|
1161
|
+
jobs?: number | "auto";
|
|
1162
|
+
budgetMs?: number;
|
|
1163
|
+
samples?: number;
|
|
1164
|
+
minSamples?: number;
|
|
1165
|
+
gc?: boolean;
|
|
1166
|
+
cpu?: boolean;
|
|
1167
|
+
cpuIntervalUs?: number;
|
|
1168
|
+
alloc?: boolean;
|
|
1169
|
+
peakMem?: boolean;
|
|
1170
|
+
filter?: string;
|
|
1171
|
+
isolate?: boolean;
|
|
1172
|
+
outDir?: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* Kills a suite file's (or isolated task's) subprocess after this many
|
|
1175
|
+
* ms; overrides `ostia ci`'s 10-minute default. */
|
|
1176
|
+
timeoutMs?: number;
|
|
1177
|
+
}
|
|
1103
1178
|
export interface OstiaConfig {
|
|
1104
1179
|
/** `command` workloads: exact trial count; see `time()`. */
|
|
1105
1180
|
samples?: number;
|
|
@@ -1153,12 +1228,14 @@ export interface WorkloadConfig {
|
|
|
1153
1228
|
/**
|
|
1154
1229
|
* `command`: kills a trial (or prepare hook) after this many ms.
|
|
1155
1230
|
* `suites`: kills a suite file's (or isolated task's) process after this
|
|
1156
|
-
* many ms, overriding `bench.timeoutMs`. Overrides `ostia ci`'s
|
|
1157
|
-
* default.
|
|
1231
|
+
* many ms, overriding `bench.timeoutMs`. Overrides `ostia ci`'s
|
|
1232
|
+
* 10-minute default.
|
|
1233
|
+
*/
|
|
1158
1234
|
timeoutMs?: number;
|
|
1159
1235
|
/**
|
|
1160
|
-
* `command` only. Exit codes to treat as success;
|
|
1161
|
-
* `TimeOptions.ignoreExitCodes`.
|
|
1236
|
+
* `command` only. Exit codes to treat as success;
|
|
1237
|
+
* see `TimeOptions.ignoreExitCodes`.
|
|
1238
|
+
*/
|
|
1162
1239
|
ignoreExitCodes?: number[];
|
|
1163
1240
|
}
|
|
1164
1241
|
/**
|
|
@@ -1192,41 +1269,6 @@ export interface TimeSource {
|
|
|
1192
1269
|
unit?: TimeUnit;
|
|
1193
1270
|
}
|
|
1194
1271
|
export type TimeUnit = "ns" | "us" | "ms" | "s";
|
|
1195
|
-
interface BenchConfig {
|
|
1196
|
-
/**
|
|
1197
|
-
* Suite file globs, resolved against the config's directory (e.g.
|
|
1198
|
-
* "bench/**\/*.bench.ts"). Suite files given on the command line replace
|
|
1199
|
-
* this list. */
|
|
1200
|
-
suites?: string[];
|
|
1201
|
-
/**
|
|
1202
|
-
* Per-suite `preload`/`bunFlags`, so one tier (e.g. DOM-dependent suites)
|
|
1203
|
-
* can pay for a setup the others don't need. The first project whose
|
|
1204
|
-
* `suites` match a file wins; a file no project matches gets the top-level
|
|
1205
|
-
* `preload`/`bunFlags`. `--preload` / `--bun-flags` replace the matching
|
|
1206
|
-
* field for every file. */
|
|
1207
|
-
projects?: BenchProject[];
|
|
1208
|
-
preload?: string[];
|
|
1209
|
-
/**
|
|
1210
|
-
* Extra flags for the `bun` process that runs each suite file; see
|
|
1211
|
-
* `BenchOptions.bunFlags`. `--bun-flags` replaces this list. */
|
|
1212
|
-
bunFlags?: string[];
|
|
1213
|
-
jobs?: number | "auto";
|
|
1214
|
-
budgetMs?: number;
|
|
1215
|
-
samples?: number;
|
|
1216
|
-
minSamples?: number;
|
|
1217
|
-
gc?: boolean;
|
|
1218
|
-
cpu?: boolean;
|
|
1219
|
-
cpuIntervalUs?: number;
|
|
1220
|
-
alloc?: boolean;
|
|
1221
|
-
peakMem?: boolean;
|
|
1222
|
-
filter?: string;
|
|
1223
|
-
isolate?: boolean;
|
|
1224
|
-
outDir?: string;
|
|
1225
|
-
/**
|
|
1226
|
-
* Kills a suite file's (or isolated task's) subprocess after this many
|
|
1227
|
-
* ms; overrides `ostia ci`'s 10-minute default. */
|
|
1228
|
-
timeoutMs?: number;
|
|
1229
|
-
}
|
|
1230
1272
|
export type OstiaConfigInput = Omit<Partial<OstiaConfig>, "thresholds"> & {
|
|
1231
1273
|
thresholds?: Partial<Thresholds>;
|
|
1232
1274
|
};
|
|
@@ -1258,9 +1300,11 @@ export declare class OstiaDocumentError extends Error {
|
|
|
1258
1300
|
* truncated file.
|
|
1259
1301
|
*/
|
|
1260
1302
|
export declare function saveDocument(doc: ProfileDocument, path: string): Promise<void>;
|
|
1261
|
-
/**
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1303
|
+
/**
|
|
1304
|
+
* Pins `value` against dead-code elimination for an intermediate inside a
|
|
1305
|
+
* task body. A task's own return value is already pinned by the
|
|
1306
|
+
* timing loop.
|
|
1307
|
+
*/
|
|
1264
1308
|
export declare function keep(value: unknown): void;
|
|
1265
1309
|
export interface ProfileOptions {
|
|
1266
1310
|
/**
|
|
@@ -1270,8 +1314,9 @@ export interface ProfileOptions {
|
|
|
1270
1314
|
/**
|
|
1271
1315
|
* Names the workload: it becomes the label and, instead of the function's
|
|
1272
1316
|
* name and source, what the id hashes, so closures that differ only in
|
|
1273
|
-
* captured values get distinct ids and the id survives editing
|
|
1274
|
-
* function.
|
|
1317
|
+
* captured values get distinct ids and the id survives editing
|
|
1318
|
+
* the function.
|
|
1319
|
+
*/
|
|
1275
1320
|
name?: string;
|
|
1276
1321
|
/**
|
|
1277
1322
|
* `"inspector"` (default) captures through CDP and writes a portable
|
|
@@ -1281,8 +1326,9 @@ export interface ProfileOptions {
|
|
|
1281
1326
|
/**
|
|
1282
1327
|
* There's no child to kill, so an already-aborted signal skips the
|
|
1283
1328
|
* profiler, calls `fn` plain (still returning its `result`) and records an
|
|
1284
|
-
* `aborted` warning instead of CPU evidence. It can't interrupt a
|
|
1285
|
-
* `fn`.
|
|
1329
|
+
* `aborted` warning instead of CPU evidence. It can't interrupt a
|
|
1330
|
+
* running `fn`.
|
|
1331
|
+
*/
|
|
1286
1332
|
signal?: AbortSignal;
|
|
1287
1333
|
}
|
|
1288
1334
|
export interface ProfileResult<T> {
|
|
@@ -1300,13 +1346,16 @@ export declare const renderers: {
|
|
|
1300
1346
|
json: Renderer;
|
|
1301
1347
|
markdown: Renderer;
|
|
1302
1348
|
jsonl: Renderer;
|
|
1349
|
+
events: Renderer<MinimalRenderOptions>;
|
|
1350
|
+
/** `events`, by the name it had until 0.5.0. */
|
|
1303
1351
|
minimal: Renderer<MinimalRenderOptions>;
|
|
1352
|
+
concise: Renderer;
|
|
1304
1353
|
collapsed: Renderer<VizOptions>;
|
|
1305
1354
|
mermaid: Renderer<MermaidOptions>;
|
|
1306
1355
|
speedscope: Renderer<VizOptions>;
|
|
1307
1356
|
cpuprofile: Renderer<VizOptions>;
|
|
1308
1357
|
};
|
|
1309
|
-
interface Renderer<O = unknown> {
|
|
1358
|
+
export interface Renderer<O = unknown> {
|
|
1310
1359
|
name: FormatName;
|
|
1311
1360
|
render(doc: ProfileDocument, options: O): Promise<RenderResult>;
|
|
1312
1361
|
}
|
|
@@ -1323,8 +1372,9 @@ export interface MinimalRenderOptions {
|
|
|
1323
1372
|
/**
|
|
1324
1373
|
* What the `unmatched`/`summary` events need beyond one `ProfileDocument`.
|
|
1325
1374
|
* The CLI builds it for `compare`/`ci`/`ab`; without it `minimal` emits
|
|
1326
|
-
* only `run` lines. `exitCode` is inline because the CLI decides it
|
|
1327
|
-
* rendering.
|
|
1375
|
+
* only `run` lines. `exitCode` is inline because the CLI decides it
|
|
1376
|
+
* after rendering.
|
|
1377
|
+
*/
|
|
1328
1378
|
export interface MinimalProtocolContext {
|
|
1329
1379
|
command: "compare" | "ci" | "ab";
|
|
1330
1380
|
exitCode: number;
|
|
@@ -1356,7 +1406,7 @@ export type MinimalEvent = MinimalRunLine | MinimalUnmatchedLine | MinimalSummar
|
|
|
1356
1406
|
/**
|
|
1357
1407
|
* One per timing run, for piping into an agent's context in place of the
|
|
1358
1408
|
* full `ProfileDocument`. Numbers stay in the IR's units (ns). */
|
|
1359
|
-
interface MinimalRunLine {
|
|
1409
|
+
export interface MinimalRunLine {
|
|
1360
1410
|
event: "run";
|
|
1361
1411
|
protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
|
|
1362
1412
|
schemaVersion: ProfileDocument["schemaVersion"];
|
|
@@ -1370,8 +1420,8 @@ interface MinimalRunLine {
|
|
|
1370
1420
|
groupDescription?: string;
|
|
1371
1421
|
params?: Record<string, string | number | boolean>;
|
|
1372
1422
|
/**
|
|
1373
|
-
* `task.skip()` / `group.skip()`: no measurement, so every stats field
|
|
1374
|
-
* absent.
|
|
1423
|
+
* `task.skip()` / `group.skip()`: no measurement, so every stats field
|
|
1424
|
+
* is absent.
|
|
1375
1425
|
*/
|
|
1376
1426
|
skipped?: true;
|
|
1377
1427
|
unit?: "ns";
|
|
@@ -1495,7 +1545,7 @@ interface MinimalMemoryChange {
|
|
|
1495
1545
|
floor: number;
|
|
1496
1546
|
}
|
|
1497
1547
|
/** A workload present on only one side of a `compare`/`ci` run. */
|
|
1498
|
-
interface MinimalUnmatchedLine {
|
|
1548
|
+
export interface MinimalUnmatchedLine {
|
|
1499
1549
|
event: "unmatched";
|
|
1500
1550
|
protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
|
|
1501
1551
|
workloadId: string;
|
|
@@ -1505,7 +1555,7 @@ interface MinimalUnmatchedLine {
|
|
|
1505
1555
|
/**
|
|
1506
1556
|
* The last line of a `compare`/`ci`/`ab` run; never emitted for a bare
|
|
1507
1557
|
* `time`/`bench` document. */
|
|
1508
|
-
interface MinimalSummaryLine {
|
|
1558
|
+
export interface MinimalSummaryLine {
|
|
1509
1559
|
event: "summary";
|
|
1510
1560
|
protocolVersion: typeof MINIMAL_PROTOCOL_VERSION;
|
|
1511
1561
|
command: "compare" | "ci" | "ab";
|
|
@@ -1541,8 +1591,8 @@ interface MinimalSummaryLine {
|
|
|
1541
1591
|
/** `ab` only: the gate on `geomeanPct`. */
|
|
1542
1592
|
geomeanThresholdPct?: number;
|
|
1543
1593
|
/**
|
|
1544
|
-
* `ab` only: flagged in the first process but not reproduced; counted
|
|
1545
|
-
* `unchanged`.
|
|
1594
|
+
* `ab` only: flagged in the first process but not reproduced; counted
|
|
1595
|
+
* in `unchanged`.
|
|
1546
1596
|
*/
|
|
1547
1597
|
unconfirmed?: number;
|
|
1548
1598
|
/**
|
|
@@ -1590,6 +1640,23 @@ export interface CommandSpec {
|
|
|
1590
1640
|
}
|
|
1591
1641
|
export interface TimeOptions {
|
|
1592
1642
|
commands: (string | string[] | CommandSpec)[];
|
|
1643
|
+
/**
|
|
1644
|
+
* Run each string command, and a string `prepare`, as `shell -c COMMAND`
|
|
1645
|
+
* (`"sh"`, `"bash"`) instead of splitting it on whitespace, so env
|
|
1646
|
+
* prefixes, pipes, `&&` and `$(...)` work. An argv array runs as given.
|
|
1647
|
+
* The shell's own startup is measured and recorded as `doc.shell`,
|
|
1648
|
+
* not subtracted.
|
|
1649
|
+
*/
|
|
1650
|
+
shell?: string;
|
|
1651
|
+
/**
|
|
1652
|
+
* Save each trial's stdout and stderr under this directory, one folder
|
|
1653
|
+
* per command (its label, made safe for a path, and its id), as
|
|
1654
|
+
* `trial-N.log` and `warmup-N.log`; each trial's `outputPath` names
|
|
1655
|
+
* its file.
|
|
1656
|
+
*/
|
|
1657
|
+
saveOutput?: string;
|
|
1658
|
+
/** Pass each trial's output to stderr, for debugging. */
|
|
1659
|
+
showOutput?: boolean;
|
|
1593
1660
|
/**
|
|
1594
1661
|
* Runs unmeasured before every trial (warmup and instrumented included),
|
|
1595
1662
|
* in `cwd`/`env`: a command spawned and awaited, or a function. */
|
|
@@ -1609,8 +1676,9 @@ export interface TimeOptions {
|
|
|
1609
1676
|
warmup?: number;
|
|
1610
1677
|
/**
|
|
1611
1678
|
* Round-robin trials across commands instead of finishing each command
|
|
1612
|
-
* first, so drift hits every command equally. Default: true with
|
|
1613
|
-
* commands.
|
|
1679
|
+
* first, so drift hits every command equally. Default: true with
|
|
1680
|
+
* 2+ commands.
|
|
1681
|
+
*/
|
|
1614
1682
|
interleave?: boolean;
|
|
1615
1683
|
cwd?: string;
|
|
1616
1684
|
env?: Record<string, string>;
|
|
@@ -1619,9 +1687,11 @@ export interface TimeOptions {
|
|
|
1619
1687
|
cpuIntervalUs?: number;
|
|
1620
1688
|
outDir?: string;
|
|
1621
1689
|
/**
|
|
1622
|
-
* Measure the machine's noise floor first (default true,
|
|
1623
|
-
* it on the document as `environment`. */
|
|
1690
|
+
* Measure the machine's noise floor first (default true, 25 to 50 ms) and
|
|
1691
|
+
* stamp it on the document as `environment`. */
|
|
1624
1692
|
noiseCheck?: boolean;
|
|
1693
|
+
/** Sample the noise floor for exactly this many ms instead. */
|
|
1694
|
+
noiseBudgetMs?: number;
|
|
1625
1695
|
/**
|
|
1626
1696
|
* SIGKILLs a trial (or prepare hook) still running after this many ms. No
|
|
1627
1697
|
* default. A timed-out trial contributes no sample. */
|
|
@@ -1641,3 +1711,4 @@ export interface TimeOptions {
|
|
|
1641
1711
|
export declare function time(opts: TimeOptions): Promise<ProfileDocument>;
|
|
1642
1712
|
/** Identity function that types an `ostia.config.ts` default export. */
|
|
1643
1713
|
export declare function defineConfig(config: OstiaConfigInput): OstiaConfigInput;
|
|
1714
|
+
export {};
|