@smoothbricks/nx-plugin 0.7.15 → 0.7.17
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 +15 -0
- package/dist/.build-inputs.json +10 -7
- package/dist/compile-environment.d.ts +8 -0
- package/dist/compile-environment.d.ts.map +1 -0
- package/dist/compile-environment.js +80 -0
- package/dist/dependency-manifests.d.ts +13 -0
- package/dist/dependency-manifests.d.ts.map +1 -0
- package/dist/dependency-manifests.js +20 -0
- package/dist/executors/bounded-exec/child-exit-diagnostics.d.ts +45 -0
- package/dist/executors/bounded-exec/child-exit-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/child-exit-diagnostics.js +188 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +10 -1
- package/dist/executors/bounded-exec/host-memory.d.ts +11 -0
- package/dist/executors/bounded-exec/host-memory.d.ts.map +1 -1
- package/dist/executors/bounded-exec/host-memory.darwin.d.ts.map +1 -1
- package/dist/executors/bounded-exec/host-memory.darwin.js +1 -0
- package/dist/executors/bounded-exec/host-memory.linux.d.ts +3 -1
- package/dist/executors/bounded-exec/host-memory.linux.d.ts.map +1 -1
- package/dist/executors/bounded-exec/host-memory.linux.js +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -8
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/typecheck-route.d.ts +3 -4
- package/dist/typecheck-route.d.ts.map +1 -1
- package/dist/typecheck-route.js +4 -15
- package/managed/raw/patches/{ttsc@0.34.1.patch → ttsc@0.36.3.patch} +728 -71
- package/managed/raw/tooling/direnv/devenv.smoo.nix +1 -1
- package/package.json +9 -4
- package/src/compile-environment.ts +35 -0
- package/src/dependency-manifests.ts +30 -0
- package/src/executors/bounded-exec/child-exit-diagnostics.ts +87 -0
- package/src/executors/bounded-exec/executor.ts +10 -1
- package/src/executors/bounded-exec/host-memory.darwin.ts +1 -0
- package/src/executors/bounded-exec/host-memory.linux.ts +25 -2
- package/src/executors/bounded-exec/host-memory.ts +7 -0
- package/src/index.ts +17 -8
- package/src/managed-files/files.ts +3 -3
- package/src/typecheck-route.ts +5 -14
- package/test-timings.json +138 -137
package/README.md
CHANGED
|
@@ -1279,6 +1279,12 @@ Concrete targets come from concrete files:
|
|
|
1279
1279
|
and never compiles one, and the inference guesses no workspace target. A declaration of another shape refuses the
|
|
1280
1280
|
inference by its manifest path. Its compiler is the installed ttsc, which `bun.lock` and the patches in the check
|
|
1281
1281
|
inputs already key. A project that depends only on typia stays on the pinned compiler.
|
|
1282
|
+
- A direct dependency whose ttsc plugin lowers by environment variables declares them in its manifest,
|
|
1283
|
+
`"smoo": { "compileEnv": ["NODE_ENV"] }` (`@smoothbricks/lmao-ttsc` does: it compiles trace statements away unless
|
|
1284
|
+
`NODE_ENV` is `test`). The transformed JavaScript is then a function of those variables, so `tsc-js` and every scriptc
|
|
1285
|
+
target hash each as an `{ "env": … }` input; `typecheck` does not, as no check reads them. A declaration of another
|
|
1286
|
+
shape refuses the inference by its manifest path. Targets a project declares itself, and test targets, list the input
|
|
1287
|
+
in their own `inputs`.
|
|
1282
1288
|
- `typecheck-tests` is inferred from `tsconfig.test.json` and runs the same compiler on
|
|
1283
1289
|
`-p tsconfig.test.json --noEmit`. It first rebuilds the current package's `tsc-js` output (or its non-TypeScript
|
|
1284
1290
|
`build`) so self-imports resolve from its own outputs. Transform calls in test files are checked when the test runner
|
|
@@ -2494,6 +2500,15 @@ and says so. A host CI scope's first run of a task it holds no record of is the
|
|
|
2494
2500
|
release workflow's CI's) and takes, at each run, the record of every task the scope lacks
|
|
2495
2501
|
(`specs/cowshed/05_gateway.md`, "Without mbx, every Nx run budgets itself").
|
|
2496
2502
|
|
|
2503
|
+
A child-runtime owner can diagnose a death without guessing from its WebSocket close. `bounded-exec` passes the
|
|
2504
|
+
memory-bearing grant's immutable charge/bound and its installed observer module URL through
|
|
2505
|
+
`BOUNDED_EXEC_MEMORY_DIAGNOSTICS` / `BOUNDED_EXEC_DIAGNOSTICS_MODULE`. `observeChildMemory(pid, context)` returns a
|
|
2506
|
+
stop-and-snapshot function called at the child's exit: the last readable, timestamped RSS and the existing bound's live
|
|
2507
|
+
anon/shmem reading at exit. An unavailable reading carries its reason. Nested sub-pools retain the memory-bearing
|
|
2508
|
+
ancestor's facts; these fields never change admission, runner sizing or retry policy. The runtime owner adds the actual
|
|
2509
|
+
exit code/signal and prints its structured diagnostic before its existing crash handling. See 05_gateway's “A dead child
|
|
2510
|
+
keeps its diagnosis”; a SIGKILL without kernel evidence is not an OOM verdict.
|
|
2511
|
+
|
|
2497
2512
|
The pool runs on a worker thread of its own (`cpu-pool-thread.ts`). The process that serves the run, the Nx daemon when
|
|
2498
2513
|
installed plugins load in it or the Nx CLI without one, hashes tasks and builds the project graph in synchronous calls
|
|
2499
2514
|
on its main thread; a pool on that thread wrote no heartbeat behind a 14.2 s `hashPlans`, and every runner queued on it
|
package/dist/.build-inputs.json
CHANGED
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"packages/nx-plugin/src/cargo-toolchain-paths.ts": "3c622c19ed7a43166e81f9a92e8ab0e3b607690add5408cd96e95912ecf4c4c1",
|
|
25
25
|
"packages/nx-plugin/src/cargo-toolchain-policy.ts": "9c7bae572b57046dcc1e3d577b4abb25e877cf551efcca1b837c4bb5a8c62203",
|
|
26
26
|
"packages/nx-plugin/src/cargo-workspace.ts": "ecbe5e0545e07a68ba02d18a2ed362a545e902e947a52af1dab112b71f91f633",
|
|
27
|
+
"packages/nx-plugin/src/compile-environment.ts": "8085b28e695f60306eefb91f3eca3e1bb908d7ea1676d028c7c85a6adda1a95c",
|
|
27
28
|
"packages/nx-plugin/src/cross-check-policy.ts": "3a22f798805dca09f6452d929d86c0d76621bdd32d5d1f21fe02c75cf7335e2f",
|
|
29
|
+
"packages/nx-plugin/src/dependency-manifests.ts": "2acc8497dbf07e432a1a093c7c2fd8765bc4c3e089be7b332ea7d239e280d0b0",
|
|
28
30
|
"packages/nx-plugin/src/deploy-policy.ts": "2f6202000dceca84d472f417affce50fd2ec3cab87c969443d83ec6e1d4ccf71",
|
|
29
31
|
"packages/nx-plugin/src/disk-command-policy.ts": "fb8731ccf41cff47b88f30165b08dc8d551068c436f4e49cb2b62aa4b49be43c",
|
|
30
32
|
"packages/nx-plugin/src/ensure-built-receipt.ts": "f80084d91d37c5132822bf26b45e6a9ae35e54e366cedbb9d69a2abd663ca419",
|
|
@@ -37,16 +39,17 @@
|
|
|
37
39
|
"packages/nx-plugin/src/executors/all-verdicts/schema.ts": "2ca6bd8d2f19d851f291ab6a5227167399b9dc8ed0fda0248b69896d77e471f1",
|
|
38
40
|
"packages/nx-plugin/src/executors/bounded-exec/admission-queue.ts": "86664180f8296032f7c96022a790285799e666d92360a10b7a5cc6f3facd58eb",
|
|
39
41
|
"packages/nx-plugin/src/executors/bounded-exec/bounds.ts": "fecc48ea66df1c2ba526dc0322ab7760cfc1a4e85d99a72a7a43f040448970f0",
|
|
42
|
+
"packages/nx-plugin/src/executors/bounded-exec/child-exit-diagnostics.ts": "fdcd4e074577814d9b7b9d014d2c39297e9c763bd570d9fab0db172349e039b2",
|
|
40
43
|
"packages/nx-plugin/src/executors/bounded-exec/cpu-grant.ts": "c5217349c23be537d9b6a0a52445f3ee442402fdbd08f1d33a3095c52051616d",
|
|
41
44
|
"packages/nx-plugin/src/executors/bounded-exec/cpu-pool-thread.ts": "47697a9531df5fd6fcdf4e706fc7e5874bca1717c838496673bf148c691f1e9e",
|
|
42
45
|
"packages/nx-plugin/src/executors/bounded-exec/cpu-pool.ts": "bc122174ccf628b769c73197b7a78987d033b5e7ea6cb5ddbeac384310fdd22a",
|
|
43
46
|
"packages/nx-plugin/src/executors/bounded-exec/disk-lease.ts": "1a3f6a6fa590d9a2550490bb6906dc91b6c05fbef235b025eaf257eb5310e92d",
|
|
44
|
-
"packages/nx-plugin/src/executors/bounded-exec/executor.ts": "
|
|
47
|
+
"packages/nx-plugin/src/executors/bounded-exec/executor.ts": "0840b55ecbb2e12b0a9821513a786f5f027b93cf940606ca4f2a11fde4a38c31",
|
|
45
48
|
"packages/nx-plugin/src/executors/bounded-exec/gateway-lease.ts": "f3f73bd92db30e4857f98fb8bd2b9a75b2a5a2a318f094e075ed803c1f9a0117",
|
|
46
49
|
"packages/nx-plugin/src/executors/bounded-exec/hang-diagnostics.ts": "bcaa9e52384f6c481a9cc2835ba6e8ffe167afa3cb51623fdf8dc3493876f335",
|
|
47
|
-
"packages/nx-plugin/src/executors/bounded-exec/host-memory.darwin.ts": "
|
|
48
|
-
"packages/nx-plugin/src/executors/bounded-exec/host-memory.linux.ts": "
|
|
49
|
-
"packages/nx-plugin/src/executors/bounded-exec/host-memory.ts": "
|
|
50
|
+
"packages/nx-plugin/src/executors/bounded-exec/host-memory.darwin.ts": "fe89fc99f85f48caec7c614cfd976c362253b9707797c2c849a3aa9664e65dbe",
|
|
51
|
+
"packages/nx-plugin/src/executors/bounded-exec/host-memory.linux.ts": "752519893ed6fc3b9d7d17b0b0801d7103129f7a838743d129057debf043f0c1",
|
|
52
|
+
"packages/nx-plugin/src/executors/bounded-exec/host-memory.ts": "d3eef7fb06bf259f0f7f7dc67fc7f246a39adf5e4e80850fd4565e91626b1ec5",
|
|
50
53
|
"packages/nx-plugin/src/executors/bounded-exec/leaf-peak.ts": "0b1b94992b2cbb9e3759785424ceb202667053c5571edf3a79cdd0b206e54a1d",
|
|
51
54
|
"packages/nx-plugin/src/executors/bounded-exec/lease-wait.ts": "59d8ac94d0b8b75858971c5bb28ee421fca4f7685577274fe8bbaf0c01ba462a",
|
|
52
55
|
"packages/nx-plugin/src/executors/bounded-exec/lock-wait.ts": "b14a23b49759a777f4b3338ced003adaf76837c2c38462458f76a7fef1b95d9e",
|
|
@@ -101,11 +104,11 @@
|
|
|
101
104
|
"packages/nx-plugin/src/generators/make-public/schema.d.ts": "5e7bd2f1ce16795df4c919d6d53588ea85b574c84400940b6322275f96f60357",
|
|
102
105
|
"packages/nx-plugin/src/go-tests.ts": "8e356b6ee276e6e836c404353b0ffb5ccec5beb261126f167f730e6e01e9c2b6",
|
|
103
106
|
"packages/nx-plugin/src/graph-input-contract.ts": "8a1aec1294960ae80bcff55a0370c95004a911bf1afe6caa47e666da3baeac43",
|
|
104
|
-
"packages/nx-plugin/src/index.ts": "
|
|
107
|
+
"packages/nx-plugin/src/index.ts": "97cd2243f28c4bf75a2be30b2e21fb4573f6ce13ce96af6236590daee54f4744",
|
|
105
108
|
"packages/nx-plugin/src/managed-assets.ts": "9cea959c09f3163992e666eecc5a65ec1f1b63c81fc56c5e99088507d02c5e3b",
|
|
106
109
|
"packages/nx-plugin/src/managed-files/ci-workflow.ts": "c48f80cf3b215a8b41fdeb220e653a3a26ee288e833b1bb215f8f15de006e5ae",
|
|
107
110
|
"packages/nx-plugin/src/managed-files/context.ts": "472553c8e15f5bb72f7167ca3f3c5ce5171f479a3cdf2fb4b9f86d1f1addf4bd",
|
|
108
|
-
"packages/nx-plugin/src/managed-files/files.ts": "
|
|
111
|
+
"packages/nx-plugin/src/managed-files/files.ts": "0e4010a194cc3ae89cc05ba1d3482d607fd3e39dd776edf0eaa8e38804e5d897",
|
|
109
112
|
"packages/nx-plugin/src/managed-files/generator.ts": "8cf1a1b121645c5ead86c163c9da03f612efb2fff6aabed3ea858d87d6cbd0b3",
|
|
110
113
|
"packages/nx-plugin/src/managed-files/github-runs-on.ts": "a049ca60a79dec57f77e5d18090569a9b8b78818219f236fe352e7705500f531",
|
|
111
114
|
"packages/nx-plugin/src/managed-files/json-edit.ts": "81bc6dd10fffff583cc9f2269f0c2fd2f76b1c5aedbc7d068cf29878371497c2",
|
|
@@ -144,7 +147,7 @@
|
|
|
144
147
|
"packages/nx-plugin/src/testing.ts": "ef26d48eb7b90d682778cbbff678c9cc25df57a6775cb58b8c925e8fb829fe6a",
|
|
145
148
|
"packages/nx-plugin/src/tool-bins.ts": "8e5b194d76ce854fd33ad464017c021af401a2d92383f5c31168652b73656601",
|
|
146
149
|
"packages/nx-plugin/src/type-guards.ts": "87d87a9bb83f0f4614b9f615d8cc7347772cb1418dc1946978987147c0d6ef0c",
|
|
147
|
-
"packages/nx-plugin/src/typecheck-route.ts": "
|
|
150
|
+
"packages/nx-plugin/src/typecheck-route.ts": "90d47be308cb510b252451747d1eaaa2675f79c1687070e39fc7d2578abdb476",
|
|
148
151
|
"packages/nx-plugin/src/typecheck-test-policy.ts": "5f6b1ff0dbf4bcac84721e60452790fb5e4ce41ee35ca2f1d033d51575ed53d7",
|
|
149
152
|
"packages/nx-plugin/src/version-actions.cts": "c579ed33d5641bd487024429758582fe1f7bde376cfbd4a4a4325aa70fb71883",
|
|
150
153
|
"packages/nx-plugin/src/wait-why-policy.ts": "f10a5370665c0c38dc778d7532b2cd2b008221efea097b788aeaba8ee63745ea",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DependencyManifest } from './dependency-manifests.js';
|
|
2
|
+
/**
|
|
3
|
+
* The environment variables a project's transformed output depends on, over its direct dependencies' manifests, once
|
|
4
|
+
* each in declaration order. A manifest that declares `smoo.compileEnv` in another shape refuses the inference by its
|
|
5
|
+
* path and the field it got wrong.
|
|
6
|
+
*/
|
|
7
|
+
export declare function compileEnvironment(manifests: readonly DependencyManifest[]): string[];
|
|
8
|
+
//# sourceMappingURL=compile-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-environment.d.ts","sourceRoot":"","sources":["../src/compile-environment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAcpE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAcrF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as _validateReport_1 from "typia/lib/internal/_validateReport";
|
|
2
|
+
import * as _createStandardSchema_1 from "typia/lib/internal/_createStandardSchema";
|
|
3
|
+
import typia from 'typia';
|
|
4
|
+
const validateManifest = (() => {
|
|
5
|
+
let errors;
|
|
6
|
+
let _report;
|
|
7
|
+
const _io0 = input => undefined === input.smoo || "object" === typeof input.smoo && null !== input.smoo && false === Array.isArray(input.smoo) && _io1(input.smoo);
|
|
8
|
+
const _io1 = input => undefined === input.compileEnv || Array.isArray(input.compileEnv) && input.compileEnv.every(elem => "string" === typeof elem);
|
|
9
|
+
const _vo0 = (input, _path, _exceptionable = true) => [undefined === input.smoo || ("object" === typeof input.smoo && null !== input.smoo && false === Array.isArray(input.smoo) || _report(_exceptionable, {
|
|
10
|
+
path: _path + ".smoo",
|
|
11
|
+
expected: "(undefined | { readonly compileEnv?: readonly string[] | undefined; })",
|
|
12
|
+
value: input.smoo
|
|
13
|
+
})) && _vo1(input.smoo, _path + ".smoo", true && _exceptionable) || _report(_exceptionable, {
|
|
14
|
+
path: _path + ".smoo",
|
|
15
|
+
expected: "(undefined | { readonly compileEnv?: readonly string[] | undefined; })",
|
|
16
|
+
value: input.smoo
|
|
17
|
+
})].every(flag => flag);
|
|
18
|
+
const _vo1 = (input, _path, _exceptionable = true) => [undefined === input.compileEnv || (Array.isArray(input.compileEnv) || _report(_exceptionable, {
|
|
19
|
+
path: _path + ".compileEnv",
|
|
20
|
+
expected: "(ReadonlyArray<string> | undefined)",
|
|
21
|
+
value: input.compileEnv
|
|
22
|
+
})) && input.compileEnv.map((elem, _index2) => "string" === typeof elem || _report(_exceptionable, {
|
|
23
|
+
path: _path + ".compileEnv[" + _index2 + "]",
|
|
24
|
+
expected: "string",
|
|
25
|
+
value: elem
|
|
26
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
27
|
+
path: _path + ".compileEnv",
|
|
28
|
+
expected: "(ReadonlyArray<string> | undefined)",
|
|
29
|
+
value: input.compileEnv
|
|
30
|
+
})].every(flag => flag);
|
|
31
|
+
const __is = input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
|
|
32
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
33
|
+
if (false === __is(input)) {
|
|
34
|
+
errors = [];
|
|
35
|
+
_report = _validateReport_1._validateReport(errors);
|
|
36
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input && false === Array.isArray(input) || _report(true, {
|
|
37
|
+
path: _path + "",
|
|
38
|
+
expected: "DeclaringManifest",
|
|
39
|
+
value: input
|
|
40
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
41
|
+
path: _path + "",
|
|
42
|
+
expected: "DeclaringManifest",
|
|
43
|
+
value: input
|
|
44
|
+
}))(input, "$input", true);
|
|
45
|
+
const success = 0 === errors.length;
|
|
46
|
+
return success ? {
|
|
47
|
+
success,
|
|
48
|
+
data: input
|
|
49
|
+
} : {
|
|
50
|
+
success,
|
|
51
|
+
errors,
|
|
52
|
+
data: input
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
success: true,
|
|
57
|
+
data: input
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
})();
|
|
61
|
+
/**
|
|
62
|
+
* The environment variables a project's transformed output depends on, over its direct dependencies' manifests, once
|
|
63
|
+
* each in declaration order. A manifest that declares `smoo.compileEnv` in another shape refuses the inference by its
|
|
64
|
+
* path and the field it got wrong.
|
|
65
|
+
*/
|
|
66
|
+
export function compileEnvironment(manifests) {
|
|
67
|
+
const names = [];
|
|
68
|
+
for (const manifest of manifests) {
|
|
69
|
+
const checked = validateManifest(manifest.json);
|
|
70
|
+
if (!checked.success) {
|
|
71
|
+
throw new Error(`${manifest.path}: smoo.compileEnv must be ['<VARIABLE>', ...]: ${checked.errors
|
|
72
|
+
.map((error) => `${error.path} expected ${error.expected}`)
|
|
73
|
+
.join('; ')}`);
|
|
74
|
+
}
|
|
75
|
+
for (const name of checked.data.smoo?.compileEnv ?? [])
|
|
76
|
+
if (!names.includes(name))
|
|
77
|
+
names.push(name);
|
|
78
|
+
}
|
|
79
|
+
return names;
|
|
80
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** One installed direct dependency's manifest: its package name, where it is, and its parsed JSON. */
|
|
2
|
+
export interface DependencyManifest {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly json: unknown;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The manifests of a project's direct dependencies, the ones ttsc discovers plugins on (`dependencies` and
|
|
9
|
+
* `devDependencies`), once per name. Each is the manifest Node resolution reaches from the project, as ttsc reads it;
|
|
10
|
+
* a dependency that is not installed has none. Read once per project, for every declaration inference reads from them.
|
|
11
|
+
*/
|
|
12
|
+
export declare function directDependencyManifests(packageJsonPath: string, dependencies: readonly string[]): DependencyManifest[];
|
|
13
|
+
//# sourceMappingURL=dependency-manifests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency-manifests.d.ts","sourceRoot":"","sources":["../src/dependency-manifests.ts"],"names":[],"mappings":"AAIA,sGAAsG;AACtG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,SAAS,MAAM,EAAE,GAC9B,kBAAkB,EAAE,CAUtB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
/**
|
|
5
|
+
* The manifests of a project's direct dependencies, the ones ttsc discovers plugins on (`dependencies` and
|
|
6
|
+
* `devDependencies`), once per name. Each is the manifest Node resolution reaches from the project, as ttsc reads it;
|
|
7
|
+
* a dependency that is not installed has none. Read once per project, for every declaration inference reads from them.
|
|
8
|
+
*/
|
|
9
|
+
export function directDependencyManifests(packageJsonPath, dependencies) {
|
|
10
|
+
const lookup = createRequire(packageJsonPath);
|
|
11
|
+
const manifests = [];
|
|
12
|
+
for (const name of new Set(dependencies)) {
|
|
13
|
+
const path = (lookup.resolve.paths(name) ?? [])
|
|
14
|
+
.map((root) => join(root, ...name.split('/'), 'package.json'))
|
|
15
|
+
.find((candidate) => existsSync(candidate));
|
|
16
|
+
if (path !== undefined)
|
|
17
|
+
manifests.push({ name, path, json: JSON.parse(readFileSync(path, 'utf-8')) });
|
|
18
|
+
}
|
|
19
|
+
return manifests;
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type LiveUsageReading, type ResidentUsageReading, type RunMemoryReading } from './host-memory.js';
|
|
2
|
+
/** Diagnostic facts, not configuration: neither value changes a grant or a runner's parallelism. */
|
|
3
|
+
export declare const DIAGNOSTIC_CONTEXT_ENV = "BOUNDED_EXEC_MEMORY_DIAGNOSTICS";
|
|
4
|
+
export declare const DIAGNOSTIC_MODULE_ENV = "BOUNDED_EXEC_DIAGNOSTICS_MODULE";
|
|
5
|
+
/** A sub-pool charges no memory: descendants retain the memory-bearing ancestor's facts. */
|
|
6
|
+
export declare function grantMemoryEnvironment(chargedBytes: number | null, inherited: Readonly<NodeJS.ProcessEnv>, readMemory?: () => Promise<RunMemoryReading>): Promise<Record<string, string>>;
|
|
7
|
+
export interface ResidentSample {
|
|
8
|
+
readonly sampledAtMs: number;
|
|
9
|
+
readonly reading: ResidentUsageReading;
|
|
10
|
+
}
|
|
11
|
+
/** The original grant plus the bound's live reading at exit, never a new accounting ledger. */
|
|
12
|
+
export declare function childExitMemory(contextText: string | undefined, lastResident: ResidentSample, readLive?: (bound: string) => LiveUsageReading): {
|
|
13
|
+
lastResident: ResidentSample;
|
|
14
|
+
pool: {
|
|
15
|
+
ok: false;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
lastResident: ResidentSample;
|
|
20
|
+
pool: {
|
|
21
|
+
chargedBytes: number;
|
|
22
|
+
bound: RunMemoryReading;
|
|
23
|
+
reason?: undefined;
|
|
24
|
+
ok: true;
|
|
25
|
+
live: LiveUsageReading;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/** Retains the last readable sample through PID exit; stop is called by the child's exit event. */
|
|
29
|
+
export declare function observeChildMemory(pid: number, contextText: string | undefined): () => {
|
|
30
|
+
lastResident: ResidentSample;
|
|
31
|
+
pool: {
|
|
32
|
+
ok: false;
|
|
33
|
+
reason: string;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
lastResident: ResidentSample;
|
|
37
|
+
pool: {
|
|
38
|
+
chargedBytes: number;
|
|
39
|
+
bound: RunMemoryReading;
|
|
40
|
+
reason?: undefined;
|
|
41
|
+
ok: true;
|
|
42
|
+
live: LiveUsageReading;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=child-exit-diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-exit-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/child-exit-diagnostics.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAGtB,MAAM,kBAAkB,CAAC;AAE1B,oGAAoG;AACpG,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AACxE,eAAO,MAAM,qBAAqB,oCAAoC,CAAC;AAQvE,4FAA4F;AAC5F,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EACtC,UAAU,GAAE,MAAM,OAAO,CAAC,gBAAgB,CAAiB,GAC1D,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CASjC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;CACxC;AAED,+FAA+F;AAC/F,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,YAAY,EAAE,cAAc,EAC5B,QAAQ,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,gBAAgC;;;QAG5B,EAAE;QAAkB,MAAM;;;;;sBAjCpC,MAAM;eACb,gBAAgB;;;;;EAiDjC;AAED,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS;;;QApB5C,EAAE;QAAkB,MAAM;;;;;sBAjCpC,MAAM;eACb,gBAAgB;;;;;EAsEjC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as _assertGuard_1 from "typia/lib/internal/_assertGuard";
|
|
2
|
+
import typia from 'typia';
|
|
3
|
+
import { HOST_MEMORY, readLiveUsage, readRunMemory, } from './host-memory.js';
|
|
4
|
+
/** Diagnostic facts, not configuration: neither value changes a grant or a runner's parallelism. */
|
|
5
|
+
export const DIAGNOSTIC_CONTEXT_ENV = 'BOUNDED_EXEC_MEMORY_DIAGNOSTICS';
|
|
6
|
+
export const DIAGNOSTIC_MODULE_ENV = 'BOUNDED_EXEC_DIAGNOSTICS_MODULE';
|
|
7
|
+
const parseContext = (() => {
|
|
8
|
+
let _errorFactory;
|
|
9
|
+
const _ao0 = (input, _path, _exceptionable = true) => ("number" === typeof input.chargedBytes || _assertGuard_1._assertGuard(_exceptionable, {
|
|
10
|
+
method: "typia.json.createAssertParse",
|
|
11
|
+
path: _path + ".chargedBytes",
|
|
12
|
+
expected: "number",
|
|
13
|
+
value: input.chargedBytes
|
|
14
|
+
}, _errorFactory)) && (("object" === typeof input.bound && null !== input.bound || _assertGuard_1._assertGuard(_exceptionable, {
|
|
15
|
+
method: "typia.json.createAssertParse",
|
|
16
|
+
path: _path + ".bound",
|
|
17
|
+
expected: "({ readonly ok: false; readonly error: RunMemoryError; } | { readonly ok: true; readonly memory: RunMemory; })",
|
|
18
|
+
value: input.bound
|
|
19
|
+
}, _errorFactory)) && _au0(input.bound, _path + ".bound", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
|
|
20
|
+
method: "typia.json.createAssertParse",
|
|
21
|
+
path: _path + ".bound",
|
|
22
|
+
expected: "({ readonly ok: false; readonly error: RunMemoryError; } | { readonly ok: true; readonly memory: RunMemory; })",
|
|
23
|
+
value: input.bound
|
|
24
|
+
}, _errorFactory));
|
|
25
|
+
const _ao1 = (input, _path, _exceptionable = true) => (true === input.ok || _assertGuard_1._assertGuard(_exceptionable, {
|
|
26
|
+
method: "typia.json.createAssertParse",
|
|
27
|
+
path: _path + ".ok",
|
|
28
|
+
expected: "true",
|
|
29
|
+
value: input.ok
|
|
30
|
+
}, _errorFactory)) && (("object" === typeof input.memory && null !== input.memory || _assertGuard_1._assertGuard(_exceptionable, {
|
|
31
|
+
method: "typia.json.createAssertParse",
|
|
32
|
+
path: _path + ".memory",
|
|
33
|
+
expected: "RunMemory",
|
|
34
|
+
value: input.memory
|
|
35
|
+
}, _errorFactory)) && _ao2(input.memory, _path + ".memory", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
|
|
36
|
+
method: "typia.json.createAssertParse",
|
|
37
|
+
path: _path + ".memory",
|
|
38
|
+
expected: "RunMemory",
|
|
39
|
+
value: input.memory
|
|
40
|
+
}, _errorFactory));
|
|
41
|
+
const _ao2 = (input, _path, _exceptionable = true) => ("number" === typeof input.bytes || _assertGuard_1._assertGuard(_exceptionable, {
|
|
42
|
+
method: "typia.json.createAssertParse",
|
|
43
|
+
path: _path + ".bytes",
|
|
44
|
+
expected: "number",
|
|
45
|
+
value: input.bytes
|
|
46
|
+
}, _errorFactory)) && ("string" === typeof input.source || _assertGuard_1._assertGuard(_exceptionable, {
|
|
47
|
+
method: "typia.json.createAssertParse",
|
|
48
|
+
path: _path + ".source",
|
|
49
|
+
expected: "string",
|
|
50
|
+
value: input.source
|
|
51
|
+
}, _errorFactory));
|
|
52
|
+
const _ao3 = (input, _path, _exceptionable = true) => (false === input.ok || _assertGuard_1._assertGuard(_exceptionable, {
|
|
53
|
+
method: "typia.json.createAssertParse",
|
|
54
|
+
path: _path + ".ok",
|
|
55
|
+
expected: "false",
|
|
56
|
+
value: input.ok
|
|
57
|
+
}, _errorFactory)) && (("object" === typeof input.error && null !== input.error || _assertGuard_1._assertGuard(_exceptionable, {
|
|
58
|
+
method: "typia.json.createAssertParse",
|
|
59
|
+
path: _path + ".error",
|
|
60
|
+
expected: "RunMemoryError",
|
|
61
|
+
value: input.error
|
|
62
|
+
}, _errorFactory)) && _ao4(input.error, _path + ".error", true && _exceptionable) || _assertGuard_1._assertGuard(_exceptionable, {
|
|
63
|
+
method: "typia.json.createAssertParse",
|
|
64
|
+
path: _path + ".error",
|
|
65
|
+
expected: "RunMemoryError",
|
|
66
|
+
value: input.error
|
|
67
|
+
}, _errorFactory));
|
|
68
|
+
const _ao4 = (input, _path, _exceptionable = true) => ("read-run-memory" === input.operation || _assertGuard_1._assertGuard(_exceptionable, {
|
|
69
|
+
method: "typia.json.createAssertParse",
|
|
70
|
+
path: _path + ".operation",
|
|
71
|
+
expected: "\"read-run-memory\"",
|
|
72
|
+
value: input.operation
|
|
73
|
+
}, _errorFactory)) && ("malformed" === input.code || "unmounted" === input.code || "unreadable" === input.code || "unsupported-platform" === input.code || _assertGuard_1._assertGuard(_exceptionable, {
|
|
74
|
+
method: "typia.json.createAssertParse",
|
|
75
|
+
path: _path + ".code",
|
|
76
|
+
expected: "(\"malformed\" | \"unmounted\" | \"unreadable\" | \"unsupported-platform\")",
|
|
77
|
+
value: input.code
|
|
78
|
+
}, _errorFactory)) && ("string" === typeof input.subject || _assertGuard_1._assertGuard(_exceptionable, {
|
|
79
|
+
method: "typia.json.createAssertParse",
|
|
80
|
+
path: _path + ".subject",
|
|
81
|
+
expected: "string",
|
|
82
|
+
value: input.subject
|
|
83
|
+
}, _errorFactory)) && ("string" === typeof input.cause || _assertGuard_1._assertGuard(_exceptionable, {
|
|
84
|
+
method: "typia.json.createAssertParse",
|
|
85
|
+
path: _path + ".cause",
|
|
86
|
+
expected: "string",
|
|
87
|
+
value: input.cause
|
|
88
|
+
}, _errorFactory));
|
|
89
|
+
const _au0 = (input, _path, _exceptionable = true) => (() => {
|
|
90
|
+
if (true === input.ok)
|
|
91
|
+
return _ao1(input, _path, true && _exceptionable);
|
|
92
|
+
else if (false === input.ok)
|
|
93
|
+
return _ao3(input, _path, true && _exceptionable);
|
|
94
|
+
else
|
|
95
|
+
return _assertGuard_1._assertGuard(_exceptionable, {
|
|
96
|
+
method: "typia.json.createAssertParse",
|
|
97
|
+
path: _path,
|
|
98
|
+
expected: "({ readonly ok: true; readonly memory: RunMemory; } | { readonly ok: false; readonly error: RunMemoryError; })",
|
|
99
|
+
value: input
|
|
100
|
+
}, _errorFactory);
|
|
101
|
+
})();
|
|
102
|
+
const _io0 = input => "number" === typeof input.chargedBytes && ("object" === typeof input.bound && null !== input.bound && _iu0(input.bound));
|
|
103
|
+
const _io1 = input => true === input.ok && ("object" === typeof input.memory && null !== input.memory && _io2(input.memory));
|
|
104
|
+
const _io2 = input => "number" === typeof input.bytes && "string" === typeof input.source;
|
|
105
|
+
const _io3 = input => false === input.ok && ("object" === typeof input.error && null !== input.error && _io4(input.error));
|
|
106
|
+
const _io4 = input => "read-run-memory" === input.operation && ("malformed" === input.code || "unmounted" === input.code || "unreadable" === input.code || "unsupported-platform" === input.code) && "string" === typeof input.subject && "string" === typeof input.cause;
|
|
107
|
+
const _iu0 = input => (() => {
|
|
108
|
+
if (true === input.ok)
|
|
109
|
+
return _io1(input);
|
|
110
|
+
else if (false === input.ok)
|
|
111
|
+
return _io3(input);
|
|
112
|
+
else
|
|
113
|
+
return false;
|
|
114
|
+
})();
|
|
115
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
116
|
+
const __assert = (input, errorFactory) => {
|
|
117
|
+
if (false === __is(input)) {
|
|
118
|
+
_errorFactory = errorFactory;
|
|
119
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _assertGuard_1._assertGuard(true, {
|
|
120
|
+
method: "typia.json.createAssertParse",
|
|
121
|
+
path: _path + "",
|
|
122
|
+
expected: "GrantMemoryContext",
|
|
123
|
+
value: input
|
|
124
|
+
}, _errorFactory)) && _ao0(input, _path + "", true) || _assertGuard_1._assertGuard(true, {
|
|
125
|
+
method: "typia.json.createAssertParse",
|
|
126
|
+
path: _path + "",
|
|
127
|
+
expected: "GrantMemoryContext",
|
|
128
|
+
value: input
|
|
129
|
+
}, _errorFactory))(input, "$input", true);
|
|
130
|
+
}
|
|
131
|
+
return input;
|
|
132
|
+
};
|
|
133
|
+
return (input, errorFactory) => __assert(JSON.parse(input), errorFactory);
|
|
134
|
+
})();
|
|
135
|
+
/** A sub-pool charges no memory: descendants retain the memory-bearing ancestor's facts. */
|
|
136
|
+
export async function grantMemoryEnvironment(chargedBytes, inherited, readMemory = readRunMemory) {
|
|
137
|
+
if (chargedBytes === null) {
|
|
138
|
+
return {
|
|
139
|
+
[DIAGNOSTIC_CONTEXT_ENV]: inherited[DIAGNOSTIC_CONTEXT_ENV] ?? '',
|
|
140
|
+
[DIAGNOSTIC_MODULE_ENV]: inherited[DIAGNOSTIC_MODULE_ENV] ?? '',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const context = { chargedBytes, bound: await readMemory() };
|
|
144
|
+
return { [DIAGNOSTIC_CONTEXT_ENV]: JSON.stringify(context), [DIAGNOSTIC_MODULE_ENV]: import.meta.url };
|
|
145
|
+
}
|
|
146
|
+
/** The original grant plus the bound's live reading at exit, never a new accounting ledger. */
|
|
147
|
+
export function childExitMemory(contextText, lastResident, readLive = readLiveUsage) {
|
|
148
|
+
if (!contextText)
|
|
149
|
+
return { lastResident, pool: { ok: false, reason: 'no memory-bearing CPU grant was inherited' } };
|
|
150
|
+
let context;
|
|
151
|
+
try {
|
|
152
|
+
context = parseContext(contextText);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
lastResident,
|
|
157
|
+
pool: {
|
|
158
|
+
ok: false,
|
|
159
|
+
reason: `invalid inherited memory diagnostic: ${error instanceof Error ? error.message : String(error)}`,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const live = context.bound.ok
|
|
164
|
+
? readLive(context.bound.memory.source)
|
|
165
|
+
: { ok: false, reason: `${context.bound.error.subject}: ${context.bound.error.cause}` };
|
|
166
|
+
return { lastResident, pool: { ok: true, ...context, live } };
|
|
167
|
+
}
|
|
168
|
+
/** Retains the last readable sample through PID exit; stop is called by the child's exit event. */
|
|
169
|
+
export function observeChildMemory(pid, contextText) {
|
|
170
|
+
const sample = () => ({
|
|
171
|
+
sampledAtMs: Date.now(),
|
|
172
|
+
reading: HOST_MEMORY?.residentUsage(pid) ?? {
|
|
173
|
+
ok: false,
|
|
174
|
+
reason: `${process.platform} has no per-process RSS reader`,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
let lastResident = sample();
|
|
178
|
+
const timer = setInterval(() => {
|
|
179
|
+
const next = sample();
|
|
180
|
+
if (next.reading.ok || !lastResident.reading.ok)
|
|
181
|
+
lastResident = next;
|
|
182
|
+
}, 250);
|
|
183
|
+
timer.unref();
|
|
184
|
+
return () => {
|
|
185
|
+
clearInterval(timer);
|
|
186
|
+
return childExitMemory(contextText, lastResident);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/executor.ts"],"names":[],"mappings":"AAeA,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"executor.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BAAkB,GAAE,OAAO,sBAA+C,EAC1E,KAAK,GAAE,YAAY,GAAG,IAAW,EACjC,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAe5B;AA0lCD,wBAAgB,uBAAuB,IAAI,iBAAiB,CAM3D"}
|
|
@@ -9,6 +9,7 @@ import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory
|
|
|
9
9
|
import { DEADLINE_PATIENCE, describeMembersLeft, killProcessGroup, processGroupHasMembers, signalProcessGroup, } from '../../process-group.js';
|
|
10
10
|
import { AdmissionObservation } from './admission-queue.js';
|
|
11
11
|
import { earliestBound, stepBounds, UNARMED } from './bounds.js';
|
|
12
|
+
import { DIAGNOSTIC_CONTEXT_ENV, DIAGNOSTIC_MODULE_ENV, grantMemoryEnvironment } from './child-exit-diagnostics.js';
|
|
12
13
|
import { createCpuPool } from './cpu-pool.js';
|
|
13
14
|
import { GATEWAY_SOCKET } from './gateway-lease.js';
|
|
14
15
|
import { captureHangDiagnostics, HANG_CAPTURE_MS } from './hang-diagnostics.js';
|
|
@@ -37,7 +38,14 @@ const POOL_ENV = [CPU_TOKENS_ENV, CPU_POOL_ENV];
|
|
|
37
38
|
* itself inherits, a parent make's or its cowshed job's, still reaches an ungranted command by Cargo's own rule; a
|
|
38
39
|
* granted one's sub-pool names its own fifo over it.
|
|
39
40
|
*/
|
|
40
|
-
const BUDGET_ENV = [
|
|
41
|
+
const BUDGET_ENV = [
|
|
42
|
+
...POOL_ENV,
|
|
43
|
+
'CARGO_MAKEFLAGS',
|
|
44
|
+
'MAKEFLAGS',
|
|
45
|
+
'MFLAGS',
|
|
46
|
+
DIAGNOSTIC_CONTEXT_ENV,
|
|
47
|
+
DIAGNOSTIC_MODULE_ENV,
|
|
48
|
+
];
|
|
41
49
|
/** Workspace-provided cowshed launchers, in the order a workspace that provides one names them. */
|
|
42
50
|
const WORKSPACE_COWSHED_LAUNCHERS = [
|
|
43
51
|
'packages/cowshed/bin/cowshed',
|
|
@@ -535,6 +543,7 @@ async function runCommand(options, context, killer, tempVolume, inherited, captu
|
|
|
535
543
|
...sized.env,
|
|
536
544
|
...native.env,
|
|
537
545
|
...(pool?.environment ?? {}),
|
|
546
|
+
...(await grantMemoryEnvironment(grant?.charged ?? null, process.env)),
|
|
538
547
|
...(leaf?.kind === 'cargo' ? { MBX_GRANT_FD: String(MBX_GRANT_FD) } : {}),
|
|
539
548
|
};
|
|
540
549
|
// A fixture rides as segment 0 of the lifecycle. Without the channel (Windows) it is plain shell text ahead
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
export interface HostMemory {
|
|
7
7
|
/** The memory the run's pool charges its leaves' peaks against. */
|
|
8
8
|
readRunMemory(): Promise<RunMemoryReading>;
|
|
9
|
+
/** One process's resident set for an exit diagnostic; unavailable is never a zero RSS sample. */
|
|
10
|
+
residentUsage(pid: number): ResidentUsageReading;
|
|
9
11
|
/**
|
|
10
12
|
* A leaf's peak in bytes, from the `maxRSS` that Bun's `Subprocess.resourceUsage()` on `bunVersion` reports for
|
|
11
13
|
* it: the exited leaf's `ru_maxrss`.
|
|
@@ -39,6 +41,15 @@ export type LiveUsageReading = {
|
|
|
39
41
|
readonly ok: false;
|
|
40
42
|
readonly reason: string;
|
|
41
43
|
};
|
|
44
|
+
/** A process's resident bytes and source, or why no sample could be read. */
|
|
45
|
+
export type ResidentUsageReading = {
|
|
46
|
+
readonly ok: true;
|
|
47
|
+
readonly bytes: number;
|
|
48
|
+
readonly source: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly ok: false;
|
|
51
|
+
readonly reason: string;
|
|
52
|
+
};
|
|
42
53
|
/** The run's memory in bytes, and where it was read: the file or sysctl that holds it. */
|
|
43
54
|
export interface RunMemory {
|
|
44
55
|
readonly bytes: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-memory.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/host-memory.ts"],"names":[],"mappings":"AAGA;;;;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;IAA1C,YAAqB,KAAK,EAAE,cAAc,EAKzC;CACF;AAID,kGAAkG;AAClG,eAAO,MAAM,WAAW,EAAE,UAAU,GAAG,IAA0C,CAAC;AAElF,mEAAmE;AACnE,wBAAgB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAazD;AAED,4GAA4G;AAC5G,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAI7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-memory.darwin.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/host-memory.darwin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAqIrE,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"host-memory.darwin.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/host-memory.darwin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAqIrE,eAAO,MAAM,YAAY,EAAE,UAO1B,CAAC"}
|
|
@@ -103,6 +103,7 @@ export const darwinMemory = {
|
|
|
103
103
|
readRunMemory,
|
|
104
104
|
peakBytes: (maxRss) => maxRss,
|
|
105
105
|
treeResidentBytes,
|
|
106
|
+
residentUsage: () => ({ ok: false, reason: 'Node has no macOS per-process RSS reader' }),
|
|
106
107
|
// macOS has no cgroup, and its anonymous and shared pages are not read from a file the pool may open.
|
|
107
108
|
liveUsage: () => ({ ok: false, reason: 'macOS keeps no anonymous and shared memory of a run to read' }),
|
|
108
109
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HostMemory, LiveUsageReading, RunMemoryReading } from './host-memory.js';
|
|
1
|
+
import type { HostMemory, LiveUsageReading, ResidentUsageReading, RunMemoryReading } from './host-memory.js';
|
|
2
2
|
/** A file's text, or the errno code and message its read failed with. */
|
|
3
3
|
export type FileRead = {
|
|
4
4
|
readonly ok: true;
|
|
@@ -12,5 +12,7 @@ export type FileRead = {
|
|
|
12
12
|
export declare function linuxRunMemory(read: (path: string) => Promise<FileRead>): Promise<RunMemoryReading>;
|
|
13
13
|
/** The memory a bound holds live: `memory.stat`'s `anon` and `shmem` beside a cgroup's `memory.max`, meminfo's `AnonPages` and `Shmem` for the host's. */
|
|
14
14
|
export declare function linuxLiveUsage(read: (path: string) => FileRead, bound: string): LiveUsageReading;
|
|
15
|
+
/** The same VmRSS field the peak waiter reads, without turning an unreadable or exited PID into zero. */
|
|
16
|
+
export declare function linuxResidentUsage(read: (path: string) => FileRead, pid: number): ResidentUsageReading;
|
|
15
17
|
export declare const linuxMemory: HostMemory;
|
|
16
18
|
//# sourceMappingURL=host-memory.linux.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-memory.linux.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/host-memory.linux.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"host-memory.linux.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/host-memory.linux.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EAGpB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAc1B,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AA2B5E,2DAA2D;AAC3D,wBAAsB,cAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA8CzG;AAWD,0JAA0J;AAC1J,wBAAgB,cAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAuBhG;AAuDD,yGAAyG;AACzG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAQtG;AAED,eAAO,MAAM,WAAW,EAAE,UAMzB,CAAC"}
|
|
@@ -168,12 +168,27 @@ async function residentBytes(pid) {
|
|
|
168
168
|
return 0;
|
|
169
169
|
throw error;
|
|
170
170
|
}
|
|
171
|
-
const kib =
|
|
171
|
+
const kib = residentKib(status);
|
|
172
172
|
return kib === undefined ? 0 : Number(kib) * 1024;
|
|
173
173
|
}
|
|
174
|
+
function residentKib(status) {
|
|
175
|
+
return /^VmRSS:\s+(\d+) kB$/m.exec(status)?.[1];
|
|
176
|
+
}
|
|
177
|
+
/** The same VmRSS field the peak waiter reads, without turning an unreadable or exited PID into zero. */
|
|
178
|
+
export function linuxResidentUsage(read, pid) {
|
|
179
|
+
const source = `/proc/${pid}/status`;
|
|
180
|
+
const status = read(source);
|
|
181
|
+
if (!status.ok)
|
|
182
|
+
return { ok: false, reason: `${source}: ${status.code}: ${status.message}` };
|
|
183
|
+
const kib = residentKib(status.text);
|
|
184
|
+
return kib === undefined
|
|
185
|
+
? { ok: false, reason: `${source} names no VmRSS in kB` }
|
|
186
|
+
: { ok: true, bytes: Number(kib) * 1024, source };
|
|
187
|
+
}
|
|
174
188
|
export const linuxMemory = {
|
|
175
189
|
readRunMemory: () => linuxRunMemory(readText),
|
|
176
190
|
peakBytes,
|
|
177
191
|
treeResidentBytes,
|
|
192
|
+
residentUsage: (pid) => linuxResidentUsage(readTextSync, pid),
|
|
178
193
|
liveUsage: (bound) => linuxLiveUsage(readTextSync, bound),
|
|
179
194
|
};
|
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
|
+
{"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;AAuElC,OAAO,EACL,KAAK,uBAAuB,EAG7B,MAAM,wBAAwB,CAAC;AAqBhC,gEAAgE;AAChE,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAuelD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAMtE;AA4aD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,qBAAqB,UAAkC,GACtD,OAAO,CAoBT;AACD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,OAAO,GACjB,MAAM,EAAE,CAKV;AA6JD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC;AAeF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAAE,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