@smoothbricks/nx-plugin 0.7.17 → 0.7.19
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 +315 -114
- package/dist/.build-inputs.json +47 -38
- package/dist/built-output-packages.js +1 -1
- package/dist/bun-lock-scope.d.ts +128 -20
- package/dist/bun-lock-scope.d.ts.map +1 -1
- package/dist/bun-lock-scope.js +267 -44
- package/dist/cargo-closure-input.d.ts +8 -6
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +15 -12
- package/dist/cargo-source-hash.d.ts +26 -25
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +84 -105
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts +20 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +43 -22
- package/dist/ensure-built-receipt.d.ts +3 -2
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +3 -2
- package/dist/eslint-config-closure.d.ts +8 -3
- package/dist/eslint-config-closure.d.ts.map +1 -1
- package/dist/eslint-config-closure.js +24 -5
- package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
- package/dist/executors/bounded-exec/admission-queue.js +9 -10
- package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
- package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
- package/dist/executors/bounded-exec/awake-clock.js +22 -0
- package/dist/executors/bounded-exec/bounds.d.ts +19 -6
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +22 -15
- package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
- package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
- package/dist/executors/bounded-exec/case-gate.js +342 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
- package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +102 -16
- package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
- package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-rise.js +111 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
- package/dist/executors/bounded-exec/endpoint-life.js +228 -0
- package/dist/executors/bounded-exec/executor.d.ts +1 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +256 -86
- package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +8 -1
- package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
- package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
- package/dist/executors/bounded-exec/go-run-summary.js +98 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
- package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
- package/dist/executors/bounded-exec/lease-wait.js +1 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +45 -8
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
- package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
- package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
- package/dist/executors/bounded-exec/parent-grant.js +1 -0
- package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
- package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
- package/dist/executors/bounded-exec/pool-admission.js +47 -1
- package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
- package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress-channel.js +113 -0
- package/dist/executors/bounded-exec/progress.d.ts +5 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +31 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +123 -16
- package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
- package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
- package/dist/executors/bounded-exec/reservation-connection.js +248 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +13 -9
- package/dist/executors/bounded-exec/schema.d.ts +7 -2
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/schema.js +17 -1
- package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
- package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
- package/dist/executors/bounded-exec/suite-minimum.js +85 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-result-writer.js +1 -0
- package/dist/executors/bounded-exec/test-results.d.ts +5 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-results.js +2 -2
- package/dist/executors/bounded-exec/verdict.d.ts +39 -10
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +60 -14
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +32 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +294 -152
- package/dist/managed-files/ci-workflow.d.ts +4 -1
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +9 -14
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/managed-files/generator.d.ts +5 -1
- package/dist/managed-files/generator.d.ts.map +1 -1
- package/dist/managed-files/generator.js +22 -7
- package/dist/managed-files/render-memo.d.ts +13 -0
- package/dist/managed-files/render-memo.d.ts.map +1 -0
- package/dist/managed-files/render-memo.js +94 -0
- package/dist/task-results.js +2 -1
- package/dist/test-program.d.ts +11 -6
- package/dist/test-program.d.ts.map +1 -1
- package/dist/test-program.js +39 -35
- package/dist/tool-bins.d.ts +12 -0
- package/dist/tool-bins.d.ts.map +1 -1
- package/dist/tool-bins.js +31 -6
- package/dist/typecheck-test-policy.d.ts +10 -1
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +40 -24
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/dist/workspace-index.d.ts +14 -1
- package/dist/workspace-index.d.ts.map +1 -1
- package/dist/workspace-index.js +36 -4
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1851 -221
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +122 -14
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +68 -11
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +293 -3
- package/runtime/nx-publish/nx_publish.js +36 -14
- package/src/built-output-packages.ts +1 -1
- package/src/bun-lock-scope.ts +293 -40
- package/src/cargo-closure-input.ts +20 -12
- package/src/cargo-source-hash.ts +119 -145
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +59 -21
- package/src/ensure-built-receipt.ts +3 -2
- package/src/eslint-config-closure.ts +27 -6
- package/src/executors/bounded-exec/admission-queue.ts +11 -10
- package/src/executors/bounded-exec/awake-clock.ts +20 -0
- package/src/executors/bounded-exec/bounds.ts +41 -19
- package/src/executors/bounded-exec/case-gate.ts +365 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
- package/src/executors/bounded-exec/cpu-pool.ts +139 -12
- package/src/executors/bounded-exec/cpu-rise.ts +156 -0
- package/src/executors/bounded-exec/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +341 -123
- package/src/executors/bounded-exec/gateway-lease.ts +6 -0
- package/src/executors/bounded-exec/go-run-summary.ts +137 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +57 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
- package/src/executors/bounded-exec/parent-grant.ts +3 -0
- package/src/executors/bounded-exec/pool-admission.ts +59 -2
- package/src/executors/bounded-exec/progress-channel.ts +129 -0
- package/src/executors/bounded-exec/progress.ts +39 -3
- package/src/executors/bounded-exec/ram-temp.ts +137 -17
- package/src/executors/bounded-exec/reservation-connection.ts +221 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
- package/src/executors/bounded-exec/runner-sizing.ts +13 -8
- package/src/executors/bounded-exec/schema.json +1 -1
- package/src/executors/bounded-exec/schema.ts +21 -2
- package/src/executors/bounded-exec/suite-minimum.ts +81 -0
- package/src/executors/bounded-exec/test-result-writer.ts +3 -0
- package/src/executors/bounded-exec/test-results.ts +5 -0
- package/src/executors/bounded-exec/verdict.ts +83 -22
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +357 -166
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/managed-files/generator.ts +21 -6
- package/src/managed-files/render-memo.ts +135 -0
- package/src/test-program.ts +36 -41
- package/src/tool-bins.ts +35 -6
- package/src/typecheck-test-policy.ts +49 -24
- package/src/workspace-config-policy.ts +161 -43
- package/src/workspace-index.ts +40 -5
- package/test-timings.json +157 -141
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { MbxPriority } from './mbx-pool.js';
|
|
2
|
+
/**
|
|
3
|
+
* One process's connection to its run's mbx reservation endpoint (mbx-reservations.ts; specs/cowshed/05_gateway.md,
|
|
4
|
+
* "Parallelism inside a job"), as a state machine over what the process asks of it and what its socket says. Pure: no
|
|
5
|
+
* I/O and no clock. The shell maps its callers' requests and the socket's events into `ConnectionEvent`s and executes
|
|
6
|
+
* the `ConnectionEffect`s each step answers, in their order; it decides nothing.
|
|
7
|
+
*
|
|
8
|
+
* Every request is answered once: granted, refused by the pool, withdrawn by its own release, or failed by the
|
|
9
|
+
* connection's end, which also loses every grant still held. A grant lasts until its release or that end, and the
|
|
10
|
+
* endpoint is told of every release it can still hear. Nothing is written once the connection has ended.
|
|
11
|
+
*/
|
|
12
|
+
export interface Connection {
|
|
13
|
+
readonly endpoint: string;
|
|
14
|
+
/** What the socket said after its last whole line. */
|
|
15
|
+
readonly unread: string;
|
|
16
|
+
/** Each request neither released nor refused: waiting for its answer, or holding its grant. */
|
|
17
|
+
readonly entries: ReadonlyMap<number, 'waiting' | 'held'>;
|
|
18
|
+
/** Why the connection ended, which answers every later request; null while it serves. */
|
|
19
|
+
readonly closed: ReservationRefusal | null;
|
|
20
|
+
}
|
|
21
|
+
/** Why a reservation holds no cores: the endpoint asked, and the connect error's code when it could not be reached. */
|
|
22
|
+
export interface ReservationRefusal {
|
|
23
|
+
readonly endpoint: string;
|
|
24
|
+
/** The code of the error that ended the connection (`ENOENT`: the endpoint's socket is gone), else null. */
|
|
25
|
+
readonly errno: string | null;
|
|
26
|
+
readonly message: string;
|
|
27
|
+
}
|
|
28
|
+
/** What the shell observes: its callers' requests, each under an id of its own, and its socket's events. */
|
|
29
|
+
export type ConnectionEvent = {
|
|
30
|
+
readonly type: 'reserve';
|
|
31
|
+
readonly id: number;
|
|
32
|
+
readonly cpus: number;
|
|
33
|
+
readonly priority: MbxPriority;
|
|
34
|
+
/** The fewest cores the reservation starts on before mbx's aging bound; one is no minimum. */
|
|
35
|
+
readonly min: number;
|
|
36
|
+
/** The class mbx predicts the reservation by. */
|
|
37
|
+
readonly name?: string | undefined;
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: 'release';
|
|
40
|
+
readonly id: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: 'data';
|
|
43
|
+
readonly text: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: 'error';
|
|
46
|
+
readonly message: string;
|
|
47
|
+
readonly code: string | null;
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: 'close';
|
|
50
|
+
};
|
|
51
|
+
/** A request's answer: its cores, or why it has none. */
|
|
52
|
+
export type Answer = {
|
|
53
|
+
readonly ok: true;
|
|
54
|
+
readonly cpus: number;
|
|
55
|
+
} | {
|
|
56
|
+
readonly ok: false;
|
|
57
|
+
readonly refusal: ReservationRefusal;
|
|
58
|
+
};
|
|
59
|
+
export type ConnectionEffect =
|
|
60
|
+
/** Keep the process alive for the connection: a request waits or holds. */
|
|
61
|
+
{
|
|
62
|
+
readonly do: 'ref';
|
|
63
|
+
}
|
|
64
|
+
/** Nothing waits or holds: the connection no longer keeps the process alive. */
|
|
65
|
+
| {
|
|
66
|
+
readonly do: 'unref';
|
|
67
|
+
} | {
|
|
68
|
+
readonly do: 'write';
|
|
69
|
+
readonly line: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly do: 'answer';
|
|
72
|
+
readonly id: number;
|
|
73
|
+
readonly answer: Answer;
|
|
74
|
+
}
|
|
75
|
+
/** A grant its request was answered with is lost, and why. */
|
|
76
|
+
| {
|
|
77
|
+
readonly do: 'lose';
|
|
78
|
+
readonly id: number;
|
|
79
|
+
readonly why: string;
|
|
80
|
+
}
|
|
81
|
+
/** Forget the connection, so the next request opens another, and destroy its socket. */
|
|
82
|
+
| {
|
|
83
|
+
readonly do: 'hang-up';
|
|
84
|
+
};
|
|
85
|
+
export type ConnectionStep = readonly [Connection, readonly ConnectionEffect[]];
|
|
86
|
+
/** A connection just opened to `endpoint`. */
|
|
87
|
+
export declare function opened(endpoint: string): Connection;
|
|
88
|
+
/** The next state of `connection` at `event`, and what the shell does about it. */
|
|
89
|
+
export declare function connectionStep(connection: Connection, event: ConnectionEvent): ConnectionStep;
|
|
90
|
+
//# sourceMappingURL=reservation-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reservation-connection.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/reservation-connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,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E,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEjE,MAAM,MAAM,gBAAgB;AAC1B,2EAA2E;AACzE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAA;CAAE;AACxB,gFAAgF;GAC9E;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;CAAE,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACzE,8DAA8D;GAC5D;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE;AACpE,wFAAwF;GACtF;IAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAA;CAAE,CAAC;AAE/B,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC,CAAC;AA6BhF,8CAA8C;AAC9C,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAEnD;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,cAAc,CA6C7F"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import * as _isTypeUint32_1 from "typia/lib/internal/_isTypeUint32";
|
|
2
|
+
import * as _jsonStringifyNumber_1 from "typia/lib/internal/_jsonStringifyNumber";
|
|
3
|
+
import * as _jsonStringifyString_1 from "typia/lib/internal/_jsonStringifyString";
|
|
4
|
+
import * as _jsonStringifyTail_1 from "typia/lib/internal/_jsonStringifyTail";
|
|
5
|
+
import * as _throwTypeGuardError_1 from "typia/lib/internal/_throwTypeGuardError";
|
|
6
|
+
import * as _validateReport_1 from "typia/lib/internal/_validateReport";
|
|
7
|
+
import typia from 'typia';
|
|
8
|
+
const stringifyRequest = (() => {
|
|
9
|
+
const _ip0 = input => "number" === typeof input["id"] && _isTypeUint32_1._isTypeUint32(input["id"]);
|
|
10
|
+
const _so0 = input => `{${_jsonStringifyTail_1._jsonStringifyTail(`"type":${"\"" + input.type + "\""},"id":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.id))},"cpus":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.cpus))},"priority":${"\"" + input.priority + "\""},${undefined === input.min ? "" : `"min":${undefined !== input.min ? String(_jsonStringifyNumber_1._jsonStringifyNumber(input.min)) : undefined},`}${undefined === input.name ? "" : `"name":${undefined !== input.name ? _jsonStringifyString_1._jsonStringifyString(input.name) : undefined}`}`)}}`;
|
|
11
|
+
const _so1 = input => `{"type":${"\"" + input.type + "\""},"id":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.id))}}`;
|
|
12
|
+
const _su0 = input => (() => {
|
|
13
|
+
if ("reserve" === input.type)
|
|
14
|
+
return _so0(input);
|
|
15
|
+
else if ("release" === input.type)
|
|
16
|
+
return _so1(input);
|
|
17
|
+
else
|
|
18
|
+
_throwTypeGuardError_1._throwTypeGuardError({
|
|
19
|
+
method: "typia.json.createStringify",
|
|
20
|
+
expected: "({ type: \"reserve\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; priority: \"interactive\" | \"low\" | \"normal\"; min?: (number & Type<\"uint32\"> & Minimum<...>) | undefined; name?: string | undefined; } | { type: \"release\"; id: Uint; })",
|
|
21
|
+
value: input
|
|
22
|
+
});
|
|
23
|
+
})();
|
|
24
|
+
const _io0 = input => "reserve" === input.type && _ip0(input) && ("number" === typeof input.cpus && (_isTypeUint32_1._isTypeUint32(input.cpus) && 1 <= input.cpus)) && ("interactive" === input.priority || "low" === input.priority || "normal" === input.priority) && (undefined === input.min || "number" === typeof input.min && (_isTypeUint32_1._isTypeUint32(input.min) && 2 <= input.min)) && (undefined === input.name || "string" === typeof input.name);
|
|
25
|
+
const _io1 = input => "release" === input.type && _ip0(input);
|
|
26
|
+
return input => _su0(input);
|
|
27
|
+
})();
|
|
28
|
+
const parseReply = (() => {
|
|
29
|
+
let errors;
|
|
30
|
+
let _report;
|
|
31
|
+
const _ip0 = input => "number" === typeof input["id"] && _isTypeUint32_1._isTypeUint32(input["id"]);
|
|
32
|
+
const _ip1 = input => "string" === typeof input["error"];
|
|
33
|
+
const _ve0 = "({ type: \"error\"; error: string; } | { type: \"granted\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; } | { type: \"refused\"; id: Uint; error: string; })";
|
|
34
|
+
const _vp0 = (input, _path, _exceptionable = true) => "number" === typeof input["id"] && (_isTypeUint32_1._isTypeUint32(input["id"]) || _report(_exceptionable, {
|
|
35
|
+
path: _path + ".id",
|
|
36
|
+
expected: "number & Type<\"uint32\">",
|
|
37
|
+
value: input["id"]
|
|
38
|
+
})) || _report(_exceptionable, {
|
|
39
|
+
path: _path + ".id",
|
|
40
|
+
expected: "(number & Type<\"uint32\">)",
|
|
41
|
+
value: input["id"]
|
|
42
|
+
});
|
|
43
|
+
const _vp1 = (input, _path, _exceptionable = true) => "string" === typeof input["error"] || _report(_exceptionable, {
|
|
44
|
+
path: _path + ".error",
|
|
45
|
+
expected: "string",
|
|
46
|
+
value: input["error"]
|
|
47
|
+
});
|
|
48
|
+
const _ve1 = "({ type: \"granted\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; } | { type: \"refused\"; id: Uint; error: string; } | { type: \"error\"; error: string; })";
|
|
49
|
+
const _io0 = input => "granted" === input.type && _ip0(input) && ("number" === typeof input.cpus && (_isTypeUint32_1._isTypeUint32(input.cpus) && 1 <= input.cpus));
|
|
50
|
+
const _io1 = input => "refused" === input.type && _ip0(input) && _ip1(input);
|
|
51
|
+
const _io2 = input => "error" === input.type && _ip1(input);
|
|
52
|
+
const _iu0 = input => (() => {
|
|
53
|
+
if ("granted" === input.type)
|
|
54
|
+
return _io0(input);
|
|
55
|
+
else if ("refused" === input.type)
|
|
56
|
+
return _io1(input);
|
|
57
|
+
else if ("error" === input.type)
|
|
58
|
+
return _io2(input);
|
|
59
|
+
else
|
|
60
|
+
return false;
|
|
61
|
+
})();
|
|
62
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["granted" === input.type || _report(_exceptionable, {
|
|
63
|
+
path: _path + ".type",
|
|
64
|
+
expected: "\"granted\"",
|
|
65
|
+
value: input.type
|
|
66
|
+
}), _vp0(input, _path, true && _exceptionable), "number" === typeof input.cpus && (_isTypeUint32_1._isTypeUint32(input.cpus) || _report(_exceptionable, {
|
|
67
|
+
path: _path + ".cpus",
|
|
68
|
+
expected: "number & Type<\"uint32\">",
|
|
69
|
+
value: input.cpus
|
|
70
|
+
})) && (1 <= input.cpus || _report(_exceptionable, {
|
|
71
|
+
path: _path + ".cpus",
|
|
72
|
+
expected: "number & Minimum<1>",
|
|
73
|
+
value: input.cpus
|
|
74
|
+
})) || _report(_exceptionable, {
|
|
75
|
+
path: _path + ".cpus",
|
|
76
|
+
expected: "(number & Type<\"uint32\"> & Minimum<1>)",
|
|
77
|
+
value: input.cpus
|
|
78
|
+
})].every(flag => flag);
|
|
79
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["refused" === input.type || _report(_exceptionable, {
|
|
80
|
+
path: _path + ".type",
|
|
81
|
+
expected: "\"refused\"",
|
|
82
|
+
value: input.type
|
|
83
|
+
}), _vp0(input, _path, true && _exceptionable), _vp1(input, _path, true && _exceptionable)].every(flag => flag);
|
|
84
|
+
const _vo2 = (input, _path, _exceptionable = true) => ["error" === input.type || _report(_exceptionable, {
|
|
85
|
+
path: _path + ".type",
|
|
86
|
+
expected: "\"error\"",
|
|
87
|
+
value: input.type
|
|
88
|
+
}), _vp1(input, _path, true && _exceptionable)].every(flag => flag);
|
|
89
|
+
const _vu0 = (input, _path, _exceptionable = true) => (() => {
|
|
90
|
+
if ("granted" === input.type)
|
|
91
|
+
return _vo0(input, _path, true && _exceptionable);
|
|
92
|
+
else if ("refused" === input.type)
|
|
93
|
+
return _vo1(input, _path, true && _exceptionable);
|
|
94
|
+
else if ("error" === input.type)
|
|
95
|
+
return _vo2(input, _path, true && _exceptionable);
|
|
96
|
+
else
|
|
97
|
+
return _report(_exceptionable, {
|
|
98
|
+
path: _path,
|
|
99
|
+
expected: _ve1,
|
|
100
|
+
value: input
|
|
101
|
+
});
|
|
102
|
+
})();
|
|
103
|
+
const __is = input => "object" === typeof input && null !== input && _iu0(input);
|
|
104
|
+
const __validate = input => {
|
|
105
|
+
if (false === __is(input)) {
|
|
106
|
+
errors = [];
|
|
107
|
+
_report = _validateReport_1._validateReport(errors);
|
|
108
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
109
|
+
path: _path + "",
|
|
110
|
+
expected: _ve0,
|
|
111
|
+
value: input
|
|
112
|
+
})) && _vu0(input, _path + "", true) || _report(true, {
|
|
113
|
+
path: _path + "",
|
|
114
|
+
expected: _ve0,
|
|
115
|
+
value: input
|
|
116
|
+
}))(input, "$input", true);
|
|
117
|
+
const success = 0 === errors.length;
|
|
118
|
+
return success ? {
|
|
119
|
+
success,
|
|
120
|
+
data: input
|
|
121
|
+
} : {
|
|
122
|
+
success,
|
|
123
|
+
errors,
|
|
124
|
+
data: input
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
success: true,
|
|
129
|
+
data: input
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
return input => __validate(JSON.parse(input));
|
|
133
|
+
})();
|
|
134
|
+
/** A connection just opened to `endpoint`. */
|
|
135
|
+
export function opened(endpoint) {
|
|
136
|
+
return { endpoint, unread: '', entries: new Map(), closed: null };
|
|
137
|
+
}
|
|
138
|
+
/** The next state of `connection` at `event`, and what the shell does about it. */
|
|
139
|
+
export function connectionStep(connection, event) {
|
|
140
|
+
if (connection.closed !== null) {
|
|
141
|
+
// An ended connection answers a request with its end; nothing else of it is left to decide.
|
|
142
|
+
return event.type === 'reserve'
|
|
143
|
+
? [connection, [{ do: 'answer', id: event.id, answer: { ok: false, refusal: connection.closed } }]]
|
|
144
|
+
: [connection, []];
|
|
145
|
+
}
|
|
146
|
+
switch (event.type) {
|
|
147
|
+
case 'reserve': {
|
|
148
|
+
// A minimum of one is no minimum, and mbx refuses one above the ask.
|
|
149
|
+
const gathers = Math.min(event.min, event.cpus);
|
|
150
|
+
const line = stringifyRequest({
|
|
151
|
+
type: 'reserve',
|
|
152
|
+
id: event.id,
|
|
153
|
+
cpus: event.cpus,
|
|
154
|
+
priority: event.priority,
|
|
155
|
+
...(gathers > 1 ? { min: gathers } : {}),
|
|
156
|
+
...(event.name === undefined ? {} : { name: event.name }),
|
|
157
|
+
});
|
|
158
|
+
return [
|
|
159
|
+
{ ...connection, entries: new Map(connection.entries).set(event.id, 'waiting') },
|
|
160
|
+
[{ do: 'ref' }, { do: 'write', line: `${line}\n` }],
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
case 'release': {
|
|
164
|
+
const entry = connection.entries.get(event.id);
|
|
165
|
+
// Released, refused or never asked: nothing of it is left to give back.
|
|
166
|
+
if (entry === undefined)
|
|
167
|
+
return [connection, []];
|
|
168
|
+
const entries = without(connection.entries, event.id);
|
|
169
|
+
return [
|
|
170
|
+
{ ...connection, entries },
|
|
171
|
+
[
|
|
172
|
+
...(entry === 'waiting' ? [refused(connection, event.id, 'released while it waited')] : []),
|
|
173
|
+
{ do: 'write', line: `${stringifyRequest({ type: 'release', id: event.id })}\n` },
|
|
174
|
+
...unreferenced(entries),
|
|
175
|
+
],
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
case 'data':
|
|
179
|
+
return read({ ...connection, unread: connection.unread + event.text }, []);
|
|
180
|
+
case 'error':
|
|
181
|
+
return close(connection, `mbx reservation endpoint ${connection.endpoint}: ${event.message}`, event.code, []);
|
|
182
|
+
case 'close':
|
|
183
|
+
return close(connection, `mbx reservation endpoint ${connection.endpoint} closed the connection`, null, []);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function without(entries, id) {
|
|
187
|
+
const rest = new Map(entries);
|
|
188
|
+
rest.delete(id);
|
|
189
|
+
return rest;
|
|
190
|
+
}
|
|
191
|
+
function unreferenced(entries) {
|
|
192
|
+
return entries.size === 0 ? [{ do: 'unref' }] : [];
|
|
193
|
+
}
|
|
194
|
+
function refused(connection, id, message) {
|
|
195
|
+
return { do: 'answer', id, answer: { ok: false, refusal: { endpoint: connection.endpoint, errno: null, message } } };
|
|
196
|
+
}
|
|
197
|
+
/** `line` as a reply, or null when it is none: typia's parse validates what `JSON.parse` returns and throws what it throws. */
|
|
198
|
+
function replyOf(line) {
|
|
199
|
+
try {
|
|
200
|
+
const parsed = parseReply(line);
|
|
201
|
+
return parsed.success ? parsed.data : null;
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Each whole line of `connection.unread` in turn, until none is left or one ends the connection. */
|
|
208
|
+
function read(connection, done) {
|
|
209
|
+
const end = connection.unread.indexOf('\n');
|
|
210
|
+
if (end === -1)
|
|
211
|
+
return [connection, done];
|
|
212
|
+
const line = connection.unread.slice(0, end);
|
|
213
|
+
const rest = { ...connection, unread: connection.unread.slice(end + 1) };
|
|
214
|
+
const reply = replyOf(line);
|
|
215
|
+
if (reply === null) {
|
|
216
|
+
const why = `mbx reservation endpoint ${connection.endpoint} answered ${JSON.stringify(line)}, which is no reply`;
|
|
217
|
+
return close(rest, why, null, done);
|
|
218
|
+
}
|
|
219
|
+
const [next, effects] = answer(rest, reply);
|
|
220
|
+
return next.closed === null ? read(next, [...done, ...effects]) : [next, [...done, ...effects]];
|
|
221
|
+
}
|
|
222
|
+
function answer(connection, reply) {
|
|
223
|
+
const { endpoint } = connection;
|
|
224
|
+
if (reply.type === 'error') {
|
|
225
|
+
return close(connection, `mbx reservation endpoint ${endpoint} closed this connection: ${reply.error}`, null, []);
|
|
226
|
+
}
|
|
227
|
+
const entry = connection.entries.get(reply.id);
|
|
228
|
+
// Released before its answer arrived: the endpoint drops what it won.
|
|
229
|
+
if (entry === undefined)
|
|
230
|
+
return [connection, []];
|
|
231
|
+
if (entry === 'held') {
|
|
232
|
+
return close(connection, `mbx reservation endpoint ${endpoint} answered reservation ${reply.id} twice`, null, []);
|
|
233
|
+
}
|
|
234
|
+
if (reply.type === 'granted') {
|
|
235
|
+
return [
|
|
236
|
+
{ ...connection, entries: new Map(connection.entries).set(reply.id, 'held') },
|
|
237
|
+
[{ do: 'answer', id: reply.id, answer: { ok: true, cpus: reply.cpus } }],
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
const entries = without(connection.entries, reply.id);
|
|
241
|
+
return [{ ...connection, entries }, [refused(connection, reply.id, reply.error), ...unreferenced(entries)]];
|
|
242
|
+
}
|
|
243
|
+
/** End the connection: what waits is refused by its end, what is held is lost to it. */
|
|
244
|
+
function close(connection, message, errno, done) {
|
|
245
|
+
const refusal = { endpoint: connection.endpoint, errno, message };
|
|
246
|
+
const settled = Array.from(connection.entries, ([id, entry]) => entry === 'waiting' ? { do: 'answer', id, answer: { ok: false, refusal } } : { do: 'lose', id, why: message });
|
|
247
|
+
return [{ ...connection, unread: '', entries: new Map(), closed: refusal }, [...done, ...settled, { do: 'hang-up' }]];
|
|
248
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cpu-pool.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/run-cpu-pool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAGtH,OAAO,EAAkB,KAAK,gBAAgB,EAAsC,MAAM,kBAAkB,CAAC;AAsD7G;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5F;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,EAC7C,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,KAAK,GAAE,MAA+B,EACtC,UAAU,GAAE,MAAM,OAAO,CAAC,gBAAgB,CAAiB,GAC1D,OAAO,CAAC,IAAI,CAAC,CAoBf;
|
|
1
|
+
{"version":3,"file":"run-cpu-pool.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/run-cpu-pool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAGtH,OAAO,EAAkB,KAAK,gBAAgB,EAAsC,MAAM,kBAAkB,CAAC;AAsD7G;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5F;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,EAC7C,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,KAAK,GAAE,MAA+B,EACtC,UAAU,GAAE,MAAM,OAAO,CAAC,gBAAgB,CAAiB,GAC1D,OAAO,CAAC,IAAI,CAAC,CAoBf;AAsED,uEAAuE;AACvE,wBAAsB,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnG"}
|
|
@@ -139,6 +139,9 @@ function servePoolThread(tokens, memory) {
|
|
|
139
139
|
now.served({ ok: false, error: report.error });
|
|
140
140
|
}
|
|
141
141
|
else if (now.kind === 'closing' && report.kind === 'closed') {
|
|
142
|
+
// What the run's pool left idle beside starved holds, said with the run's end.
|
|
143
|
+
if (report.idle !== null)
|
|
144
|
+
process.stderr.write(report.idle);
|
|
142
145
|
finish(report.outcome);
|
|
143
146
|
now.closed(report.outcome);
|
|
144
147
|
}
|
|
@@ -107,13 +107,15 @@ export declare function withInvocationFlag(command: string, invocation: RegExp,
|
|
|
107
107
|
/**
|
|
108
108
|
* Size the runner to the lesser of its bounded demand and grant, keeping the test-thread ceilings. Rewrite named flags
|
|
109
109
|
* so they cannot outrank that size. `CPU_TOKENS_ENV` still reports the actual held grant.
|
|
110
|
+
* A `gated` nextest runner starts every thread of its ask instead: each case takes its token at the leaf's gate
|
|
111
|
+
* (case-gate.ts; specs/cowshed/05_gateway.md, "A case starts on a core", Inside a hold).
|
|
110
112
|
*
|
|
111
113
|
* Cargo's rustc count is the pool's: the executor's sub-pool exports its jobserver fifo, so no `CARGO_BUILD_JOBS`
|
|
112
114
|
* comes from the grant (specs/cowshed/05_gateway.md, "Cargo reads its holder's jobserver"). Test threads take no
|
|
113
115
|
* jobserver token, so a cargo build's test threads are its size, and a process's, whose script may start Cargo, are
|
|
114
116
|
* its whole held grant.
|
|
115
117
|
*/
|
|
116
|
-
export declare function sizeRunner(demand: Demand, command: string, tokens: number): {
|
|
118
|
+
export declare function sizeRunner(demand: Demand, command: string, tokens: number, gated?: boolean): {
|
|
117
119
|
command: string;
|
|
118
120
|
env: Record<string, string>;
|
|
119
121
|
};
|
|
@@ -121,14 +123,16 @@ export declare function sizeRunner(demand: Demand, command: string, tokens: numb
|
|
|
121
123
|
* The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
|
|
122
124
|
* the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
|
|
123
125
|
* than the leaf asked for (`WANT_ENV`, set before it reserved). The test-thread variables a sizing sets follow from it,
|
|
124
|
-
* under their inherited ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
|
|
126
|
+
* under their inherited ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`). A `gated` nextest
|
|
127
|
+
* leaf's runner starts every thread of its ask instead: each case takes its core at the leaf's gate (case-gate.ts;
|
|
128
|
+
* specs/cowshed/05_gateway.md, "A case starts on a core").
|
|
125
129
|
*/
|
|
126
|
-
export declare function grantedSizing(demand: ReservedDemand): string;
|
|
130
|
+
export declare function grantedSizing(demand: ReservedDemand, gated: boolean): string;
|
|
127
131
|
/**
|
|
128
132
|
* `command` with a reserved runner's named count read from its grant, `CPU_TOKENS_ENV` as `grantedSizing` sets it,
|
|
129
|
-
* where the runner's shell runs it; the runner then runs on all it holds.
|
|
133
|
+
* where the runner's shell runs it; the runner then runs on all it holds. A `gated` nextest runner's count is its ask.
|
|
130
134
|
*/
|
|
131
|
-
export declare function sizeRunnerToGrant(demand: ReservedDemand, command: string): string;
|
|
135
|
+
export declare function sizeRunnerToGrant(demand: ReservedDemand, command: string, gated: boolean): string;
|
|
132
136
|
/**
|
|
133
137
|
* The count `CPU_TOKENS_ENV` names, as a positive safe integer, or `null` when absent or malformed. It is
|
|
134
138
|
* descriptor input only: a count proves nothing about a live pool and grants nothing. It is a ceiling the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-sizing.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-sizing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,kGAAkG;AAClG,MAAM,MAAM,UAAU;AACpB,mFAAmF;AACjF,SAAS;AACX,mDAAmD;GACjD,cAAc;AAChB,2EAA2E;GACzE,cAAc;AAChB,yHAAyH;GACvH,eAAe;AACjB,kGAAkG;GAChG,OAAO;AACT,2FAA2F;GACzF,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MA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AO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EACtC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GACvC,MAAM,CAiCR;AAuED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqBpG;AAOD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,GACX,MAAM,CAKR;AAED
|
|
1
|
+
{"version":3,"file":"runner-sizing.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/runner-sizing.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,kGAAkG;AAClG,MAAM,MAAM,UAAU;AACpB,mFAAmF;AACjF,SAAS;AACX,mDAAmD;GACjD,cAAc;AAChB,2EAA2E;GACzE,cAAc;AAChB,yHAAyH;GACvH,eAAe;AACjB,kGAAkG;GAChG,OAAO;AACT,2FAA2F;GACzF,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GACd;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,kBAAkB,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC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AAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqBpG;AAOD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,OAAO,GACX,MAAM,CAKR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,KAAK,UAAQ,GACZ;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAoDlD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAuB5E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAcjG;AASD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM7E"}
|
|
@@ -201,21 +201,23 @@ export function withInvocationFlag(command, invocation, flag, value, add) {
|
|
|
201
201
|
/**
|
|
202
202
|
* Size the runner to the lesser of its bounded demand and grant, keeping the test-thread ceilings. Rewrite named flags
|
|
203
203
|
* so they cannot outrank that size. `CPU_TOKENS_ENV` still reports the actual held grant.
|
|
204
|
+
* A `gated` nextest runner starts every thread of its ask instead: each case takes its token at the leaf's gate
|
|
205
|
+
* (case-gate.ts; specs/cowshed/05_gateway.md, "A case starts on a core", Inside a hold).
|
|
204
206
|
*
|
|
205
207
|
* Cargo's rustc count is the pool's: the executor's sub-pool exports its jobserver fifo, so no `CARGO_BUILD_JOBS`
|
|
206
208
|
* comes from the grant (specs/cowshed/05_gateway.md, "Cargo reads its holder's jobserver"). Test threads take no
|
|
207
209
|
* jobserver token, so a cargo build's test threads are its size, and a process's, whose script may start Cargo, are
|
|
208
210
|
* its whole held grant.
|
|
209
211
|
*/
|
|
210
|
-
export function sizeRunner(demand, command, tokens) {
|
|
212
|
+
export function sizeRunner(demand, command, tokens, gated = false) {
|
|
211
213
|
const runnerCount = Math.min(tokens, demand.want);
|
|
212
214
|
const count = String(runnerCount);
|
|
213
215
|
const held = String(tokens);
|
|
214
216
|
switch (demand.kind) {
|
|
215
217
|
case 'nextest':
|
|
216
218
|
return {
|
|
217
|
-
command: command.replace(TEST_THREADS, `--test-threads=${count}`),
|
|
218
|
-
env: { [CPU_TOKENS_ENV]: held, NEXTEST_TEST_THREADS: count },
|
|
219
|
+
command: command.replace(TEST_THREADS, `--test-threads=${gated ? demand.want : count}`),
|
|
220
|
+
env: { [CPU_TOKENS_ENV]: held, NEXTEST_TEST_THREADS: gated ? String(demand.want) : count },
|
|
219
221
|
};
|
|
220
222
|
case 'bun-parallel':
|
|
221
223
|
return { command: command.replace(BUN_PARALLEL, `--parallel=${count}`), env: { [CPU_TOKENS_ENV]: held } };
|
|
@@ -264,9 +266,11 @@ export function sizeRunner(demand, command, tokens) {
|
|
|
264
266
|
* The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
|
|
265
267
|
* the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
|
|
266
268
|
* than the leaf asked for (`WANT_ENV`, set before it reserved). The test-thread variables a sizing sets follow from it,
|
|
267
|
-
* under their inherited ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
|
|
269
|
+
* under their inherited ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`). A `gated` nextest
|
|
270
|
+
* leaf's runner starts every thread of its ask instead: each case takes its core at the leaf's gate (case-gate.ts;
|
|
271
|
+
* specs/cowshed/05_gateway.md, "A case starts on a core").
|
|
268
272
|
*/
|
|
269
|
-
export function grantedSizing(demand) {
|
|
273
|
+
export function grantedSizing(demand, gated) {
|
|
270
274
|
const asked = `$${WANT_ENV}`;
|
|
271
275
|
const named = `$${GRANTED_CPUS_ENV}`;
|
|
272
276
|
const tokens = `$${CPU_TOKENS_ENV}`;
|
|
@@ -274,7 +278,7 @@ export function grantedSizing(demand) {
|
|
|
274
278
|
const statements = [`export ${CPU_TOKENS_ENV}="$(( ${named} < ${asked} ? ${named} : ${asked} ))"`];
|
|
275
279
|
switch (demand.kind) {
|
|
276
280
|
case 'nextest':
|
|
277
|
-
statements.push(`export NEXTEST_TEST_THREADS="${tokens}"`);
|
|
281
|
+
statements.push(`export NEXTEST_TEST_THREADS="${gated ? asked : tokens}"`);
|
|
278
282
|
break;
|
|
279
283
|
case 'process':
|
|
280
284
|
// A process's script may start Cargo, whose test threads take no jobserver token: its whole grant.
|
|
@@ -288,13 +292,13 @@ export function grantedSizing(demand) {
|
|
|
288
292
|
}
|
|
289
293
|
/**
|
|
290
294
|
* `command` with a reserved runner's named count read from its grant, `CPU_TOKENS_ENV` as `grantedSizing` sets it,
|
|
291
|
-
* where the runner's shell runs it; the runner then runs on all it holds.
|
|
295
|
+
* where the runner's shell runs it; the runner then runs on all it holds. A `gated` nextest runner's count is its ask.
|
|
292
296
|
*/
|
|
293
|
-
export function sizeRunnerToGrant(demand, command) {
|
|
297
|
+
export function sizeRunnerToGrant(demand, command, gated) {
|
|
294
298
|
const granted = `\${${CPU_TOKENS_ENV}}`;
|
|
295
299
|
switch (demand.kind) {
|
|
296
300
|
case 'nextest':
|
|
297
|
-
return command.replace(TEST_THREADS, `--test-threads=${granted}`);
|
|
301
|
+
return command.replace(TEST_THREADS, `--test-threads=${gated ? `\${${WANT_ENV}}` : granted}`);
|
|
298
302
|
case 'bun-parallel':
|
|
299
303
|
return command.replace(BUN_PARALLEL, `--parallel=${granted}`);
|
|
300
304
|
case 'stryker': {
|
|
@@ -30,8 +30,8 @@ export interface BoundedExecCommand {
|
|
|
30
30
|
killAfterMs?: number;
|
|
31
31
|
/**
|
|
32
32
|
* A compiler-fixture producer for `command`: a shell command run first, in the same cwd and environment, inside
|
|
33
|
-
* the run's CPU grant; under mbx
|
|
34
|
-
*
|
|
33
|
+
* the run's CPU grant; under mbx's pool before its leaf's reservation, as pooled work whose compilers mbx admits one
|
|
34
|
+
* by one, since a reservation is never held across a build.
|
|
35
35
|
* Its whole life is a lifecycle build interval — the progress bound does not run during it, as it does not run
|
|
36
36
|
* during a `cargo test` build. Its failure fails the run; `command` starts only after it exits 0.
|
|
37
37
|
*
|
|
@@ -65,4 +65,9 @@ export interface BoundedExecCommand {
|
|
|
65
65
|
args?: string | string[];
|
|
66
66
|
__unparsed__?: string[];
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The command line a run of `options` starts: `command`, then `args`, then the arguments Nx forwards from its own
|
|
70
|
+
* command line unless `forwardAllArgs` is false. The executor runs it and graph inference reads its runner from it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function boundedCommand(options: Pick<BoundedExecCommand, 'command' | 'args' | 'forwardAllArgs' | '__unparsed__'>): string;
|
|
68
73
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAExE,MAAM,MAAM,iBAAiB,GACzB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,SAAS,CAAC,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CA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;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,MAAM,GAAG,gBAAgB,GAAG,cAAc,CAAC,GACxF,MAAM,CAWR"}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The command line a run of `options` starts: `command`, then `args`, then the arguments Nx forwards from its own
|
|
3
|
+
* command line unless `forwardAllArgs` is false. The executor runs it and graph inference reads its runner from it.
|
|
4
|
+
*/
|
|
5
|
+
export function boundedCommand(options) {
|
|
6
|
+
const parts = [options.command];
|
|
7
|
+
if (Array.isArray(options.args)) {
|
|
8
|
+
parts.push(...options.args);
|
|
9
|
+
}
|
|
10
|
+
else if (options.args) {
|
|
11
|
+
parts.push(options.args);
|
|
12
|
+
}
|
|
13
|
+
if (options.forwardAllArgs !== false && options.__unparsed__?.length) {
|
|
14
|
+
parts.push(...options.__unparsed__);
|
|
15
|
+
}
|
|
16
|
+
return parts.join(' ');
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The minimum a whole-suite test leaf names on its reservation (specs/cowshed/05_gateway.md, "A minimum for a whole
|
|
3
|
+
* suite"): "the fewest threads at which its last recorded test walls, longest first, never leave 180 s without a test
|
|
4
|
+
* finishing". The 180 s there is the leaf's own no-progress bound, `idleMs`.
|
|
5
|
+
*
|
|
6
|
+
* A grant never grows, so a suite that starts on one core runs every test in turn for its whole life: a suite of
|
|
7
|
+
* minutes-long cases granted one core beside seventeen short leaves ran 21 minutes where its longest case is 8.5.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Each test's wall as the task's last run closed it, by the test's id, from its results in `directory`; none for a
|
|
11
|
+
* task that has not run, whose results are gone or cannot be read. They size a request and order a leaf's cases at its
|
|
12
|
+
* gate (case-gate.ts), never a charge: a leaf with none names no minimum and starts as it did before it had any.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readLastWalls(directory: string): Promise<Map<string, number>>;
|
|
15
|
+
/**
|
|
16
|
+
* The fewest threads, from one to `want`, at which the recorded walls keep a test finishing within every `idleMs`;
|
|
17
|
+
* `want` when none does (a single test longer than the bound finishes within it on no count). One, which is no
|
|
18
|
+
* minimum, for a leaf with no recorded wall.
|
|
19
|
+
*/
|
|
20
|
+
export declare function suiteMinimum(recordedWallsMs: readonly number[], want: number, idleMs: number): number;
|
|
21
|
+
//# sourceMappingURL=suite-minimum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suite-minimum.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/suite-minimum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAqBnF;AA4BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQrG"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The minimum a whole-suite test leaf names on its reservation (specs/cowshed/05_gateway.md, "A minimum for a whole
|
|
3
|
+
* suite"): "the fewest threads at which its last recorded test walls, longest first, never leave 180 s without a test
|
|
4
|
+
* finishing". The 180 s there is the leaf's own no-progress bound, `idleMs`.
|
|
5
|
+
*
|
|
6
|
+
* A grant never grows, so a suite that starts on one core runs every test in turn for its whole life: a suite of
|
|
7
|
+
* minutes-long cases granted one core beside seventeen short leaves ran 21 minutes where its longest case is 8.5.
|
|
8
|
+
*/
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { TEST_RESULTS_FILE } from './test-results.js';
|
|
12
|
+
/**
|
|
13
|
+
* Each test's wall as the task's last run closed it, by the test's id, from its results in `directory`; none for a
|
|
14
|
+
* task that has not run, whose results are gone or cannot be read. They size a request and order a leaf's cases at its
|
|
15
|
+
* gate (case-gate.ts), never a charge: a leaf with none names no minimum and starts as it did before it had any.
|
|
16
|
+
*/
|
|
17
|
+
export async function readLastWalls(directory) {
|
|
18
|
+
let text;
|
|
19
|
+
try {
|
|
20
|
+
text = await readFile(join(directory, TEST_RESULTS_FILE), 'utf8');
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return new Map();
|
|
24
|
+
}
|
|
25
|
+
const walls = new Map();
|
|
26
|
+
for (const line of text.split('\n')) {
|
|
27
|
+
if (line === '')
|
|
28
|
+
continue;
|
|
29
|
+
let row;
|
|
30
|
+
try {
|
|
31
|
+
row = JSON.parse(line);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return new Map();
|
|
35
|
+
}
|
|
36
|
+
if (typeof row !== 'object' || row === null || !('durationMs' in row) || !('id' in row))
|
|
37
|
+
continue;
|
|
38
|
+
const { id, durationMs: wall } = row;
|
|
39
|
+
if (typeof id === 'string' && typeof wall === 'number' && Number.isFinite(wall) && wall >= 0)
|
|
40
|
+
walls.set(id, wall);
|
|
41
|
+
}
|
|
42
|
+
return walls;
|
|
43
|
+
}
|
|
44
|
+
/** When each test finishes on `threads` threads: longest first, each on the thread that frees first. */
|
|
45
|
+
function finishTimes(wallsLongestFirst, threads) {
|
|
46
|
+
const free = new Array(threads).fill(0);
|
|
47
|
+
const finished = [];
|
|
48
|
+
for (const wall of wallsLongestFirst) {
|
|
49
|
+
let soonest = 0;
|
|
50
|
+
for (let thread = 1; thread < threads; thread++) {
|
|
51
|
+
if ((free[thread] ?? 0) < (free[soonest] ?? 0))
|
|
52
|
+
soonest = thread;
|
|
53
|
+
}
|
|
54
|
+
const end = (free[soonest] ?? 0) + wall;
|
|
55
|
+
free[soonest] = end;
|
|
56
|
+
finished.push(end);
|
|
57
|
+
}
|
|
58
|
+
return finished.sort((a, b) => a - b);
|
|
59
|
+
}
|
|
60
|
+
/** Whether no span longer than `idleMs` passes without a test finishing, from the start to the last finish. */
|
|
61
|
+
function keepsFinishing(finished, idleMs) {
|
|
62
|
+
let last = 0;
|
|
63
|
+
for (const end of finished) {
|
|
64
|
+
if (end - last > idleMs)
|
|
65
|
+
return false;
|
|
66
|
+
last = end;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The fewest threads, from one to `want`, at which the recorded walls keep a test finishing within every `idleMs`;
|
|
72
|
+
* `want` when none does (a single test longer than the bound finishes within it on no count). One, which is no
|
|
73
|
+
* minimum, for a leaf with no recorded wall.
|
|
74
|
+
*/
|
|
75
|
+
export function suiteMinimum(recordedWallsMs, want, idleMs) {
|
|
76
|
+
if (recordedWallsMs.length === 0)
|
|
77
|
+
return 1;
|
|
78
|
+
const longestFirst = [...recordedWallsMs].sort((a, b) => b - a);
|
|
79
|
+
const most = Math.min(want, longestFirst.length);
|
|
80
|
+
for (let threads = 1; threads <= most; threads++) {
|
|
81
|
+
if (keepsFinishing(finishTimes(longestFirst, threads), idleMs))
|
|
82
|
+
return threads;
|
|
83
|
+
}
|
|
84
|
+
return most;
|
|
85
|
+
}
|