@smoothbricks/nx-plugin 0.7.3 → 0.7.5
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 +39 -27
- package/dist/.build-inputs.json +6 -5
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +95 -38
- package/dist/executors/bounded-exec/mbx-pool.d.ts +17 -9
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +29 -11
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +41 -0
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -0
- package/dist/executors/bounded-exec/mbx-reservations.js +372 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +5 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +6 -6
- package/dist/executors/bounded-exec/verdict.d.ts +3 -2
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +6 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +4 -0
- package/package.json +2 -2
- package/src/executors/bounded-exec/executor.ts +100 -37
- package/src/executors/bounded-exec/mbx-pool.ts +33 -13
- package/src/executors/bounded-exec/mbx-reservations.ts +300 -0
- package/src/executors/bounded-exec/runner-sizing.ts +6 -6
- package/src/executors/bounded-exec/verdict.ts +10 -5
- package/src/index.ts +4 -1
- package/test-timings.json +1 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import * as _isTypeUint32_1 from "typia/lib/internal/_isTypeUint32";
|
|
2
|
+
import * as _jsonStringifyNumber_1 from "typia/lib/internal/_jsonStringifyNumber";
|
|
3
|
+
import * as _throwTypeGuardError_1 from "typia/lib/internal/_throwTypeGuardError";
|
|
4
|
+
import * as _validateReport_1 from "typia/lib/internal/_validateReport";
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { rm } from 'node:fs/promises';
|
|
7
|
+
import { createConnection } from 'node:net';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { logger } from 'nx/src/devkit-exports.js';
|
|
10
|
+
import typia from 'typia';
|
|
11
|
+
import { ownedSocketDirectory } from '../../testing.js';
|
|
12
|
+
import { CONTROL_MS } from './lease-wait.js';
|
|
13
|
+
import { mbxPool } from './mbx-pool.js';
|
|
14
|
+
/**
|
|
15
|
+
* mbx's reservation endpoint of one Nx run (specs/cowshed/05_gateway.md, "Parallelism inside a job"). A reserved leaf
|
|
16
|
+
* once ran under its own `mbx reserve`, two mbx processes per task whose dynamic loading alone kept the host's vnode
|
|
17
|
+
* table recycling. With mbx's pool, the run's `preTasksExecution` starts `mbx reservations <socket>` once and publishes
|
|
18
|
+
* the socket in `RESERVATIONS_ENV`, which every task inherits; each task's executor asks it for its leaf's cores over
|
|
19
|
+
* one connection per process (`reserveCores`), and the run's `postTasksExecution` closes the endpoint's standard input,
|
|
20
|
+
* which ends it. Admission is `mbx reserve`'s: the same pool, priority and order. A grant lasts until its leaf ends, or
|
|
21
|
+
* until its connection closes, so an executor that dies gives back what it held.
|
|
22
|
+
*/
|
|
23
|
+
export const RESERVATIONS_ENV = 'MBX_RESERVATIONS_SOCKET';
|
|
24
|
+
const ENDPOINT_DIRECTORY = 'mbx-r-';
|
|
25
|
+
const ENDPOINT_SOCKET = 'r.sock';
|
|
26
|
+
/** What is kept of the endpoint's stderr to say why it ended: its last bytes. */
|
|
27
|
+
const SAID_BYTES = 4096;
|
|
28
|
+
/** The endpoints this process serves, by Nx run id, until that run's `postTasksExecution`. */
|
|
29
|
+
const endpoints = new Map();
|
|
30
|
+
/**
|
|
31
|
+
* Serve `context`'s run an mbx reservation endpoint and publish it in `env`, which every task inherits, when the
|
|
32
|
+
* environment names mbx's pool (`mbxPool`). An endpoint that does not start is said, and each reserved leaf of the run
|
|
33
|
+
* then refuses to run, naming `RESERVATIONS_ENV`; a leaf in no pool, or one mbx admits itself, runs as before.
|
|
34
|
+
*/
|
|
35
|
+
export async function serveRunReservations(context, env = process.env) {
|
|
36
|
+
if (mbxPool(env) === null) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const started = await startEndpoint(env);
|
|
40
|
+
if (!started.ok) {
|
|
41
|
+
logger.warn(`bounded-exec: this run's mbx reservation endpoint did not start (${started.error}); its reserved leaves refuse to run`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
endpoints.set(context.id, started.endpoint);
|
|
45
|
+
env[RESERVATIONS_ENV] = started.socket;
|
|
46
|
+
}
|
|
47
|
+
/** Close the endpoint `context`'s run was served, if it was served one: its standard input's end ends it. */
|
|
48
|
+
export async function closeRunReservations(context) {
|
|
49
|
+
const endpoint = endpoints.get(context.id);
|
|
50
|
+
if (endpoint === undefined) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
endpoints.delete(context.id);
|
|
54
|
+
endpoint.server.stdin.end();
|
|
55
|
+
const ended = await endedWithin(endpoint, CONTROL_MS);
|
|
56
|
+
await rm(endpoint.directory, { recursive: true, force: true });
|
|
57
|
+
if (ended !== 'mbx reservations ended with status 0') {
|
|
58
|
+
logger.warn(`bounded-exec: this run's mbx reservation endpoint did not close cleanly: ${ended}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Start `mbx reservations` by its PATH name in an owned socket directory, and wait until it says it listens. */
|
|
62
|
+
async function startEndpoint(env) {
|
|
63
|
+
const directory = await ownedSocketDirectory(ENDPOINT_DIRECTORY, ENDPOINT_SOCKET);
|
|
64
|
+
const socket = join(directory, ENDPOINT_SOCKET);
|
|
65
|
+
const server = spawn('mbx', ['reservations', socket], { env, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
66
|
+
let said = '';
|
|
67
|
+
server.stderr.setEncoding('utf8');
|
|
68
|
+
server.stderr.on('data', (text) => {
|
|
69
|
+
said = (said + text).slice(-SAID_BYTES);
|
|
70
|
+
});
|
|
71
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a child that runs ends with its run's postTasksExecution, which ends its standard input and bounds its exit (`endedWithin`); one that cannot run says so at once
|
|
72
|
+
const ended = new Promise((resolve) => {
|
|
73
|
+
server.once('error', (error) => resolve(`mbx reservations could not run: ${error.message}`));
|
|
74
|
+
server.once('close', (code, signal) => {
|
|
75
|
+
const last = said.trim().split('\n').at(-1) ?? '';
|
|
76
|
+
resolve(`mbx reservations ended ${signal === null ? `with status ${code}` : `on ${signal}`}${last === '' ? '' : `: ${last}`}`);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
const endpoint = { server, directory, ended };
|
|
80
|
+
const listening = await saysListening(server.stdout, ended);
|
|
81
|
+
if (listening !== null) {
|
|
82
|
+
server.kill('SIGKILL');
|
|
83
|
+
await endedWithin(endpoint, CONTROL_MS);
|
|
84
|
+
await rm(directory, { recursive: true, force: true });
|
|
85
|
+
return { ok: false, error: listening };
|
|
86
|
+
}
|
|
87
|
+
return { ok: true, endpoint, socket };
|
|
88
|
+
}
|
|
89
|
+
/** Null once the endpoint's first line is `listening`; otherwise why not, within the control-plane bound. */
|
|
90
|
+
function saysListening(stdout, ended) {
|
|
91
|
+
return new Promise((resolve) => {
|
|
92
|
+
let text = '';
|
|
93
|
+
const timer = setTimeout(() => resolve(`mbx reservations did not say it was listening within ${CONTROL_MS}ms`), CONTROL_MS);
|
|
94
|
+
stdout.setEncoding('utf8');
|
|
95
|
+
stdout.on('data', (chunk) => {
|
|
96
|
+
text += chunk;
|
|
97
|
+
const end = text.indexOf('\n');
|
|
98
|
+
if (end === -1)
|
|
99
|
+
return;
|
|
100
|
+
clearTimeout(timer);
|
|
101
|
+
const line = text.slice(0, end);
|
|
102
|
+
resolve(line === 'listening' ? null : `mbx reservations said ${JSON.stringify(line)}, not that it was listening`);
|
|
103
|
+
});
|
|
104
|
+
void ended.then((why) => {
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
resolve(why);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** How the endpoint ended, killing it once `ms` pass first. */
|
|
111
|
+
async function endedWithin(endpoint, ms) {
|
|
112
|
+
let timer;
|
|
113
|
+
const late = new Promise((resolve) => (timer = setTimeout(() => resolve(null), ms)));
|
|
114
|
+
const ended = await Promise.race([endpoint.ended, late]);
|
|
115
|
+
clearTimeout(timer);
|
|
116
|
+
if (ended !== null) {
|
|
117
|
+
return ended;
|
|
118
|
+
}
|
|
119
|
+
endpoint.server.kill('SIGKILL');
|
|
120
|
+
return `${await endpoint.ended}, killed after it outlived its standard input by ${ms}ms`;
|
|
121
|
+
}
|
|
122
|
+
const stringifyRequest = (() => {
|
|
123
|
+
const _ip0 = input => "number" === typeof input["id"] && _isTypeUint32_1._isTypeUint32(input["id"]);
|
|
124
|
+
const _so0 = input => `{"type":${"\"" + input.type + "\""},"id":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.id))},"cpus":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.cpus))},"priority":${"\"" + input.priority + "\""}}`;
|
|
125
|
+
const _so1 = input => `{"type":${"\"" + input.type + "\""},"id":${String(_jsonStringifyNumber_1._jsonStringifyNumber(input.id))}}`;
|
|
126
|
+
const _su0 = input => (() => {
|
|
127
|
+
if ("reserve" === input.type)
|
|
128
|
+
return _so0(input);
|
|
129
|
+
else if ("release" === input.type)
|
|
130
|
+
return _so1(input);
|
|
131
|
+
else
|
|
132
|
+
_throwTypeGuardError_1._throwTypeGuardError({
|
|
133
|
+
method: "typia.json.createStringify",
|
|
134
|
+
expected: "({ type: \"reserve\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; priority: \"low\" | \"normal\"; } | { type: \"release\"; id: Uint; })",
|
|
135
|
+
value: input
|
|
136
|
+
});
|
|
137
|
+
})();
|
|
138
|
+
const _io0 = input => "reserve" === input.type && _ip0(input) && ("number" === typeof input.cpus && (_isTypeUint32_1._isTypeUint32(input.cpus) && 1 <= input.cpus)) && ("low" === input.priority || "normal" === input.priority);
|
|
139
|
+
const _io1 = input => "release" === input.type && _ip0(input);
|
|
140
|
+
return input => _su0(input);
|
|
141
|
+
})();
|
|
142
|
+
const parseReply = (() => {
|
|
143
|
+
let errors;
|
|
144
|
+
let _report;
|
|
145
|
+
const _ip0 = input => "number" === typeof input["id"] && _isTypeUint32_1._isTypeUint32(input["id"]);
|
|
146
|
+
const _ip1 = input => "string" === typeof input["error"];
|
|
147
|
+
const _ve0 = "({ type: \"error\"; error: string; } | { type: \"granted\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; } | { type: \"refused\"; id: Uint; error: string; })";
|
|
148
|
+
const _vp0 = (input, _path, _exceptionable = true) => "number" === typeof input["id"] && (_isTypeUint32_1._isTypeUint32(input["id"]) || _report(_exceptionable, {
|
|
149
|
+
path: _path + ".id",
|
|
150
|
+
expected: "number & Type<\"uint32\">",
|
|
151
|
+
value: input["id"]
|
|
152
|
+
})) || _report(_exceptionable, {
|
|
153
|
+
path: _path + ".id",
|
|
154
|
+
expected: "(number & Type<\"uint32\">)",
|
|
155
|
+
value: input["id"]
|
|
156
|
+
});
|
|
157
|
+
const _vp1 = (input, _path, _exceptionable = true) => "string" === typeof input["error"] || _report(_exceptionable, {
|
|
158
|
+
path: _path + ".error",
|
|
159
|
+
expected: "string",
|
|
160
|
+
value: input["error"]
|
|
161
|
+
});
|
|
162
|
+
const _ve1 = "({ type: \"granted\"; id: Uint; cpus: number & Type<\"uint32\"> & Minimum<1>; } | { type: \"refused\"; id: Uint; error: string; } | { type: \"error\"; error: string; })";
|
|
163
|
+
const _io0 = input => "granted" === input.type && _ip0(input) && ("number" === typeof input.cpus && (_isTypeUint32_1._isTypeUint32(input.cpus) && 1 <= input.cpus));
|
|
164
|
+
const _io1 = input => "refused" === input.type && _ip0(input) && _ip1(input);
|
|
165
|
+
const _io2 = input => "error" === input.type && _ip1(input);
|
|
166
|
+
const _iu0 = input => (() => {
|
|
167
|
+
if ("granted" === input.type)
|
|
168
|
+
return _io0(input);
|
|
169
|
+
else if ("refused" === input.type)
|
|
170
|
+
return _io1(input);
|
|
171
|
+
else if ("error" === input.type)
|
|
172
|
+
return _io2(input);
|
|
173
|
+
else
|
|
174
|
+
return false;
|
|
175
|
+
})();
|
|
176
|
+
const _vo0 = (input, _path, _exceptionable = true) => ["granted" === input.type || _report(_exceptionable, {
|
|
177
|
+
path: _path + ".type",
|
|
178
|
+
expected: "\"granted\"",
|
|
179
|
+
value: input.type
|
|
180
|
+
}), _vp0(input, _path, true && _exceptionable), "number" === typeof input.cpus && (_isTypeUint32_1._isTypeUint32(input.cpus) || _report(_exceptionable, {
|
|
181
|
+
path: _path + ".cpus",
|
|
182
|
+
expected: "number & Type<\"uint32\">",
|
|
183
|
+
value: input.cpus
|
|
184
|
+
})) && (1 <= input.cpus || _report(_exceptionable, {
|
|
185
|
+
path: _path + ".cpus",
|
|
186
|
+
expected: "number & Minimum<1>",
|
|
187
|
+
value: input.cpus
|
|
188
|
+
})) || _report(_exceptionable, {
|
|
189
|
+
path: _path + ".cpus",
|
|
190
|
+
expected: "(number & Type<\"uint32\"> & Minimum<1>)",
|
|
191
|
+
value: input.cpus
|
|
192
|
+
})].every(flag => flag);
|
|
193
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["refused" === input.type || _report(_exceptionable, {
|
|
194
|
+
path: _path + ".type",
|
|
195
|
+
expected: "\"refused\"",
|
|
196
|
+
value: input.type
|
|
197
|
+
}), _vp0(input, _path, true && _exceptionable), _vp1(input, _path, true && _exceptionable)].every(flag => flag);
|
|
198
|
+
const _vo2 = (input, _path, _exceptionable = true) => ["error" === input.type || _report(_exceptionable, {
|
|
199
|
+
path: _path + ".type",
|
|
200
|
+
expected: "\"error\"",
|
|
201
|
+
value: input.type
|
|
202
|
+
}), _vp1(input, _path, true && _exceptionable)].every(flag => flag);
|
|
203
|
+
const _vu0 = (input, _path, _exceptionable = true) => (() => {
|
|
204
|
+
if ("granted" === input.type)
|
|
205
|
+
return _vo0(input, _path, true && _exceptionable);
|
|
206
|
+
else if ("refused" === input.type)
|
|
207
|
+
return _vo1(input, _path, true && _exceptionable);
|
|
208
|
+
else if ("error" === input.type)
|
|
209
|
+
return _vo2(input, _path, true && _exceptionable);
|
|
210
|
+
else
|
|
211
|
+
return _report(_exceptionable, {
|
|
212
|
+
path: _path,
|
|
213
|
+
expected: _ve1,
|
|
214
|
+
value: input
|
|
215
|
+
});
|
|
216
|
+
})();
|
|
217
|
+
const __is = input => "object" === typeof input && null !== input && _iu0(input);
|
|
218
|
+
const __validate = input => {
|
|
219
|
+
if (false === __is(input)) {
|
|
220
|
+
errors = [];
|
|
221
|
+
_report = _validateReport_1._validateReport(errors);
|
|
222
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
223
|
+
path: _path + "",
|
|
224
|
+
expected: _ve0,
|
|
225
|
+
value: input
|
|
226
|
+
})) && _vu0(input, _path + "", true) || _report(true, {
|
|
227
|
+
path: _path + "",
|
|
228
|
+
expected: _ve0,
|
|
229
|
+
value: input
|
|
230
|
+
}))(input, "$input", true);
|
|
231
|
+
const success = 0 === errors.length;
|
|
232
|
+
return success ? {
|
|
233
|
+
success,
|
|
234
|
+
data: input
|
|
235
|
+
} : {
|
|
236
|
+
success,
|
|
237
|
+
errors,
|
|
238
|
+
data: input
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
success: true,
|
|
243
|
+
data: input
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
return input => __validate(JSON.parse(input));
|
|
247
|
+
})();
|
|
248
|
+
/**
|
|
249
|
+
* One connection to an endpoint, shared by every reservation this process makes there. It keeps the process alive only
|
|
250
|
+
* while one of them waits or holds.
|
|
251
|
+
*/
|
|
252
|
+
class Connection {
|
|
253
|
+
endpoint;
|
|
254
|
+
forget;
|
|
255
|
+
#socket;
|
|
256
|
+
#entries = new Map();
|
|
257
|
+
#nextId = 1;
|
|
258
|
+
#unread = '';
|
|
259
|
+
#closed = null;
|
|
260
|
+
constructor(endpoint, forget) {
|
|
261
|
+
this.endpoint = endpoint;
|
|
262
|
+
this.forget = forget;
|
|
263
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a Unix-socket connect completes or fails at once, and a reservation's answer waits as long as the pool's admission holds it, as `mbx reserve`'s did; the connection's end answers every request still waiting
|
|
264
|
+
this.#socket = createConnection(endpoint);
|
|
265
|
+
this.#socket.setEncoding('utf8');
|
|
266
|
+
this.#socket.unref();
|
|
267
|
+
this.#socket.on('data', (text) => this.#read(text));
|
|
268
|
+
this.#socket.on('error', (error) => this.#close(`mbx reservation endpoint ${this.endpoint}: ${error.message}`));
|
|
269
|
+
this.#socket.on('close', () => this.#close(`mbx reservation endpoint ${this.endpoint} closed the connection`));
|
|
270
|
+
}
|
|
271
|
+
reserve(cpus, priority) {
|
|
272
|
+
if (this.#closed !== null) {
|
|
273
|
+
return { granted: Promise.resolve({ ok: false, error: this.#closed }), release() { } };
|
|
274
|
+
}
|
|
275
|
+
const id = this.#nextId++;
|
|
276
|
+
let answer;
|
|
277
|
+
const granted = new Promise((resolve) => (answer = resolve));
|
|
278
|
+
this.#entries.set(id, { kind: 'waiting', answer });
|
|
279
|
+
this.#socket.ref();
|
|
280
|
+
this.#socket.write(`${stringifyRequest({ type: 'reserve', id, cpus, priority })}\n`);
|
|
281
|
+
let released = false;
|
|
282
|
+
return {
|
|
283
|
+
granted,
|
|
284
|
+
release: () => {
|
|
285
|
+
if (released)
|
|
286
|
+
return;
|
|
287
|
+
released = true;
|
|
288
|
+
const entry = this.#entries.get(id);
|
|
289
|
+
if (entry === undefined)
|
|
290
|
+
return;
|
|
291
|
+
this.#entries.delete(id);
|
|
292
|
+
if (entry.kind === 'waiting')
|
|
293
|
+
entry.answer({ ok: false, error: 'released while it waited' });
|
|
294
|
+
this.#socket.write(`${stringifyRequest({ type: 'release', id })}\n`);
|
|
295
|
+
if (this.#entries.size === 0)
|
|
296
|
+
this.#socket.unref();
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
#read(text) {
|
|
301
|
+
this.#unread += text;
|
|
302
|
+
for (let end = this.#unread.indexOf('\n'); end !== -1; end = this.#unread.indexOf('\n')) {
|
|
303
|
+
const line = this.#unread.slice(0, end);
|
|
304
|
+
this.#unread = this.#unread.slice(end + 1);
|
|
305
|
+
const parsed = parseReply(line);
|
|
306
|
+
if (!parsed.success) {
|
|
307
|
+
this.#close(`mbx reservation endpoint ${this.endpoint} answered ${JSON.stringify(line)}, which is no reply`);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.#answer(parsed.data);
|
|
311
|
+
if (this.#closed !== null)
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
#answer(reply) {
|
|
316
|
+
if (reply.type === 'error') {
|
|
317
|
+
this.#close(`mbx reservation endpoint ${this.endpoint} closed this connection: ${reply.error}`);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const entry = this.#entries.get(reply.id);
|
|
321
|
+
// Released before its answer arrived: the endpoint drops what it won.
|
|
322
|
+
if (entry === undefined)
|
|
323
|
+
return;
|
|
324
|
+
if (entry.kind === 'held') {
|
|
325
|
+
this.#close(`mbx reservation endpoint ${this.endpoint} answered reservation ${reply.id} twice`);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (reply.type === 'granted') {
|
|
329
|
+
let lose;
|
|
330
|
+
const lost = new Promise((resolve) => (lose = resolve));
|
|
331
|
+
this.#entries.set(reply.id, { kind: 'held', lose });
|
|
332
|
+
entry.answer({ ok: true, cpus: reply.cpus, lost });
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
this.#entries.delete(reply.id);
|
|
336
|
+
entry.answer({ ok: false, error: reply.error });
|
|
337
|
+
if (this.#entries.size === 0)
|
|
338
|
+
this.#socket.unref();
|
|
339
|
+
}
|
|
340
|
+
#close(why) {
|
|
341
|
+
if (this.#closed !== null)
|
|
342
|
+
return;
|
|
343
|
+
this.#closed = why;
|
|
344
|
+
this.forget();
|
|
345
|
+
for (const entry of this.#entries.values()) {
|
|
346
|
+
if (entry.kind === 'waiting')
|
|
347
|
+
entry.answer({ ok: false, error: why });
|
|
348
|
+
else
|
|
349
|
+
entry.lose(why);
|
|
350
|
+
}
|
|
351
|
+
this.#entries.clear();
|
|
352
|
+
this.#socket.destroy();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/** This process's connection to each endpoint it has asked. */
|
|
356
|
+
const connections = new Map();
|
|
357
|
+
/**
|
|
358
|
+
* Ask the endpoint at `socket` for at most `cpus` cores at `priority`, over this process's one connection to it,
|
|
359
|
+
* opened by its first request and kept while another one may come.
|
|
360
|
+
*/
|
|
361
|
+
export function reserveCores(socket, cpus, priority) {
|
|
362
|
+
let connection = connections.get(socket);
|
|
363
|
+
if (connection === undefined) {
|
|
364
|
+
const opened = new Connection(socket, () => {
|
|
365
|
+
if (connections.get(socket) === opened)
|
|
366
|
+
connections.delete(socket);
|
|
367
|
+
});
|
|
368
|
+
connections.set(socket, opened);
|
|
369
|
+
connection = opened;
|
|
370
|
+
}
|
|
371
|
+
return connection.reserve(cpus, priority);
|
|
372
|
+
}
|
|
@@ -69,8 +69,9 @@ export type ReservedDemand = Extract<Demand, {
|
|
|
69
69
|
/** Every budgeted command learns its grant here, so a script that starts a runner can size it. */
|
|
70
70
|
export declare const CPU_TOKENS_ENV = "BOUNDED_EXEC_CPU_TOKENS";
|
|
71
71
|
/**
|
|
72
|
-
* The cores mbx granted the reservation a leaf runs under:
|
|
73
|
-
* as were free once one was
|
|
72
|
+
* The cores mbx granted the reservation a leaf runs under: its run's mbx reservation endpoint grants at most the N the
|
|
73
|
+
* leaf asks for, as many as were free once one was, and the leaf's shell reads that count into this variable
|
|
74
|
+
* (mbx-pool.ts, `reservation`), the one `mbx reserve --cpus N` names to its own command.
|
|
74
75
|
*/
|
|
75
76
|
export declare const GRANTED_CPUS_ENV = "MBX_RESERVE_CPUS";
|
|
76
77
|
/**
|
|
@@ -119,9 +120,8 @@ export declare function sizeRunner(demand: Demand, command: string, tokens: numb
|
|
|
119
120
|
/**
|
|
120
121
|
* The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
|
|
121
122
|
* the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
|
|
122
|
-
* than the leaf asked for (`WANT_ENV`, set before it reserved)
|
|
123
|
-
*
|
|
124
|
-
* ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
|
|
123
|
+
* 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`).
|
|
125
125
|
*/
|
|
126
126
|
export declare function grantedSizing(demand: ReservedDemand): string;
|
|
127
127
|
/**
|
|
@@ -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,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,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C1B,OAAO,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;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAoDlD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAuB5D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAcjF;AASD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM7E"}
|
|
@@ -2,8 +2,9 @@ import { BUN_TEST, GO_TEST_RUNNER, NEXTEST_RUN } from './verdict.js';
|
|
|
2
2
|
/** Every budgeted command learns its grant here, so a script that starts a runner can size it. */
|
|
3
3
|
export const CPU_TOKENS_ENV = 'BOUNDED_EXEC_CPU_TOKENS';
|
|
4
4
|
/**
|
|
5
|
-
* The cores mbx granted the reservation a leaf runs under:
|
|
6
|
-
* as were free once one was
|
|
5
|
+
* The cores mbx granted the reservation a leaf runs under: its run's mbx reservation endpoint grants at most the N the
|
|
6
|
+
* leaf asks for, as many as were free once one was, and the leaf's shell reads that count into this variable
|
|
7
|
+
* (mbx-pool.ts, `reservation`), the one `mbx reserve --cpus N` names to its own command.
|
|
7
8
|
*/
|
|
8
9
|
export const GRANTED_CPUS_ENV = 'MBX_RESERVE_CPUS';
|
|
9
10
|
/**
|
|
@@ -262,13 +263,12 @@ export function sizeRunner(demand, command, tokens) {
|
|
|
262
263
|
/**
|
|
263
264
|
* The shell statements that run first in a reserved leaf's reservation and size its runner to the grant, which only
|
|
264
265
|
* the command learns as it starts: `CPU_TOKENS_ENV` becomes the cores mbx granted (`GRANTED_CPUS_ENV`), never more
|
|
265
|
-
* than the leaf asked for (`WANT_ENV`, set before it reserved)
|
|
266
|
-
*
|
|
267
|
-
* ceilings, outranking the target's own as a numeric grant's do (`sizeRunner`).
|
|
266
|
+
* 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`).
|
|
268
268
|
*/
|
|
269
269
|
export function grantedSizing(demand) {
|
|
270
270
|
const asked = `$${WANT_ENV}`;
|
|
271
|
-
const named =
|
|
271
|
+
const named = `$${GRANTED_CPUS_ENV}`;
|
|
272
272
|
const tokens = `$${CPU_TOKENS_ENV}`;
|
|
273
273
|
const atMost = (ceiling) => ceiling === null ? `"${tokens}"` : `"$(( ${tokens} < ${ceiling} ? ${tokens} : ${ceiling} ))"`;
|
|
274
274
|
const statements = [`export ${CPU_TOKENS_ENV}="$(( ${named} < ${asked} ? ${named} : ${asked} ))"`];
|
|
@@ -20,8 +20,9 @@ import type { NativeTestResult } from './test-result-writer.js';
|
|
|
20
20
|
* - `no-space`: the run failed and its output said a write found no space (ENOSPC). Whatever its tests then reported,
|
|
21
21
|
* they failed on the disk, not on their own: the verdict names the line that said so and, when the task held one,
|
|
22
22
|
* its RAM temp volume as it stood when that line arrived.
|
|
23
|
-
* - `queued`: the command failed before any admission after a live task PID was explicitly seen waiting in mbx
|
|
24
|
-
*
|
|
23
|
+
* - `queued`: the command failed before any admission after a live task PID was explicitly seen waiting in mbx, or
|
|
24
|
+
* while its reserved leaf's request waited on its run's mbx reservation endpoint. Its observed wait, and any public
|
|
25
|
+
* queue positions, describe admission pressure, never a wedged test.
|
|
25
26
|
* - `failed`: anything else that did not pass. That includes an assertion named in the report,
|
|
26
27
|
* or a non-zero exit with no report to say why.
|
|
27
28
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/verdict.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAmB,KAAK,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE
|
|
1
|
+
{"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/verdict.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAmB,KAAK,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA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
490
490
|
/** The same honest admission diagnostic in live output and a terminal verdict. */
|
|
491
491
|
export function describeAdmissionQueue(wait) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
.
|
|
492
|
+
const where = wait.requests.length === 0
|
|
493
|
+
? "on its run's mbx reservation endpoint"
|
|
494
|
+
: `mbx ${wait.requests
|
|
495
|
+
.map((request) => `pid=${request.pid} ticket=${request.ticket} queue position=${request.queuePosition}`)
|
|
496
|
+
.join(', ')}`;
|
|
497
|
+
return `queued for admission ${(wait.waitedMs / 1_000).toFixed(1)} s; ${where}`;
|
|
495
498
|
}
|
|
496
499
|
export function describeVerdict(verdict) {
|
|
497
500
|
switch (verdict.outcome) {
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare const createNodesV2: CreateNodesV2;
|
|
|
37
37
|
* hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
|
|
38
38
|
* other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
|
|
39
39
|
* pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
|
|
40
|
-
* it when the run ends. Last, once every task has finished, the post hook starts the reclaim of the
|
|
40
|
+
* it when the run ends, and a run with mbx's pool its mbx reservation endpoint (`mbx-reservations.ts`), which it ends then too. Last, once every task has finished, the post hook starts the reclaim of the
|
|
41
41
|
* superseded Cargo unit generations of each Cargo workspace the run built into, in a process of its own, never on
|
|
42
42
|
* Nx's thread (`@smoothbricks/cargo-retain`).
|
|
43
43
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EAGnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAGtB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{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EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmCxB"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND,
|
|
|
18
18
|
import { eslintConfigClosure } from './eslint-config-closure.js';
|
|
19
19
|
import { ESLINT_SOURCES_GLOB, eslintSources } from './eslint-sources.js';
|
|
20
20
|
import { ALL_VERDICTS_EXECUTOR, ESLINT_SOURCES_TOKEN, } from './executors/all-verdicts/schema.js';
|
|
21
|
+
import { closeRunReservations, serveRunReservations } from './executors/bounded-exec/mbx-reservations.js';
|
|
21
22
|
import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
|
|
22
23
|
import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
|
|
23
24
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
@@ -954,7 +955,7 @@ function isBuildOutputPackageJson(packageJsonPath) {
|
|
|
954
955
|
* hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
|
|
955
956
|
* other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
|
|
956
957
|
* pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
|
|
957
|
-
* it when the run ends. Last, once every task has finished, the post hook starts the reclaim of the
|
|
958
|
+
* it when the run ends, and a run with mbx's pool its mbx reservation endpoint (`mbx-reservations.ts`), which it ends then too. Last, once every task has finished, the post hook starts the reclaim of the
|
|
958
959
|
* superseded Cargo unit generations of each Cargo workspace the run built into, in a process of its own, never on
|
|
959
960
|
* Nx's thread (`@smoothbricks/cargo-retain`).
|
|
960
961
|
*/
|
|
@@ -965,11 +966,13 @@ export const preTasksExecution = async (options, context) => {
|
|
|
965
966
|
preTaskResults(options, context);
|
|
966
967
|
await preProducerReceipts(options, context);
|
|
967
968
|
await serveRunCpuPool(context);
|
|
969
|
+
await serveRunReservations(context);
|
|
968
970
|
};
|
|
969
971
|
export const postTasksExecution = async (options, context) => {
|
|
970
972
|
await postTaskResults(options, context);
|
|
971
973
|
await postProducerReceipts(options, context);
|
|
972
974
|
await closeRunCpuPool(context);
|
|
975
|
+
await closeRunReservations(context);
|
|
973
976
|
await postCargoRetention(options, context);
|
|
974
977
|
};
|
|
975
978
|
/** The lock-scope nodes' edges: each bun node's to the packages and members its manifest resolves. */
|
|
@@ -251,6 +251,10 @@ persist_devenv_environment() {
|
|
|
251
251
|
# The runner step owns these.
|
|
252
252
|
PWD | OLDPWD | SHLVL | SHELL | HOME | USER | LOGNAME | HOSTNAME | TERM | TMPDIR | TMP | TEMP | _ | PS1) continue ;;
|
|
253
253
|
GITHUB_* | RUNNER_* | ACTIONS_* | CI) continue ;;
|
|
254
|
+
# The shell Python's package path, not bookkeeping: nixpkgs' sitecustomize (which
|
|
255
|
+
# PYTHONPATH names) reads it to put the withPackages site-packages on sys.path, so a
|
|
256
|
+
# later step's python3 imports the packages the shell provides.
|
|
257
|
+
NIX_PYTHONPATH) ;;
|
|
254
258
|
# Shell-session bookkeeping, meaningful only inside the shell itself.
|
|
255
259
|
DIRENV_* | DEVENV_* | NIX_* | BASH* | XDG_* | IN_NIX_SHELL | SMOO_ENV_CAPTURE_OUT) continue ;;
|
|
256
260
|
esac
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -652,7 +652,7 @@
|
|
|
652
652
|
"@nx/js": "24.0.3",
|
|
653
653
|
"@smoothbricks/build-inputs": "0.0.2",
|
|
654
654
|
"@smoothbricks/cargo-retain": "0.0.2",
|
|
655
|
-
"@smoothbricks/cowshed": "0.4.
|
|
655
|
+
"@smoothbricks/cowshed": "0.4.5",
|
|
656
656
|
"@smoothbricks/nextest-extract": "0.0.2",
|
|
657
657
|
"jsonc-parser": "^3.3.1",
|
|
658
658
|
"minimatch": "10.2.5",
|