@smoothbricks/nx-plugin 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +59 -30
  2. package/dist/.build-inputs.json +15 -8
  3. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +3 -2
  4. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  5. package/dist/executors/bounded-exec/cpu-pool-thread.js +1 -1
  6. package/dist/executors/bounded-exec/cpu-pool.d.ts +24 -10
  7. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  8. package/dist/executors/bounded-exec/cpu-pool.js +96 -52
  9. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  10. package/dist/executors/bounded-exec/executor.js +192 -82
  11. package/dist/executors/bounded-exec/host-memory.d.ts +47 -0
  12. package/dist/executors/bounded-exec/host-memory.d.ts.map +1 -0
  13. package/dist/executors/bounded-exec/host-memory.darwin.d.ts +3 -0
  14. package/dist/executors/bounded-exec/host-memory.darwin.d.ts.map +1 -0
  15. package/dist/executors/bounded-exec/host-memory.darwin.js +40 -0
  16. package/dist/executors/bounded-exec/host-memory.js +29 -0
  17. package/dist/executors/bounded-exec/host-memory.linux.d.ts +14 -0
  18. package/dist/executors/bounded-exec/host-memory.linux.d.ts.map +1 -0
  19. package/dist/executors/bounded-exec/host-memory.linux.js +104 -0
  20. package/dist/executors/bounded-exec/leaf-peak.d.ts +55 -0
  21. package/dist/executors/bounded-exec/leaf-peak.d.ts.map +1 -0
  22. package/dist/executors/bounded-exec/leaf-peak.js +146 -0
  23. package/dist/executors/bounded-exec/mbx-pool.d.ts +17 -9
  24. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  25. package/dist/executors/bounded-exec/mbx-pool.js +29 -11
  26. package/dist/executors/bounded-exec/mbx-reservations.d.ts +41 -0
  27. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -0
  28. package/dist/executors/bounded-exec/mbx-reservations.js +372 -0
  29. package/dist/executors/bounded-exec/peak-waiter.d.ts +2 -0
  30. package/dist/executors/bounded-exec/peak-waiter.d.ts.map +1 -0
  31. package/dist/executors/bounded-exec/peak-waiter.js +53 -0
  32. package/dist/executors/bounded-exec/pool-admission.d.ts +38 -0
  33. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -0
  34. package/dist/executors/bounded-exec/pool-admission.js +31 -0
  35. package/dist/executors/bounded-exec/run-cpu-pool.d.ts +6 -4
  36. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  37. package/dist/executors/bounded-exec/run-cpu-pool.js +20 -7
  38. package/dist/executors/bounded-exec/runner-sizing.d.ts +5 -5
  39. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  40. package/dist/executors/bounded-exec/runner-sizing.js +6 -6
  41. package/dist/executors/bounded-exec/verdict.d.ts +21 -2
  42. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  43. package/dist/executors/bounded-exec/verdict.js +27 -4
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +4 -1
  47. package/package.json +1 -1
  48. package/src/executors/bounded-exec/cpu-pool-thread.ts +4 -3
  49. package/src/executors/bounded-exec/cpu-pool.ts +111 -49
  50. package/src/executors/bounded-exec/executor.ts +202 -77
  51. package/src/executors/bounded-exec/host-memory.darwin.ts +44 -0
  52. package/src/executors/bounded-exec/host-memory.linux.ts +115 -0
  53. package/src/executors/bounded-exec/host-memory.ts +70 -0
  54. package/src/executors/bounded-exec/leaf-peak.ts +151 -0
  55. package/src/executors/bounded-exec/mbx-pool.ts +33 -13
  56. package/src/executors/bounded-exec/mbx-reservations.ts +300 -0
  57. package/src/executors/bounded-exec/peak-waiter.ts +82 -0
  58. package/src/executors/bounded-exec/pool-admission.ts +64 -0
  59. package/src/executors/bounded-exec/run-cpu-pool.ts +20 -6
  60. package/src/executors/bounded-exec/runner-sizing.ts +6 -6
  61. package/src/executors/bounded-exec/verdict.ts +40 -6
  62. package/src/index.ts +4 -1
  63. package/test-timings.json +134 -131
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=peak-waiter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peak-waiter.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/peak-waiter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ import { writeSync } from 'node:fs';
2
+ import { HOST_MEMORY } from './host-memory.js';
3
+ function isBunSpawner(runtime) {
4
+ return (typeof runtime === 'object' &&
5
+ runtime !== null &&
6
+ 'spawn' in runtime &&
7
+ typeof runtime.spawn === 'function' &&
8
+ 'version' in runtime &&
9
+ typeof runtime.version === 'string');
10
+ }
11
+ const IGNORED = ['SIGINT', 'SIGTERM', 'SIGHUP'];
12
+ const bun = Reflect.get(globalThis, 'Bun');
13
+ const [reportFd, list, file, ...args] = process.argv.slice(2);
14
+ if (!isBunSpawner(bun) || HOST_MEMORY === null || reportFd === undefined || list === undefined || file === undefined) {
15
+ throw new Error('peak-waiter runs on Bun, on Linux or macOS, as `peak-waiter.js <report fd> <fds> <file> [args…]`');
16
+ }
17
+ const report = (line) => {
18
+ try {
19
+ writeSync(Number(reportFd), `${JSON.stringify(line)}\n`);
20
+ }
21
+ catch {
22
+ // The executor that would read the report is gone.
23
+ }
24
+ };
25
+ const passed = list === '' ? [] : list.split(',').map(Number);
26
+ const stdio = ['inherit', 'inherit', 'inherit'];
27
+ for (let fd = 3; fd <= Math.max(2, ...passed); fd += 1)
28
+ stdio.push(passed.includes(fd) ? fd : 'ignore');
29
+ const ignore = () => { };
30
+ for (const signal of IGNORED)
31
+ process.on(signal, ignore);
32
+ let child;
33
+ try {
34
+ child = bun.spawn([file, ...args], { stdio });
35
+ }
36
+ catch (error) {
37
+ const reason = error instanceof Error ? error.message : String(error);
38
+ report({ unmeasured: `the command did not start: ${reason}` });
39
+ writeSync(2, `bounded-exec: could not start ${file}: ${reason}\n`);
40
+ process.exit(1);
41
+ }
42
+ report({ started: child.pid });
43
+ await child.exited;
44
+ const usage = child.resourceUsage();
45
+ report(usage === undefined
46
+ ? { unmeasured: 'Bun read no resource usage for the exited command' }
47
+ : { peakBytes: HOST_MEMORY.peakBytes(usage.maxRSS, bun.version) });
48
+ if (child.signalCode !== null) {
49
+ for (const signal of IGNORED)
50
+ process.removeListener(signal, ignore);
51
+ process.kill(process.pid, child.signalCode);
52
+ }
53
+ process.exit(child.exitCode ?? 1);
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The admission decision of a CPU pool (`cpu-pool.ts`; specs/cowshed/05_gateway.md, "Without mbx, every Nx run budgets
3
+ * itself"): which queued requests a pool grants, in FIFO order, from the tokens it has free and, for a run's own pool,
4
+ * the run's memory. Pure: the pool reads its jobserver fifo for the free count and keeps the holders' charges, and this
5
+ * decides.
6
+ *
7
+ * Every grant needs both. The head takes `min(want, free)` tokens once one is free, and only while the charges of the
8
+ * leaves holding grants plus its own fit the run's memory; a head that cannot be granted holds up every request behind
9
+ * it, and no request holds part of a grant while it waits for the rest. A leaf is charged its task's last recorded
10
+ * memory peak, and nothing while its task has none. A leaf whose own charge alone exceeds the run's memory could never
11
+ * fit, so it is granted once nothing else holds memory, and the grant says so.
12
+ */
13
+ /** What a queued request asks: whole tokens, at least one, and its charge in bytes (0 for a task with no peak). */
14
+ export interface PoolAsk {
15
+ readonly want: number;
16
+ readonly memory: number;
17
+ }
18
+ /** The run's memory a pool charges against, and the bytes its holders are charged; null for a pool that charges none. */
19
+ export interface MemoryLedger {
20
+ readonly capacity: number;
21
+ readonly held: number;
22
+ }
23
+ /** One request's grant: the request, its tokens, and whether its charge alone exceeds the run's memory. */
24
+ export interface PoolGrant<Ask extends PoolAsk> {
25
+ readonly request: Ask;
26
+ readonly tokens: number;
27
+ readonly oversized: boolean;
28
+ }
29
+ /**
30
+ * The grants of the queue's first requests, in its order, and what the first request left waiting waits for: free
31
+ * tokens (`cpu`) or the run's memory (`memory`). `waiting` is null when every request was granted.
32
+ */
33
+ export interface Admission<Ask extends PoolAsk> {
34
+ readonly grants: readonly PoolGrant<Ask>[];
35
+ readonly waiting: 'cpu' | 'memory' | null;
36
+ }
37
+ export declare function admit<Ask extends PoolAsk>(queue: readonly Ask[], available: number, memory: MemoryLedger | null): Admission<Ask>;
38
+ //# sourceMappingURL=pool-admission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool-admission.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/pool-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mHAAmH;AACnH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,yHAAyH;AACzH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,2GAA2G;AAC3G,MAAM,WAAW,SAAS,CAAC,GAAG,SAAS,OAAO;IAC5C,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,GAAG,SAAS,OAAO;IAC5C,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC;CAC3C;AAED,wBAAgB,KAAK,CAAC,GAAG,SAAS,OAAO,EACvC,KAAK,EAAE,SAAS,GAAG,EAAE,EACrB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,GAAG,IAAI,GAC1B,SAAS,CAAC,GAAG,CAAC,CAkBhB"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The admission decision of a CPU pool (`cpu-pool.ts`; specs/cowshed/05_gateway.md, "Without mbx, every Nx run budgets
3
+ * itself"): which queued requests a pool grants, in FIFO order, from the tokens it has free and, for a run's own pool,
4
+ * the run's memory. Pure: the pool reads its jobserver fifo for the free count and keeps the holders' charges, and this
5
+ * decides.
6
+ *
7
+ * Every grant needs both. The head takes `min(want, free)` tokens once one is free, and only while the charges of the
8
+ * leaves holding grants plus its own fit the run's memory; a head that cannot be granted holds up every request behind
9
+ * it, and no request holds part of a grant while it waits for the rest. A leaf is charged its task's last recorded
10
+ * memory peak, and nothing while its task has none. A leaf whose own charge alone exceeds the run's memory could never
11
+ * fit, so it is granted once nothing else holds memory, and the grant says so.
12
+ */
13
+ export function admit(queue, available, memory) {
14
+ const grants = [];
15
+ let free = available;
16
+ let held = memory?.held ?? 0;
17
+ for (const request of queue) {
18
+ const oversized = memory !== null && request.memory > memory.capacity;
19
+ if (memory !== null && held + request.memory > memory.capacity && !(oversized && held === 0)) {
20
+ return { grants, waiting: 'memory' };
21
+ }
22
+ const tokens = Math.min(request.want, free);
23
+ if (tokens === 0) {
24
+ return { grants, waiting: 'cpu' };
25
+ }
26
+ free -= tokens;
27
+ held += request.memory;
28
+ grants.push({ request, tokens, oversized });
29
+ }
30
+ return { grants, waiting: null };
31
+ }
@@ -1,4 +1,5 @@
1
1
  import type { PostTasksExecutionContext, PreTasksExecutionContext } from 'nx/src/project-graph/plugins/public-api.js';
2
+ import { type RunMemoryReading } from './host-memory.js';
2
3
  /**
3
4
  * The count of the pool a run is served, or null when it is served none. A run that inherits a pool (an enclosing
4
5
  * executor's) takes from that one; with mbx, its pool is the host's one ledger, and a run pool beside it would count
@@ -6,11 +7,12 @@ import type { PostTasksExecutionContext, PreTasksExecutionContext } from 'nx/src
6
7
  */
7
8
  export declare function runPoolTokens(env: Readonly<NodeJS.ProcessEnv>, cores: number): number | null;
8
9
  /**
9
- * Serve `context`'s run a pool of `runPoolTokens` and publish it in `env`, which every task inherits, unless the run
10
- * is served none. A pool that cannot be made is said, and the run's tasks are then sized only by the ceilings they
11
- * inherit.
10
+ * Serve `context`'s run a pool of `runPoolTokens`, charged against the run's memory `readMemory` reads, and publish it
11
+ * in `env`, which every task inherits, unless the run is served none. A run whose memory cannot be read throws
12
+ * `RunMemoryUnreadable`, which fails the run before any task starts: it is not shown to have room. A pool that cannot
13
+ * be made is said, and the run's tasks are then sized only by the ceilings they inherit.
12
14
  */
13
- export declare function serveRunCpuPool(context: Pick<PreTasksExecutionContext, 'id'>, env?: NodeJS.ProcessEnv, cores?: number): Promise<void>;
15
+ export declare function serveRunCpuPool(context: Pick<PreTasksExecutionContext, 'id'>, env?: NodeJS.ProcessEnv, cores?: number, readMemory?: () => Promise<RunMemoryReading>): Promise<void>;
14
16
  /** Close the pool `context`'s run was served, if it was served one. */
15
17
  export declare function closeRunCpuPool(context: Pick<PostTasksExecutionContext, 'id'>): Promise<void>;
16
18
  //# sourceMappingURL=run-cpu-pool.d.ts.map
@@ -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;AAmDtH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5F;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,EAC7C,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,KAAK,GAAE,MAA+B,GACrC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAiED,uEAAuE;AACvE,wBAAsB,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnG"}
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,EAAE,KAAK,gBAAgB,EAAsC,MAAM,kBAAkB,CAAC;AAqD7F;;;;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;AAoED,uEAAuE;AACvE,wBAAsB,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnG"}
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url';
3
3
  import { Worker } from 'node:worker_threads';
4
4
  import { logger } from 'nx/src/devkit-exports.js';
5
5
  import { readInheritedCpuPool } from './cpu-pool.js';
6
+ import { RunMemoryUnreadable, readRunMemory } from './host-memory.js';
6
7
  import { mbxPool } from './mbx-pool.js';
7
8
  import { CPU_TOKENS_ENV, parseInheritedTokens } from './runner-sizing.js';
8
9
  /**
@@ -20,6 +21,10 @@ import { CPU_TOKENS_ENV, parseInheritedTokens } from './runner-sizing.js';
20
21
  * one token per core, or the inherited positive `BOUNDED_EXEC_CPU_TOKENS` when that is fewer: inside a cowshed job
21
22
  * that count is the job's own, so the job's `--want` bounds the run.
22
23
  *
24
+ * The pool also charges memory: each leaf is charged its task's last recorded peak, and granted only while the charges
25
+ * of the leaves holding grants and its own fit the run's memory (`host-memory.ts`: the cgroup's `memory.max` on Linux,
26
+ * else the host's). A run whose memory cannot be read does not start.
27
+ *
23
28
  * The pool runs on a thread of its own (`cpu-pool-thread.ts`). The process that serves it, the Nx daemon when installed
24
29
  * plugins load in it or the Nx CLI without one, hashes the run's tasks and builds its project graph in synchronous calls
25
30
  * on its main thread. In a gate on 2026-10-28 one `hashPlans` ran for 14.2 s, and sixteen runners queued on a pool on
@@ -51,16 +56,21 @@ export function runPoolTokens(env, cores) {
51
56
  return inherited === null ? cores : Math.min(inherited, cores);
52
57
  }
53
58
  /**
54
- * Serve `context`'s run a pool of `runPoolTokens` and publish it in `env`, which every task inherits, unless the run
55
- * is served none. A pool that cannot be made is said, and the run's tasks are then sized only by the ceilings they
56
- * inherit.
59
+ * Serve `context`'s run a pool of `runPoolTokens`, charged against the run's memory `readMemory` reads, and publish it
60
+ * in `env`, which every task inherits, unless the run is served none. A run whose memory cannot be read throws
61
+ * `RunMemoryUnreadable`, which fails the run before any task starts: it is not shown to have room. A pool that cannot
62
+ * be made is said, and the run's tasks are then sized only by the ceilings they inherit.
57
63
  */
58
- export async function serveRunCpuPool(context, env = process.env, cores = availableParallelism()) {
64
+ export async function serveRunCpuPool(context, env = process.env, cores = availableParallelism(), readMemory = readRunMemory) {
59
65
  const tokens = runPoolTokens(env, cores);
60
66
  if (tokens === null) {
61
67
  return;
62
68
  }
63
- const served = await servePoolThread(tokens);
69
+ const memory = await readMemory();
70
+ if (!memory.ok) {
71
+ throw new RunMemoryUnreadable(memory.error);
72
+ }
73
+ const served = await servePoolThread(tokens, memory.memory.bytes);
64
74
  if (!served.ok) {
65
75
  logger.warn(`bounded-exec: this run's CPU pool failed (${served.error}); its tasks are sized only by the ceilings they inherit`);
66
76
  return;
@@ -76,8 +86,11 @@ export async function serveRunCpuPool(context, env = process.env, cores = availa
76
86
  * has said how its pool closed fails whichever wait is open, a later close returns that failure, and a thread lost while
77
87
  * its pool serves is said at once.
78
88
  */
79
- function servePoolThread(tokens) {
80
- const thread = new Worker(THREAD_ENTRY, { workerData: { tokens }, ...THREAD_PRELOAD });
89
+ function servePoolThread(tokens, memory) {
90
+ const thread = new Worker(THREAD_ENTRY, {
91
+ workerData: { tokens, memory },
92
+ ...THREAD_PRELOAD,
93
+ });
81
94
  return new Promise((served) => {
82
95
  let state = { kind: 'starting', served };
83
96
  let closing;
@@ -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: `mbx reserve --cpus N` names at most N to its command, as many
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), which also stands in under an mbx that grants a
123
- * reservation whole and names none. The test-thread variables a sizing sets follow from it, under their inherited
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;;;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