@mark1russell7/harness 0.16.18 → 0.16.20

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 CHANGED
@@ -44,6 +44,10 @@ The folder `vm/`, the file `src/vm.ts` and the workflow `vm.yml` operate a lab i
44
44
 
45
45
  `runCells` in that file is the one command of the cells for the runner and for a guest. Rule 3 of that document pairs the two in one job. A guest cannot read its runner, thus the runner gives its host in `LAB_RUNNER`. `substrateHere` writes E4 with that cloud and image, and with the kernel and HZ of the guest. A run also records `steal`, the share of the CPU that the host took (`stealShare`). A guest sees only the host above it, thus this number does not show the layer below a hosted runner.
46
46
 
47
+ The command `run` of `src/vm.ts` and the workflow `vm-run.yml` operate one command of another repository in the guest (SYS-136). The guest copies a folder of the caller to `/work`, with no `node_modules`, and installs it from its lockfile. The argv starts in `/work` when Docker is ready. It writes its output to `/out`, and `/out` comes back to the runner, also after a failure.
48
+
49
+ After the time limit, each process of the argv stops. The file `run.json` in `/out` tells why the run ended, the exit code and the kernel of the guest. A consumer adds one job that uses `vm-run.yml` at a commit of this repository. One file, `vm/linux.json`, pins the kernel for `vm.yml` and `vm-run.yml`.
50
+
47
51
  ## The topologies
48
52
 
49
53
  A topology (`Topology`) is the chain of hops from the client to the target, as data. Each hop is on two networks, one for each side. Network j joins element j and element j + 1: the client is element 0, and the target is the last element.
@@ -250,7 +254,7 @@ console.log(used.cpu?.total, used.network?.tx.bytes, used.memory.peak, reader.se
250
254
  - `Cell.clientLimits` gives the limits of the client in each run, for example other CPUs than the target.
251
255
  - `Cell.resources` starts a reader of the target in each run, with these options. The reader stops at the end of the run.
252
256
  - Each run then keeps `Run.resources`. It has a reading when the client is ready and before it sends (`start`). It also has a reading after the run ended (`end`), and the series of the reader.
253
- - `environmentProblems` names each problem of the limits of the target and of the client, before a lab opens.
257
+ - `environmentProblems` names each problem of the limits of the target and of the client, before a lab opens. It also names each bad value of the connections of a load stream.
254
258
 
255
259
  ## The subjects
256
260
 
@@ -289,7 +293,14 @@ From 0.11.20, the harness builds each image with the CLI of Docker (`docker buil
289
293
  - the kernel program of the prober, compiled against the BTF of the kernel that builds it, and its Rust collector.
290
294
  - `client`, the TCP client of a cell. Rust's `std::net` sets no socket option by itself, thus the measurement gets the timers of the namespace. The client also samples `TCP_INFO` each 2 ms, a second vantage on its socket. It waits in `poll()`, which does not lock the socket. A keepalive timer that finds its socket held tries again HZ/20 later.
291
295
  - In a stream, a reply of the `client` is whole at its CRLF, or after the length of a bulk string. The client then writes a `replied` line.
292
- - `load`, the open-loop driver of an HTTP/1.1 server (SYS-93). Its plan (`systems-load/1`) is a list of streams, each with a key, a schedule (`rigor-schedule/1`) and its requests. Each stream has its own connection, thus a slow reply delays only its own stream. A send does not wait for a reply. A response is whole after its `Content-Length` or its last chunk. The `sent` and `replied` lines name the stream (`k`) and the arrival (`i`), and a `replied` line names the status.
296
+ - `load`, the open-loop driver of an HTTP/1.1 server (SYS-93). Its plan (`systems-load/1`) is a list of streams, each with a key, a schedule (`rigor-schedule/1`) and its requests. Each stream has its own connections, thus a slow reply delays only its own stream. A send does not wait for a reply. A response is whole after its `Content-Length` or its last chunk. The `sent` and `replied` lines name the stream (`k`) and the arrival (`i`), and a `replied` line names the status.
297
+ - The field `connections` of a stream (`LoadConnections`) sets how its arrivals go to the server. A plan with no such field gives the same lines as before.
298
+ - `{ mode: "pipeline" }` is the default. The stream has one connection, and each arrival goes at its time also when the replies before it are not in. The replies come in the order of the requests. Thus a slow reply delays each reply after it on the stream.
299
+ - `{ mode: "pool", size }` keeps `size` connections, from 1 to 1024, each with one request in flight at most. The driver opens them before `ready`. A due arrival takes the connection that is idle for the longest time. With no idle connection, it waits in a queue of its stream.
300
+ - `{ mode: "fresh" }` opens a new connection for each arrival at its time, and closes it after the reply. The connect does not block the other streams. A failed connect is an `error` line of that arrival only, and the stream goes on.
301
+ - A run of a cell with a pool or a fresh stream ends at `done` or at the deadline (`loadEnds`). An `error` or an `eof` of one connection does not end it.
302
+ - In a pool and in a fresh stream, each `replied` line names the arrival of its own connection. Thus the replies can come out of order. The `sent` line comes at the write and gives the wait for the connection in ns (`wait`). That wait is not a lag of the driver: `streamsLoadOf` takes it out of the lag. The latency still counts from the planned time.
303
+ - A fresh stream leaves each closed connection in TIME_WAIT on the client, thus a high rate can use all the local ports. A pool needs a keep-alive time of the server above the idle time of each connection.
293
304
  - `resources`, the reader of the resources of a container. `read` prints one JSON line with the text of each file of a cgroup and of `/proc/net/dev`, between two monotonic stamps. `watch` prints one line each period. Each line of a series has its place on the clock from the start of the series. Thus a slow reading does not move the later ones.
294
305
  - `inject`, which applies a fault in one `iptables-restore` commit, with monotonic stamps around the commit. Thus the start of a fault is known in the VM. A `docker exec` from Windows comes 190 ms late at the median. With `--via DEV`, the rules go in the FORWARD chain, on the device toward one side. `--protocol` and `--handshake pass` change the match of a rule, and `inject silence` drops each packet of its namespace.
295
306
  - `inject` also sends a signal to a process by its name (`signal`), and one command to a server of the Redis protocol (`resp`). Stamps bracket each.
@@ -640,4 +651,12 @@ The tests of `resources.ts` read recorded texts of the files of a cgroup and of
640
651
  - The readings of the client are the control. Its CPU time is less than half of the burn, and its namespace sent less than 10 % of the bytes. Thus a reader of the wrong container fails the test.
641
652
  - After the end of the client, a reading of its series has null for each value of its cgroup, and a `read()` throws.
642
653
 
654
+ `HARNESS_LOAD=1` starts the proof of the connection modes of the client `load` on real containers, in the workflow `load.yml`. A Node server numbers each connection and counts the requests in its handlers on each connection. Six streams each send 40 arrivals, 50 ms apart.
655
+
656
+ - Each stream sends each arrival and gets each reply, and it keeps its schedule within 50 ms. The server starts each request after its `sent` line and ends it before its `replied` line.
657
+ - A pipeline with a wait of 100 ms has one connection with two requests or more in flight. Node runs the handlers of pipelined requests at the same time, thus the 90th percentile of the latency stays below 200 ms.
658
+ - A pool of 8 has one request at most on each connection, and the 90th percentile of the latency is below 200 ms. A fresh stream has 40 connections and a `wait` from 0 to 50 ms for each.
659
+ - A pool of 1 makes a queue: the last latency is 1.5 s or more, and the median service time is from 100 to 150 ms. The send of the last arrivals is 1 s late or more, but the lag without the wait stays below 50 ms.
660
+ - Two streams send a slow request of 300 ms and a fast request of 10 ms in turn. On a pipeline, the median latency of the fast requests is 200 ms or more. On a pool of 8, it is below 100 ms, and some fast replies come before the slow reply before them.
661
+
643
662
  `pnpm --filter @mark1russell7/harness build` writes the package for npm into `build/`.
@@ -1344,9 +1344,27 @@ interface LoadPlan {
1344
1344
  readonly options: ScheduleOptions;
1345
1345
  }
1346
1346
  /**
1347
- * A load stream is one connection of the client `load`: its key, its schedule and its requests.
1348
- * Arrival i sends request i modulo the count of requests. Each stream has its own connection, thus
1349
- * a slow stream does not delay the arrivals of another stream.
1347
+ * Load connections tell how the client `load` sends the arrivals of one stream to the server.
1348
+ * - `pipeline` is the default. The stream has one connection, and each arrival goes at its time,
1349
+ * also when the replies before it are not in. The server can read the requests of a connection
1350
+ * one at a time, and one read can hold several requests.
1351
+ * - `pool` keeps `size` connections, each with one request in flight at most. A due arrival with no
1352
+ * idle connection waits for one. That wait is not a lag of the client.
1353
+ * - `fresh` opens a new connection for each arrival at its time, and closes it after the reply.
1354
+ * The time of the connect is not a lag of the client.
1355
+ */
1356
+ type LoadConnections = {
1357
+ readonly mode: "pipeline";
1358
+ } | {
1359
+ readonly mode: "pool";
1360
+ readonly size: number;
1361
+ } | {
1362
+ readonly mode: "fresh";
1363
+ };
1364
+ /**
1365
+ * A load stream is one stream of arrivals of the client `load`: its key, its schedule and its
1366
+ * requests. Arrival i sends request i modulo the count of requests. Each stream has its own
1367
+ * connections, thus a slow stream does not delay the arrivals of another stream.
1350
1368
  */
1351
1369
  interface LoadStream {
1352
1370
  /** This text names the stream in each line of the client (`k`). Two streams of a cell do not have the same key. */
@@ -1354,6 +1372,8 @@ interface LoadStream {
1354
1372
  readonly plan: LoadPlan;
1355
1373
  /** These texts are whole HTTP/1.1 requests, each with its head and its body. */
1356
1374
  readonly requests: readonly string[];
1375
+ /** These connections carry the arrivals of the stream. With no value, the stream is a pipeline on one connection. */
1376
+ readonly connections?: LoadConnections;
1357
1377
  }
1358
1378
  /** A run stream is the schedule that one stream of the client `load` had in a run. */
1359
1379
  interface RunStream {
@@ -1879,6 +1899,7 @@ declare const isHopPlace: (place: FaultPlace | undefined) => place is HopPlace;
1879
1899
  * environments of the cell can operate. A value of the host is the same for each environment of the
1880
1900
  * host. Thus a cell with sysctls of the host operates one environment at a time. Otherwise, a lab
1881
1901
  * reads the value of a different lab as its value before, and the restore does not give back the host.
1902
+ * A bad value of the connections of a load stream is also a problem, before a lab opens.
1882
1903
  */
1883
1904
  declare const environmentProblems: (cell: Cell) => string[];
1884
1905
  /**
@@ -2123,4 +2144,4 @@ interface RunTopology {
2123
2144
  };
2124
2145
  }>>;
2125
2146
  }
2126
- export { MiddleboxEvent as $, RESOURCES_PROGRAM as $t, HopEvent as A, RunGroup as At, KernelRecord as B, ShippedImage as Bt, Fault as C, RequestPrediction as Ct, GroupPrediction as D, RunBackup as Dt, GroupPlace as E, Run as Et, HttpProbe as F, RunStream as Ft, LoadPrediction as G, Topology as Gt, LineMatch as H, StageBand as Ht, ImageSource as I, RunTopology as It, MemoryOomPrediction as J, environmentProblems as Jt, LoadStream as K, Toxic as Kt, Jitter as L, SentinelEvent as Lt, HopSignal as M, RunPause as Mt, HopWrite as N, RunResources as Nt, GroupRole as O, RunDrill as Ot, HostSysctl as P, RunRoute as Pt, MemoryThrottlePrediction as Q, RESOURCES_EVENT as Qt, Kafka as R, SentinelStage as Rt, FabricManifest as S, resourceReadingOf as Sn, Replies as St, Group as T, RttRange as Tt, LoadBand as U, Subject as Ut, LineCount as V, Stage as Vt, LoadPlan as W, Target as Wt, MemoryPrediction as X, latestEndOf as Xt, MemoryOomTask as Y, isHopPlace as Yt, MemoryStep as Z, HostLimits as Zt, DriverStep as _, memoryStatOf as _n, Reconnects as _t, ClientCapability as a, ResourceNetwork as an, PauseBand as at, EgressPrediction as b, resourceChange as bn, ReplicaSet as bt, ClusterClientAt as c, ResourceReading as cn, PortsPrediction as ct, ContainerLimits as d, cgroupLimit as dn, ProxyHop as dt, ResourceChange as en, MiddleboxExpectation as et, CountBand as f, cgroupNumber as fn, ProxyTime as ft, DriverBand as g, limitsProblems as gn, QueuePrediction as gt, DrillRoom as h, hostLimitsOf as hn, QueueEnd as ht, Client as i, ResourceMemory as in, Pair as it, HopPlace as j, RunPart as jt, Hop as k, RunFabric as kt, ClusterStage as l, ResourceTraffic as ln, Prediction as lt, Drill as m, cpuStatOf as mn, QueueConnection as mt, CLIENT_CAPABILITIES as n, ResourceDevice as nn, Observer as nt, ClientImage as o, ResourceOptions as on, PausePrediction as ot, DeliveryPrediction as p, cpuMaxOf as pn, QueueBand as pt, MemoryLimits as q, WsProbe as qt, Cell as r, ResourceLimits as rn, Outcomes as rt, Cluster as s, ResourceReader as sn, PinnedImage as st, BuildImage as t, ResourceCpu as tn, MiddleboxForm as tt, ConntrackPrediction as u, cgroupKeyed as un, ProbeEvent as ut, EgressBurst as v, networkOf as vn, Recovers as vt, FaultPlace as w, RouterHop as wt, Fabric as x, resourceReadingIn as xn, ReplicaSetStage as xt, EgressPacketLaw as y, resourceArgs as yn, Reference as yt, KafkaPause as z, Shipped as zt };
2147
+ export { MemoryThrottlePrediction as $, RESOURCES_EVENT as $t, HopEvent as A, RunFabric as At, KernelRecord as B, Shipped as Bt, Fault as C, resourceReadingOf as Cn, Replies as Ct, GroupPrediction as D, Run as Dt, GroupPlace as E, RttRange as Et, HttpProbe as F, RunRoute as Ft, LoadPlan as G, Target as Gt, LineMatch as H, Stage as Ht, ImageSource as I, RunStream as It, MemoryLimits as J, WsProbe as Jt, LoadPrediction as K, Topology as Kt, Jitter as L, RunTopology as Lt, HopSignal as M, RunPart as Mt, HopWrite as N, RunPause as Nt, GroupRole as O, RunBackup as Ot, HostSysctl as P, RunResources as Pt, MemoryStep as Q, HostLimits as Qt, Kafka as R, SentinelEvent as Rt, FabricManifest as S, resourceReadingIn as Sn, ReplicaSetStage as St, Group as T, RouterHop as Tt, LoadBand as U, StageBand as Ut, LineCount as V, ShippedImage as Vt, LoadConnections as W, Subject as Wt, MemoryOomTask as X, isHopPlace as Xt, MemoryOomPrediction as Y, environmentProblems as Yt, MemoryPrediction as Z, latestEndOf as Zt, DriverStep as _, limitsProblems as _n, QueuePrediction as _t, ClientCapability as a, ResourceMemory as an, Pair as at, EgressPrediction as b, resourceArgs as bn, Reference as bt, ClusterClientAt as c, ResourceReader as cn, PinnedImage as ct, ContainerLimits as d, cgroupKeyed as dn, ProbeEvent as dt, RESOURCES_PROGRAM as en, MiddleboxEvent as et, CountBand as f, cgroupLimit as fn, ProxyHop as ft, DriverBand as g, hostLimitsOf as gn, QueueEnd as gt, DrillRoom as h, cpuStatOf as hn, QueueConnection as ht, Client as i, ResourceLimits as in, Outcomes as it, HopPlace as j, RunGroup as jt, Hop as k, RunDrill as kt, ClusterStage as l, ResourceReading as ln, PortsPrediction as lt, Drill as m, cpuMaxOf as mn, QueueBand as mt, CLIENT_CAPABILITIES as n, ResourceCpu as nn, MiddleboxForm as nt, ClientImage as o, ResourceNetwork as on, PauseBand as ot, DeliveryPrediction as p, cgroupNumber as pn, ProxyTime as pt, LoadStream as q, Toxic as qt, Cell as r, ResourceDevice as rn, Observer as rt, Cluster as s, ResourceOptions as sn, PausePrediction as st, BuildImage as t, ResourceChange as tn, MiddleboxExpectation as tt, ConntrackPrediction as u, ResourceTraffic as un, Prediction as ut, EgressBurst as v, memoryStatOf as vn, Reconnects as vt, FaultPlace as w, RequestPrediction as wt, Fabric as x, resourceChange as xn, ReplicaSet as xt, EgressPacketLaw as y, networkOf as yn, Recovers as yt, KafkaPause as z, SentinelStage as zt };
@@ -1,4 +1,7 @@
1
1
  import { quantity, valueIn } from "@mark1russell7/quantity";
2
+ import { rungVerdict } from "@mark1russell7/rigor-bench";
3
+ import { closedLoopPlan, measureLoad, schedule, scheduleHeld } from "@mark1russell7/rigor-chaos";
4
+ import { quantile } from "@mark1russell7/rigor-statistics";
2
5
  import { setTimeout } from "node:timers/promises";
3
6
  import { createHash } from "node:crypto";
4
7
  import { execFile } from "node:child_process";
@@ -9,6 +12,356 @@ import { createRequire } from "node:module";
9
12
  import { fileURLToPath } from "node:url";
10
13
  import { isDeepStrictEqual } from "node:util";
11
14
  import semver from "semver";
15
+ // src/load.ts
16
+ /**
17
+ * The measure and the verdict of an open-loop cell (SYS-68). A client on a schedule sends each
18
+ * arrival at its time, thus a stall counts in each arrival that it delayed. The package rigor-chaos
19
+ * counts each latency from the planned time. The package rigor-bench judges a quantile by a
20
+ * distribution-free interval.
21
+ */
22
+ /** This path is where the client of an open-loop cell finds its schedule. */
23
+ const SCHEDULE_PATH = "/tmp/schedule.json";
24
+ /** This function gives the time of a line of the client, in ms from the start of the schedule. */
25
+ const fromStart = (start, t) => (t - start) / 1e6;
26
+ /**
27
+ * This function gives the measure of one run of a schedule from the lines of its client. It gives
28
+ * null when the client did not start the schedule. The first `sent` line of a client is its request
29
+ * before `ready`, and it names no arrival. The end of the run is its last line.
30
+ */
31
+ const loadOf = (events, plan) => {
32
+ const start = events.find((event) => event.ev === "scheduled")?.t;
33
+ if (start === void 0) return null;
34
+ return measureOf(events, start, plan, void 0);
35
+ };
36
+ /** This function tells if a status of a reply is a failure: a number outside 200 to 299. */
37
+ const failedStatus = (status) => typeof status === "number" && (status < 200 || status > 299);
38
+ /**
39
+ * This function gives the measure of the arrivals of one stream: the lines with the key `key`, or
40
+ * each line for no key. A `sent` line of a pool or of a fresh stream gives the time that its arrival
41
+ * waited for a connection, in ns (`wait`). The lag of such an arrival does not count that wait, but
42
+ * its latency still counts from its planned time.
43
+ */
44
+ const measureOf = (events, start, plan, key) => {
45
+ const sent = /* @__PURE__ */ new Map();
46
+ const done = /* @__PURE__ */ new Map();
47
+ const waits = /* @__PURE__ */ new Map();
48
+ let failed = 0;
49
+ for (const event of events) {
50
+ const index = event["i"];
51
+ if (typeof index !== "number" || key !== void 0 && event["k"] !== key) continue;
52
+ if (event.ev === "sent") {
53
+ sent.set(index, fromStart(start, event.t));
54
+ const wait = event["wait"];
55
+ if (typeof wait === "number" && wait > 0) waits.set(index, wait / 1e6);
56
+ }
57
+ if (event.ev === "replied") {
58
+ done.set(index, fromStart(start, event.t));
59
+ if (failedStatus(event["status"])) failed += 1;
60
+ }
61
+ }
62
+ const completions = [...sent].map(([index, at]) => ({
63
+ index,
64
+ sent: at,
65
+ done: done.get(index) ?? null
66
+ }));
67
+ const end = events.reduce((latest, event) => Math.max(latest, fromStart(start, event.t)), 0);
68
+ const measure = measureLoad(plan, completions, end);
69
+ if (waits.size === 0) return {
70
+ ...measure,
71
+ failed
72
+ };
73
+ const lag = plan.times.flatMap((planned, index) => {
74
+ const at = sent.get(index);
75
+ return at === void 0 ? [] : [at - (waits.get(index) ?? 0) - planned];
76
+ });
77
+ return {
78
+ ...measure,
79
+ lag,
80
+ failed
81
+ };
82
+ };
83
+ /** This path is where the client `load` finds its plan. */
84
+ const LOAD_PATH = "/tmp/load.json";
85
+ /** This text is the format of the plan of the client `load`. */
86
+ const LOAD_FORMAT = "systems-load/1";
87
+ /** This count is the most connections of the pool of one stream of the client `load`. */
88
+ const LOAD_POOL_LIMIT = 1024;
89
+ /**
90
+ * This function gives each problem of the connections of one load stream. An empty list means that
91
+ * the client `load` can use them. The size of a pool is a whole number from 1 to `LOAD_POOL_LIMIT`.
92
+ */
93
+ const connectionsProblems = (connections) => {
94
+ const fields = connections;
95
+ const mode = fields["mode"];
96
+ if (mode === "pipeline" || mode === "fresh") return [];
97
+ if (mode !== "pool") return [`the connections have the mode ${String(mode)}: the mode is pipeline, pool or fresh`];
98
+ const size = fields["size"];
99
+ return typeof size === "number" && Number.isInteger(size) && size >= 1 && size <= 1024 ? [] : [`the pool has the size ${String(size)}: a whole number from 1 to ${LOAD_POOL_LIMIT}`];
100
+ };
101
+ /**
102
+ * This function gives the lines that end the wait of a run for the client `load` or `schedule`.
103
+ * Without streams, the end of the one connection ends the run.
104
+ * With streams, the client `load` writes `done` when each stream can do no more, also after an error.
105
+ * The end of one connection does not end the other streams, thus only `done`, `deadline` and `fail` end the wait.
106
+ */
107
+ const loadEnds = (streams) => streams === void 0 || streams.length === 0 ? [
108
+ "done",
109
+ "error",
110
+ "eof",
111
+ "deadline"
112
+ ] : [
113
+ "done",
114
+ "deadline",
115
+ "fail"
116
+ ];
117
+ /**
118
+ * This function gives the schedule of each stream of a cell, and the text of the plan of the client
119
+ * `load`. It throws for no stream, for two streams with one key and for a stream with no request.
120
+ * It also throws for a bad value of the connections of a stream. A stream with no connections has
121
+ * no such field in the plan.
122
+ */
123
+ const loadPlanOf = (streams) => {
124
+ if (streams.length === 0) throw new RangeError("a plan of the client load has no stream");
125
+ const keys = /* @__PURE__ */ new Set();
126
+ for (const stream of streams) {
127
+ if (keys.has(stream.key)) throw new RangeError(`two streams have the key ${stream.key}`);
128
+ if (stream.requests.length === 0) throw new RangeError(`the stream ${stream.key} has no request`);
129
+ const problem = stream.connections === void 0 ? void 0 : connectionsProblems(stream.connections)[0];
130
+ if (problem !== void 0) throw new RangeError(`the stream ${stream.key}: ${problem}`);
131
+ keys.add(stream.key);
132
+ }
133
+ const scheduled = streams.map((stream) => ({
134
+ key: stream.key,
135
+ schedule: schedule(stream.plan.profile, stream.plan.options),
136
+ requests: stream.requests,
137
+ ...stream.connections === void 0 ? {} : { connections: stream.connections }
138
+ }));
139
+ return {
140
+ streams: scheduled.map(({ key, schedule: each }) => ({
141
+ key,
142
+ schedule: each
143
+ })),
144
+ content: JSON.stringify({
145
+ format: LOAD_FORMAT,
146
+ streams: scheduled
147
+ })
148
+ };
149
+ };
150
+ /**
151
+ * This function gives the measure of each stream of a run of the client `load`, and their pool. Each
152
+ * stream counts its arrivals from 0, thus the lines of a stream are the lines with its key. The pool
153
+ * sums the counts and joins the times, in the order of the streams. It gives null when the client did
154
+ * not start its schedule.
155
+ */
156
+ const streamsLoadOf = (events, streams) => {
157
+ const start = events.find((event) => event.ev === "scheduled")?.t;
158
+ if (start === void 0) return null;
159
+ const each = streams.map((stream) => [stream.key, measureOf(events, start, stream.schedule, stream.key)]);
160
+ return {
161
+ pool: poolOf(each.map(([, measure]) => measure)),
162
+ streams: Object.fromEntries(each)
163
+ };
164
+ };
165
+ /** This function gives the pool of some measures: it sums the counts and joins the times, in the order of the measures. */
166
+ const poolOf = (measures) => {
167
+ const sum = (count) => measures.reduce((total, measure) => total + count(measure), 0);
168
+ const join = (times) => measures.flatMap(times);
169
+ return {
170
+ planned: sum((measure) => measure.planned),
171
+ unsent: sum((measure) => measure.unsent),
172
+ unfinished: sum((measure) => measure.unfinished),
173
+ failed: sum((measure) => measure.failed ?? 0),
174
+ latency: join((measure) => measure.latency),
175
+ service: join((measure) => measure.service),
176
+ lag: join((measure) => measure.lag),
177
+ censored: join((measure) => measure.censored)
178
+ };
179
+ };
180
+ /**
181
+ * This time is the tolerance of a closed-loop estimate, in ms. A send later than its expected time
182
+ * by more than this tolerance is a pause of the client: a driver gap.
183
+ */
184
+ const CLOSED_TOLERANCE = 5;
185
+ /**
186
+ * This function gives the estimate of one closed-loop stream from its requests, in the order of their
187
+ * sends. Each time is a time of a line of the client. The client waits `interval` ms after each reply,
188
+ * thus the interval is also the pause of the driver. The function gives undefined for no request, and
189
+ * for a request with no reply before the last request.
190
+ */
191
+ const estimateOf = (requests, end, interval) => {
192
+ const start = requests[0]?.sent;
193
+ if (start === void 0 || requests.slice(0, -1).some((request) => request.done === null)) return void 0;
194
+ const loop = requests.map((request) => ({
195
+ sent: fromStart(start, request.sent),
196
+ done: request.done === null ? null : fromStart(start, request.done)
197
+ }));
198
+ const stop = Math.max(fromStart(start, end), ...loop.map((request) => request.done ?? request.sent), interval);
199
+ const run = closedLoopPlan(loop, {
200
+ interval,
201
+ end: stop,
202
+ tolerance: 5,
203
+ pause: interval
204
+ });
205
+ return {
206
+ ...measureLoad(run.plan, run.completions, stop),
207
+ hidden: run.hidden,
208
+ driverGaps: run.driverGaps,
209
+ driverGapTotal: run.driverGapTotal
210
+ };
211
+ };
212
+ /** This function gives the spread of a list of times in ms, or null for no time. */
213
+ const spreadOf = (values) => values.length === 0 ? null : {
214
+ p50: quantity(quantile(values, .5, "nearest-rank"), "ms"),
215
+ p95: quantity(quantile(values, .95, "nearest-rank"), "ms"),
216
+ p99: quantity(quantile(values, .99, "nearest-rank"), "ms"),
217
+ max: quantity(values.reduce((most, value) => Math.max(most, value), 0), "ms")
218
+ };
219
+ /** This time is the date of the record of a band and the date of its verdict. The record has no age, because it comes from this run. */
220
+ const NOW = "2026-01-01T00:00:00.000Z";
221
+ /**
222
+ * This function judges one band of the latency over the pooled arrivals of the counted runs. The
223
+ * top of the band reads the interval of rigor-bench: the band holds only if the interval is under its top.
224
+ * The latencies of one run can follow each other, thus the width of the interval is an estimate.
225
+ * The bottom of the band reads the quantile itself. It gives the text of the verdict, and if it holds.
226
+ */
227
+ const bandVerdict = (band, values, censored) => {
228
+ const high = valueIn(band.high, "ms");
229
+ const rung = {
230
+ name: "band",
231
+ at: {},
232
+ budgets: [{
233
+ kind: "quantile",
234
+ measure: "latency",
235
+ unit: "ms",
236
+ quantile: band.quantile,
237
+ limit: high
238
+ }],
239
+ test: "the cell"
240
+ };
241
+ const top = rungVerdict(rung, {
242
+ rung: "band",
243
+ commit: "the cell",
244
+ at: NOW,
245
+ real: ["the counted runs"],
246
+ synthetic: [],
247
+ evidence: [{
248
+ kind: "quantile",
249
+ measure: "latency",
250
+ values,
251
+ censored
252
+ }]
253
+ }, { now: NOW });
254
+ const read = values.length + censored.length === 0 ? null : quantile([...values, ...censored], band.quantile, "nearest-rank");
255
+ const low = band.low === void 0 ? null : valueIn(band.low, "ms");
256
+ const above = low === null || read !== null && read >= low;
257
+ const place = low === null ? `under ${high} ms` : `in [${low}, ${high}] ms`;
258
+ const outcome = top.outcome === "within" && !above ? "under the bottom of the band" : top.outcome;
259
+ return {
260
+ holds: top.outcome === "within" && above,
261
+ words: `p${band.quantile * 100} of the latency ${read === null ? "has no value" : `is ${read} ms`}, wanted ${place}: ${outcome}. ${top.reason}`
262
+ };
263
+ };
264
+ /**
265
+ * This function judges the share of failed arrivals over the counted runs against a limit. Each
266
+ * planned arrival is a trial. An arrival fails if the client did not send it. It also fails with no
267
+ * reply at the end of its run, or with the status of a failure. The rate budget of rigor-bench
268
+ * reads the upper end of the Wilson interval at 0.95. Thus 381 arrivals with no failure hold a limit
269
+ * of 1 %, and fewer arrivals cannot decide.
270
+ */
271
+ const failuresVerdict = (limit, failures, trials) => {
272
+ const verdict = rungVerdict({
273
+ name: "failures",
274
+ at: {},
275
+ budgets: [{
276
+ kind: "rate",
277
+ measure: "failures",
278
+ limit
279
+ }],
280
+ test: "the cell"
281
+ }, {
282
+ rung: "failures",
283
+ commit: "the cell",
284
+ at: NOW,
285
+ real: ["the counted runs"],
286
+ synthetic: [],
287
+ evidence: [{
288
+ kind: "rate",
289
+ measure: "failures",
290
+ failures,
291
+ trials
292
+ }]
293
+ }, { now: NOW });
294
+ return {
295
+ holds: verdict.outcome === "within",
296
+ words: `${failures} of ${trials} arrivals failed, wanted a share under ${limit * 100} %: ${verdict.outcome}. ${verdict.reason}`
297
+ };
298
+ };
299
+ /**
300
+ * This function judges the load of an open-loop cell over its counted runs. A run that did not keep
301
+ * its schedule measures its driver, not the target, thus it is a finding of that run. Each
302
+ * band reads all the arrivals of the counted runs.
303
+ */
304
+ const loadVerdict = (prediction, runs) => {
305
+ const limit = valueIn(prediction.lag, "ms");
306
+ const outside = runs.flatMap((run) => {
307
+ if (run.load === void 0) return [{
308
+ run: run.name,
309
+ why: "the client never started its schedule"
310
+ }];
311
+ const check = scheduleHeld(run.load, limit);
312
+ return check.held ? [] : [{
313
+ run: run.name,
314
+ why: check.reason
315
+ }];
316
+ });
317
+ const measures = runs.flatMap((run) => run.load === void 0 ? [] : [run.load]);
318
+ const latency = measures.flatMap((measure) => measure.latency);
319
+ const censored = measures.flatMap((measure) => measure.censored);
320
+ const bands = prediction.bands.map((band) => bandVerdict(band, latency, censored));
321
+ const total = (count) => measures.reduce((sum, measure) => sum + count(measure), 0);
322
+ const planned = total((measure) => measure.planned);
323
+ const unsent = total((measure) => measure.unsent);
324
+ const unfinished = total((measure) => measure.unfinished);
325
+ const failed = total((measure) => measure.failed ?? 0);
326
+ const failures = prediction.failures === void 0 ? void 0 : failuresVerdict(prediction.failures, unsent + unfinished + failed, planned);
327
+ return {
328
+ holds: runs.length > 0 && outside.length === 0 && bands.every((band) => band.holds) && (failures?.holds ?? true),
329
+ outside,
330
+ load: {
331
+ planned,
332
+ unsent,
333
+ unfinished,
334
+ failed,
335
+ latency: spreadOf([...latency, ...censored]),
336
+ service: spreadOf(measures.flatMap((measure) => measure.service)),
337
+ lag: spreadOf(measures.flatMap((measure) => measure.lag.map((lag) => Math.abs(lag)))),
338
+ bands: bands.map((band) => band.words),
339
+ ...failures === void 0 ? {} : { failures: failures.words }
340
+ }
341
+ };
342
+ };
343
+ /** This function gives the estimate verdict of the counted runs, or undefined when no run has an estimate. */
344
+ const estimateVerdict = (estimates) => {
345
+ const runs = estimates.filter((estimate) => estimate !== void 0);
346
+ if (runs.length === 0) return void 0;
347
+ const pool = poolOf(runs);
348
+ const total = (count) => runs.reduce((sum, estimate) => sum + count(estimate), 0);
349
+ const hidden = total((estimate) => estimate.hidden);
350
+ const driverGaps = total((estimate) => estimate.driverGaps);
351
+ const driverGapTotal = total((estimate) => estimate.driverGapTotal);
352
+ const latency = spreadOf([...pool.latency, ...pool.censored]);
353
+ const seconds = (time) => (valueIn(time, "ms") / 1e3).toFixed(3);
354
+ const spread = latency === null ? "no latency" : `median ${seconds(latency.p50)} s, p99 ${seconds(latency.p99)} s, slowest ${seconds(latency.max)} s`;
355
+ const gaps = driverGaps === 0 ? "no pause of the client" : `${driverGaps} pauses of the client, ${Math.round(driverGapTotal)} ms in all`;
356
+ return {
357
+ planned: pool.planned,
358
+ hidden,
359
+ driverGaps,
360
+ driverGapTotal: quantity(driverGapTotal, "ms"),
361
+ latency,
362
+ words: `The estimate of the open loop puts back ${hidden} hidden sends, with ${gaps}: ${spread}.`
363
+ };
364
+ };
12
365
  // src/resources.ts
13
366
  /**
14
367
  * The resources that one container of a lab used. A reader in a sidecar reads the files of the
@@ -354,11 +707,13 @@ const isHopPlace = (place) => typeof place === "object" && "hop" in place;
354
707
  * environments of the cell can operate. A value of the host is the same for each environment of the
355
708
  * host. Thus a cell with sysctls of the host operates one environment at a time. Otherwise, a lab
356
709
  * reads the value of a different lab as its value before, and the restore does not give back the host.
710
+ * A bad value of the connections of a load stream is also a problem, before a lab opens.
357
711
  */
358
712
  const environmentProblems = (cell) => [
359
713
  ...(cell.hostSysctls?.length ?? 0) > 0 && (cell.concurrency ?? 1) > 1 ? [`${cell.name}: a cell with sysctls of the host operates one environment at a time, not ${cell.concurrency}`] : [],
360
714
  ...cell.target.limits === void 0 ? [] : limitsProblems(cell.target.limits).map((problem) => `${cell.name}: the target: ${problem}`),
361
- ...cell.clientLimits === void 0 ? [] : limitsProblems(cell.clientLimits).map((problem) => `${cell.name}: the client: ${problem}`)
715
+ ...cell.clientLimits === void 0 ? [] : limitsProblems(cell.clientLimits).map((problem) => `${cell.name}: the client: ${problem}`),
716
+ ...(cell.probe.streams ?? []).flatMap((stream) => stream.connections === void 0 ? [] : connectionsProblems(stream.connections).map((problem) => `${cell.name}: the stream ${stream.key}: ${problem}`))
362
717
  ];
363
718
  /**
364
719
  * This function tells if the request of a client goes before the fault of its cell. That is so for a
@@ -1089,6 +1444,6 @@ const grpcClientImage = () => imageOf(shipped("grpc"));
1089
1444
  const targetSourceOf = (target) => target.subject ?? target.image;
1090
1445
  /** This function gives the image that a target operates: the image of its subject, or its stock image. */
1091
1446
  const targetImageOf = (target) => imageOf(targetSourceOf(target));
1092
- export { hostLimitsOf as $, targetSourceOf as A, versionsOf as B, programOf as C, subjectClient as D, sources as E, goVersions as F, requestFirst as G, environmentProblems as H, jarVersions as I, cgroupKeyed as J, RESOURCES_EVENT as K, locksOf as L, unpinnedBases as M, LOCK_NAMES as N, subjectProblems as O, cargoVersions as P, cpuStatOf as Q, npmDrift as R, planOf as S, shippedSource as T, isHopPlace as U, CLIENT_CAPABILITIES as V, latestEndOf as W, cgroupNumber as X, cgroupLimit as Y, cpuMaxOf as Z, kafkaClientImage as _, SHIPPED_NAMES as a, resourceReadingIn as at, nodeHttpImage as b, buildRecordOf as c, harnessImage as d, limitsProblems as et, harnessVersion as f, inContext as g, imageProblems as h, SHIPPED_CLIENTS as i, resourceChange as it, unlockedManifests as j, targetImageOf as k, goHttpImage as l, imageOf as m, PINNED as n, networkOf as nt, amqpClientImage as o, resourceReadingOf as ot, hikariClientImage as p, RESOURCES_PROGRAM as q, REPOSITORY as r, resourceArgs as rt, basesOf as s, CLIENT_NAMES as t, memoryStatOf as tt, grpcClientImage as u, mongoClientImage as v, routerImage as w, pgClientImage as x, nodeClientImage as y, npmVersions as z };
1447
+ export { hostLimitsOf as $, targetSourceOf as A, versionsOf as B, programOf as C, subjectClient as D, sources as E, goVersions as F, requestFirst as G, environmentProblems as H, jarVersions as I, cgroupKeyed as J, RESOURCES_EVENT as K, locksOf as L, unpinnedBases as M, LOCK_NAMES as N, subjectProblems as O, cargoVersions as P, cpuStatOf as Q, npmDrift as R, planOf as S, shippedSource as T, isHopPlace as U, CLIENT_CAPABILITIES as V, latestEndOf as W, cgroupNumber as X, cgroupLimit as Y, cpuMaxOf as Z, kafkaClientImage as _, loadPlanOf as _t, SHIPPED_NAMES as a, resourceReadingIn as at, nodeHttpImage as b, streamsLoadOf as bt, buildRecordOf as c, LOAD_FORMAT as ct, harnessImage as d, SCHEDULE_PATH as dt, limitsProblems as et, harnessVersion as f, connectionsProblems as ft, inContext as g, loadOf as gt, imageProblems as h, loadEnds as ht, SHIPPED_CLIENTS as i, resourceChange as it, unlockedManifests as j, targetImageOf as k, goHttpImage as l, LOAD_PATH as lt, imageOf as m, estimateVerdict as mt, PINNED as n, networkOf as nt, amqpClientImage as o, resourceReadingOf as ot, hikariClientImage as p, estimateOf as pt, RESOURCES_PROGRAM as q, REPOSITORY as r, resourceArgs as rt, basesOf as s, CLOSED_TOLERANCE as st, CLIENT_NAMES as t, memoryStatOf as tt, grpcClientImage as u, LOAD_POOL_LIMIT as ut, mongoClientImage as v, loadVerdict as vt, routerImage as w, pgClientImage as x, nodeClientImage as y, poolOf as yt, npmVersions as z };
1093
1448
 
1094
- //# sourceMappingURL=image-CjrmLPA7.js.map
1449
+ //# sourceMappingURL=image-38hbUAcd.js.map