@smoothbricks/nx-plugin 0.7.17 → 0.7.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -114
- package/dist/.build-inputs.json +47 -38
- package/dist/built-output-packages.js +1 -1
- package/dist/bun-lock-scope.d.ts +128 -20
- package/dist/bun-lock-scope.d.ts.map +1 -1
- package/dist/bun-lock-scope.js +267 -44
- package/dist/cargo-closure-input.d.ts +8 -6
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +15 -12
- package/dist/cargo-source-hash.d.ts +26 -25
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +84 -105
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts +20 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +43 -22
- package/dist/ensure-built-receipt.d.ts +3 -2
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +3 -2
- package/dist/eslint-config-closure.d.ts +8 -3
- package/dist/eslint-config-closure.d.ts.map +1 -1
- package/dist/eslint-config-closure.js +24 -5
- package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
- package/dist/executors/bounded-exec/admission-queue.js +9 -10
- package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
- package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
- package/dist/executors/bounded-exec/awake-clock.js +22 -0
- package/dist/executors/bounded-exec/bounds.d.ts +19 -6
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +22 -15
- package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
- package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
- package/dist/executors/bounded-exec/case-gate.js +342 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
- package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +102 -16
- package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
- package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-rise.js +111 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
- package/dist/executors/bounded-exec/endpoint-life.js +228 -0
- package/dist/executors/bounded-exec/executor.d.ts +1 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +256 -86
- package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +8 -1
- package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
- package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
- package/dist/executors/bounded-exec/go-run-summary.js +98 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
- package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
- package/dist/executors/bounded-exec/lease-wait.js +1 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +45 -8
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
- package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
- package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
- package/dist/executors/bounded-exec/parent-grant.js +1 -0
- package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
- package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
- package/dist/executors/bounded-exec/pool-admission.js +47 -1
- package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
- package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress-channel.js +113 -0
- package/dist/executors/bounded-exec/progress.d.ts +5 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +31 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +123 -16
- package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
- package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
- package/dist/executors/bounded-exec/reservation-connection.js +248 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +13 -9
- package/dist/executors/bounded-exec/schema.d.ts +7 -2
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/schema.js +17 -1
- package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
- package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
- package/dist/executors/bounded-exec/suite-minimum.js +85 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-result-writer.js +1 -0
- package/dist/executors/bounded-exec/test-results.d.ts +5 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-results.js +2 -2
- package/dist/executors/bounded-exec/verdict.d.ts +39 -10
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +60 -14
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +32 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +294 -152
- package/dist/managed-files/ci-workflow.d.ts +4 -1
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +9 -14
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/managed-files/generator.d.ts +5 -1
- package/dist/managed-files/generator.d.ts.map +1 -1
- package/dist/managed-files/generator.js +22 -7
- package/dist/managed-files/render-memo.d.ts +13 -0
- package/dist/managed-files/render-memo.d.ts.map +1 -0
- package/dist/managed-files/render-memo.js +94 -0
- package/dist/task-results.js +2 -1
- package/dist/test-program.d.ts +11 -6
- package/dist/test-program.d.ts.map +1 -1
- package/dist/test-program.js +39 -35
- package/dist/tool-bins.d.ts +12 -0
- package/dist/tool-bins.d.ts.map +1 -1
- package/dist/tool-bins.js +31 -6
- package/dist/typecheck-test-policy.d.ts +10 -1
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +40 -24
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/dist/workspace-index.d.ts +14 -1
- package/dist/workspace-index.d.ts.map +1 -1
- package/dist/workspace-index.js +36 -4
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1851 -221
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +122 -14
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +68 -11
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +293 -3
- package/runtime/nx-publish/nx_publish.js +36 -14
- package/src/built-output-packages.ts +1 -1
- package/src/bun-lock-scope.ts +293 -40
- package/src/cargo-closure-input.ts +20 -12
- package/src/cargo-source-hash.ts +119 -145
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +59 -21
- package/src/ensure-built-receipt.ts +3 -2
- package/src/eslint-config-closure.ts +27 -6
- package/src/executors/bounded-exec/admission-queue.ts +11 -10
- package/src/executors/bounded-exec/awake-clock.ts +20 -0
- package/src/executors/bounded-exec/bounds.ts +41 -19
- package/src/executors/bounded-exec/case-gate.ts +365 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
- package/src/executors/bounded-exec/cpu-pool.ts +139 -12
- package/src/executors/bounded-exec/cpu-rise.ts +156 -0
- package/src/executors/bounded-exec/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +341 -123
- package/src/executors/bounded-exec/gateway-lease.ts +6 -0
- package/src/executors/bounded-exec/go-run-summary.ts +137 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +57 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
- package/src/executors/bounded-exec/parent-grant.ts +3 -0
- package/src/executors/bounded-exec/pool-admission.ts +59 -2
- package/src/executors/bounded-exec/progress-channel.ts +129 -0
- package/src/executors/bounded-exec/progress.ts +39 -3
- package/src/executors/bounded-exec/ram-temp.ts +137 -17
- package/src/executors/bounded-exec/reservation-connection.ts +221 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
- package/src/executors/bounded-exec/runner-sizing.ts +13 -8
- package/src/executors/bounded-exec/schema.json +1 -1
- package/src/executors/bounded-exec/schema.ts +21 -2
- package/src/executors/bounded-exec/suite-minimum.ts +81 -0
- package/src/executors/bounded-exec/test-result-writer.ts +3 -0
- package/src/executors/bounded-exec/test-results.ts +5 -0
- package/src/executors/bounded-exec/verdict.ts +83 -22
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +357 -166
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/managed-files/generator.ts +21 -6
- package/src/managed-files/render-memo.ts +135 -0
- package/src/test-program.ts +36 -41
- package/src/tool-bins.ts +35 -6
- package/src/typecheck-test-policy.ts +49 -24
- package/src/workspace-config-policy.ts +161 -43
- package/src/workspace-index.ts +40 -5
- package/test-timings.json +157 -141
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
|
@@ -52,5 +52,5 @@ export type HeldLease = {
|
|
|
52
52
|
* refusal. CPU admission instead uses its own control/silence policy: no compatibility half-close,
|
|
53
53
|
* and no total queue bound (specs/cowshed/05_gateway.md, "Deadlines").
|
|
54
54
|
*/
|
|
55
|
-
export declare function holdLease(socket: string, request: Readonly<Record<string, unknown>>, what: string, bounds: LeaseBounds | CpuLeaseWait, onQueued?: () => void): Promise<HeldLease>;
|
|
55
|
+
export declare function holdLease(socket: string, request: Readonly<Record<string, unknown>>, what: string, bounds: LeaseBounds | CpuLeaseWait, onQueued?: () => void, withdrawn?: AbortSignal): Promise<HeldLease>;
|
|
56
56
|
//# sourceMappingURL=gateway-lease.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-lease.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/gateway-lease.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8C,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,iB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|
* refusal. CPU admission instead uses its own control/silence policy: no compatibility half-close,
|
|
45
45
|
* and no total queue bound (specs/cowshed/05_gateway.md, "Deadlines").
|
|
46
46
|
*/
|
|
47
|
-
export function holdLease(socket, request, what, bounds, onQueued) {
|
|
47
|
+
export function holdLease(socket, request, what, bounds, onQueued, withdrawn) {
|
|
48
48
|
// `Promise.withResolvers` would read better but needs lib es2024; this package inherits lib
|
|
49
49
|
// es2022 from tsconfig.base.json.
|
|
50
50
|
let resolve;
|
|
@@ -212,5 +212,12 @@ export function holdLease(socket, request, what, bounds, onQueued) {
|
|
|
212
212
|
socketClosed = true;
|
|
213
213
|
unleased(`the lease connection for ${what} at ${socket} closed`);
|
|
214
214
|
});
|
|
215
|
+
if (withdrawn !== undefined) {
|
|
216
|
+
const withdraw = () => unleased(`the request for ${what} at ${socket} was withdrawn`);
|
|
217
|
+
if (withdrawn.aborted)
|
|
218
|
+
withdraw();
|
|
219
|
+
else
|
|
220
|
+
withdrawn.addEventListener('abort', withdraw, { once: true });
|
|
221
|
+
}
|
|
215
222
|
return promise;
|
|
216
223
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Go run by its top-level tests. `go test -json` reports every event and sums none, and a consumer that keeps only
|
|
3
|
+
* part of a long output cannot count it, so the run that read every event states the sum where its output ends.
|
|
4
|
+
*/
|
|
5
|
+
export interface GoRunSummary {
|
|
6
|
+
readonly passed: number;
|
|
7
|
+
readonly failed: number;
|
|
8
|
+
readonly skipped: number;
|
|
9
|
+
readonly packages: number;
|
|
10
|
+
readonly failedTests: readonly GoFailedTest[];
|
|
11
|
+
/** Packages that failed with no failed test of their own: a build that did not compile, a `TestMain` that exited. */
|
|
12
|
+
readonly failedPackages: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
export interface GoFailedTest {
|
|
15
|
+
readonly package: string;
|
|
16
|
+
readonly test: string;
|
|
17
|
+
}
|
|
18
|
+
/** One package as `go list -f GO_LIST_FORMAT` prints it: its directory and its in-package and external test files. */
|
|
19
|
+
export interface GoPackageFiles {
|
|
20
|
+
readonly package: string;
|
|
21
|
+
readonly directory: string;
|
|
22
|
+
readonly files: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
export declare const GO_LIST_FORMAT = "{{.ImportPath}}\t{{.Dir}}\t{{join .TestGoFiles \",\"}}\t{{join .XTestGoFiles \",\"}}";
|
|
25
|
+
export declare function parseGoList(stdout: string): GoPackageFiles[];
|
|
26
|
+
/**
|
|
27
|
+
* The file of a package that declares the top-level function `test`, and its line. Go admits one such function per
|
|
28
|
+
* test package, and a directory holds two test packages (in-package and external): a name both declare has no one
|
|
29
|
+
* file, and neither does a name none declares.
|
|
30
|
+
*/
|
|
31
|
+
export declare function declarationOf(test: string, files: readonly {
|
|
32
|
+
readonly path: string;
|
|
33
|
+
readonly text: string;
|
|
34
|
+
}[]): {
|
|
35
|
+
path: string;
|
|
36
|
+
line: number;
|
|
37
|
+
} | null;
|
|
38
|
+
/** Each failed test whose declaration is found, as `<workspace path>:<line>`, keyed `<package>::<test>`. */
|
|
39
|
+
export declare function goDeclarations(failed: readonly GoFailedTest[], root: string, listed: readonly GoPackageFiles[], read: (path: string) => string | null): Map<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* The lines a Go run's output ends with. A failed test is named at its declaration, the identity a reader matches a
|
|
42
|
+
* source file by; one whose declaration was not found keeps its package, which no reader takes for a file.
|
|
43
|
+
*/
|
|
44
|
+
export declare function goRunSummaryText(summary: GoRunSummary, declared: ReadonlyMap<string, string>): string;
|
|
45
|
+
/**
|
|
46
|
+
* The declarations of a run's failed tests, asked of the toolchain that ran them: `go list` names each failed package's
|
|
47
|
+
* directory and test files, and the file that declares the test is found among them. A list that does not answer
|
|
48
|
+
* leaves every test at its package, which the summary then prints.
|
|
49
|
+
*/
|
|
50
|
+
export declare function declaredGoTests(failed: readonly GoFailedTest[], cwd: string, root: string, env: NodeJS.ProcessEnv): Map<string, string>;
|
|
51
|
+
//# sourceMappingURL=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,YAAY,EAAE,EAC/B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,cAAc,EAAE,EACjC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GACpC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAerB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CASrG;AAKD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBrB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { join, relative, sep } from 'node:path';
|
|
4
|
+
export const GO_LIST_FORMAT = '{{.ImportPath}}\t{{.Dir}}\t{{join .TestGoFiles ","}}\t{{join .XTestGoFiles ","}}';
|
|
5
|
+
export function parseGoList(stdout) {
|
|
6
|
+
const packages = [];
|
|
7
|
+
for (const line of stdout.split('\n')) {
|
|
8
|
+
const [name, directory, own, external] = line.split('\t');
|
|
9
|
+
if (name === undefined || name === '' || directory === undefined || directory === '')
|
|
10
|
+
continue;
|
|
11
|
+
packages.push({
|
|
12
|
+
package: name,
|
|
13
|
+
directory,
|
|
14
|
+
files: [own ?? '', external ?? ''].flatMap((list) => (list === '' ? [] : list.split(','))),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return packages;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The file of a package that declares the top-level function `test`, and its line. Go admits one such function per
|
|
21
|
+
* test package, and a directory holds two test packages (in-package and external): a name both declare has no one
|
|
22
|
+
* file, and neither does a name none declares.
|
|
23
|
+
*/
|
|
24
|
+
export function declarationOf(test, files) {
|
|
25
|
+
const declares = new RegExp(`^func\\s+${test.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*\\(`);
|
|
26
|
+
let found = null;
|
|
27
|
+
for (const file of files) {
|
|
28
|
+
const line = file.text.split('\n').findIndex((text) => declares.test(text));
|
|
29
|
+
if (line === -1)
|
|
30
|
+
continue;
|
|
31
|
+
if (found !== null)
|
|
32
|
+
return null;
|
|
33
|
+
found = { path: file.path, line: line + 1 };
|
|
34
|
+
}
|
|
35
|
+
return found;
|
|
36
|
+
}
|
|
37
|
+
/** Each failed test whose declaration is found, as `<workspace path>:<line>`, keyed `<package>::<test>`. */
|
|
38
|
+
export function goDeclarations(failed, root, listed, read) {
|
|
39
|
+
const declared = new Map();
|
|
40
|
+
for (const { package: name, test } of failed) {
|
|
41
|
+
const found = listed.find((entry) => entry.package === name);
|
|
42
|
+
if (found === undefined)
|
|
43
|
+
continue;
|
|
44
|
+
const files = found.files.flatMap((file) => {
|
|
45
|
+
const path = join(found.directory, file);
|
|
46
|
+
const text = read(path);
|
|
47
|
+
return text === null ? [] : [{ path, text }];
|
|
48
|
+
});
|
|
49
|
+
const declaration = declarationOf(test, files);
|
|
50
|
+
if (declaration === null)
|
|
51
|
+
continue;
|
|
52
|
+
declared.set(`${name}::${test}`, `${relative(root, declaration.path).split(sep).join('/')}:${declaration.line}`);
|
|
53
|
+
}
|
|
54
|
+
return declared;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The lines a Go run's output ends with. A failed test is named at its declaration, the identity a reader matches a
|
|
58
|
+
* source file by; one whose declaration was not found keeps its package, which no reader takes for a file.
|
|
59
|
+
*/
|
|
60
|
+
export function goRunSummaryText(summary, declared) {
|
|
61
|
+
const lines = [
|
|
62
|
+
`go test summary: ${summary.passed} passed, ${summary.failed} failed, ${summary.skipped} skipped, ${summary.packages} packages`,
|
|
63
|
+
...summary.failedTests.map(({ package: name, test }) => `go test failed: ${declared.get(`${name}::${test}`) ?? name} ${test}`),
|
|
64
|
+
...summary.failedPackages.map((name) => `go test package failed: ${name}`),
|
|
65
|
+
];
|
|
66
|
+
return `${lines.join('\n')}\n`;
|
|
67
|
+
}
|
|
68
|
+
/** How long `go list` may take to name the failed packages' directories and test files. */
|
|
69
|
+
const GO_LIST_MS = 60_000;
|
|
70
|
+
/**
|
|
71
|
+
* The declarations of a run's failed tests, asked of the toolchain that ran them: `go list` names each failed package's
|
|
72
|
+
* directory and test files, and the file that declares the test is found among them. A list that does not answer
|
|
73
|
+
* leaves every test at its package, which the summary then prints.
|
|
74
|
+
*/
|
|
75
|
+
export function declaredGoTests(failed, cwd, root, env) {
|
|
76
|
+
if (failed.length === 0)
|
|
77
|
+
return new Map();
|
|
78
|
+
const packages = [...new Set(failed.map((test) => test.package))];
|
|
79
|
+
const listed = spawnSync('go', ['list', '-f', GO_LIST_FORMAT, ...packages], {
|
|
80
|
+
cwd,
|
|
81
|
+
env,
|
|
82
|
+
encoding: 'utf8',
|
|
83
|
+
timeout: GO_LIST_MS,
|
|
84
|
+
});
|
|
85
|
+
if (listed.status !== 0)
|
|
86
|
+
return new Map();
|
|
87
|
+
return goDeclarations(failed, root, parseGoList(listed.stdout), (path) => {
|
|
88
|
+
try {
|
|
89
|
+
return readFileSync(path, 'utf8');
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
// A listed file that cannot be read declares nothing here; any other failure is a bug to see.
|
|
93
|
+
if (error instanceof Error && 'code' in error)
|
|
94
|
+
return null;
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CpuRise } from './cpu-rise.js';
|
|
1
2
|
import { type LockWait } from './lock-wait.js';
|
|
2
3
|
/**
|
|
3
4
|
* The pre-expiry capture window. Stack samples set it: under load averages of 27-52 on 18 cores one `sudo -n sample`
|
|
@@ -12,13 +13,18 @@ export interface HangDiagnostics {
|
|
|
12
13
|
outcome: 'holders' | 'none' | 'incomplete';
|
|
13
14
|
/** Lock waits the snapshot names: empty unless the capture is complete, and always empty without the open-file census. */
|
|
14
15
|
lockWaits: readonly LockWait[];
|
|
16
|
+
/**
|
|
17
|
+
* The processes of the tree whose CPU time rose between the two censuses, largest gain first: empty when none did, and
|
|
18
|
+
* when the closing census did not complete. A build inside the test, never a restart of the idle bound.
|
|
19
|
+
*/
|
|
20
|
+
cpuRising: readonly CpuRise[];
|
|
15
21
|
text: string;
|
|
16
22
|
}
|
|
17
23
|
export interface HangCaptureRequest {
|
|
18
24
|
pid: number;
|
|
19
25
|
pgid: number | null;
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
awakeExpiresAtMs: number;
|
|
27
|
+
awakeNow(): number;
|
|
22
28
|
signal?: AbortSignal;
|
|
23
29
|
}
|
|
24
30
|
export type HangProbeResult = {
|
|
@@ -36,6 +42,8 @@ export type HangProbeResult = {
|
|
|
36
42
|
export interface HangDiagnosticHost {
|
|
37
43
|
platform: NodeJS.Platform;
|
|
38
44
|
probe(file: string, args: readonly string[], timeoutMs: number, signal: AbortSignal): Promise<HangProbeResult>;
|
|
45
|
+
/** Waits `ms`, or until `signal` aborts: the capture's end ends its own CPU interval. */
|
|
46
|
+
sleep(ms: number, signal: AbortSignal): Promise<void>;
|
|
39
47
|
}
|
|
40
48
|
/** A pre-expiry observation, never an assertion that an open file is a contested lock. */
|
|
41
49
|
export declare function captureHangDiagnostics(request: HangCaptureRequest, source?: HangDiagnosticHost): Promise<HangDiagnostics>;
|
|
@@ -50,5 +58,5 @@ export declare function captureHangDiagnostics(request: HangCaptureRequest, sour
|
|
|
50
58
|
*/
|
|
51
59
|
export declare function stopProbe(file: string, pid: number): boolean;
|
|
52
60
|
/** A probe owns its group and output pipes; its deadline never waits for an unresponsive child to reap. */
|
|
53
|
-
export declare function runProbe(file: string, args: readonly string[], timeoutMs: number, signal: AbortSignal, environment?: NodeJS.ProcessEnv): Promise<HangProbeResult>;
|
|
61
|
+
export declare function runProbe(file: string, args: readonly string[], timeoutMs: number, signal: AbortSignal, environment?: NodeJS.ProcessEnv, now?: () => number): Promise<HangProbeResult>;
|
|
54
62
|
//# sourceMappingURL=hang-diagnostics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hang-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/hang-diagnostics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hang-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/hang-diagnostics.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,OAAO,EAOb,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,QAAQ,EAKd,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AA4CtC,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;IAC3C,0HAA0H;IAC1H,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC/B;;;OAGG;IACH,SAAS,EAAE,SAAS,OAAO,EAAE,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,IAAI,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/G,yFAAyF;IACzF,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAsBD,0FAA0F;AAC1F,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,GAAE,kBAIP,GACA,OAAO,CAAC,eAAe,CAAC,CAyU1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED,2GAA2G;AAC3G,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,EACnB,WAAW,CAAC,EAAE,MAAM,CAAC,UAAU,EAC/B,GAAG,GAAE,MAAM,MAAgC,GAC1C,OAAO,CAAC,eAAe,CAAC,CA6D1B"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { describeTeardown, killProcessGroupNow, TEARDOWN_PATIENCE } from '../../process-group.js';
|
|
3
3
|
import { withDescendants } from '../../testing.js';
|
|
4
|
+
import { atClockDeadline } from './awake-clock.js';
|
|
5
|
+
import { CPU_RISING_CLASS, cpuChange, cpuRiseThresholdsMs, describeCpuRise, describeCpuThresholds, parseCpuTime, } from './cpu-rise.js';
|
|
4
6
|
import { describeHolders, lockCandidates, lockWaits, parseLsofFields, parseLsofTable, } from './lock-wait.js';
|
|
5
7
|
/**
|
|
6
8
|
* The pre-expiry capture window. Stack samples set it: under load averages of 27-52 on 18 cores one `sudo -n sample`
|
|
@@ -8,12 +10,20 @@ import { describeHolders, lockCandidates, lockWaits, parseLsofFields, parseLsofT
|
|
|
8
10
|
*/
|
|
9
11
|
export const HANG_CAPTURE_MS = 10_000;
|
|
10
12
|
const MAX_PROBE_BYTES = 4 * 1024 * 1024;
|
|
11
|
-
const PS_FIELDS = 'pid=,ppid=,pgid=,stat=,%cpu=,etime=,lstart=,command=';
|
|
13
|
+
const PS_FIELDS = 'pid=,ppid=,pgid=,stat=,%cpu=,etime=,cputime=,lstart=,command=';
|
|
14
|
+
/**
|
|
15
|
+
* The least time between the two process censuses, which are the snapshot's two CPU samples. A process is named
|
|
16
|
+
* after gaining 2 s where ps counts whole seconds and 0.5 s where it counts centiseconds (cpuRiseThresholdMs), so five
|
|
17
|
+
* seconds show a process at 40% or at 10% of a core. On Darwin the stack samples have usually spent most of it;
|
|
18
|
+
* elsewhere, or when sudo refuses them, the snapshot pauses, inside its window and early enough that the closing
|
|
19
|
+
* census keeps its own limit.
|
|
20
|
+
*/
|
|
21
|
+
const CPU_INTERVAL_MS = 5_000;
|
|
12
22
|
/**
|
|
13
23
|
* Stack samples: `sample` suspends a process every millisecond for one second and reports its threads' call graph. The
|
|
14
|
-
* runner and at most this many leaf processes are sampled, all at once
|
|
15
|
-
*
|
|
16
|
-
* capture all the same.
|
|
24
|
+
* runner and at most this many leaf processes are sampled, all at once, and then at most this many named lock waiters
|
|
25
|
+
* those left out. `-mayDie` is not passed: it reads symbols before sampling and measured about a second slower under
|
|
26
|
+
* load, and a process that exits mid-sample is a raced capture all the same.
|
|
17
27
|
*/
|
|
18
28
|
const MAX_SAMPLED_LEAVES = 4;
|
|
19
29
|
const SAMPLE_SECONDS = 1;
|
|
@@ -38,12 +48,30 @@ function callGraph(report) {
|
|
|
38
48
|
const end = report.indexOf('\nBinary Images:');
|
|
39
49
|
return (end === -1 ? report : report.slice(0, end)).trim();
|
|
40
50
|
}
|
|
41
|
-
|
|
51
|
+
function sleepUnlessAborted(ms, signal, now) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
const done = () => {
|
|
54
|
+
cancelTimer();
|
|
55
|
+
signal.removeEventListener('abort', done);
|
|
56
|
+
resolve();
|
|
57
|
+
};
|
|
58
|
+
const cancelTimer = atClockDeadline(now() + ms, now, done);
|
|
59
|
+
signal.addEventListener('abort', done, { once: true });
|
|
60
|
+
if (signal.aborted)
|
|
61
|
+
done();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
42
64
|
/** A pre-expiry observation, never an assertion that an open file is a contested lock. */
|
|
43
|
-
export function captureHangDiagnostics(request, source =
|
|
65
|
+
export function captureHangDiagnostics(request, source = {
|
|
66
|
+
platform: process.platform,
|
|
67
|
+
probe: (file, args, timeoutMs, signal) => runProbe(file, args, timeoutMs, signal, undefined, request.awakeNow),
|
|
68
|
+
sleep: (ms, signal) => sleepUnlessAborted(ms, signal, request.awakeNow),
|
|
69
|
+
}) {
|
|
44
70
|
const startedAtMs = Date.now();
|
|
45
|
-
const
|
|
46
|
-
const
|
|
71
|
+
const { awakeNow, awakeExpiresAtMs } = request;
|
|
72
|
+
const startedAwake = awakeNow();
|
|
73
|
+
const endsAtMs = Math.min(startedAwake + HANG_CAPTURE_MS, awakeExpiresAtMs);
|
|
74
|
+
const budgetMs = Math.max(0, Math.min(HANG_CAPTURE_MS, awakeExpiresAtMs - startedAwake));
|
|
47
75
|
const controller = new AbortController();
|
|
48
76
|
const lines = [
|
|
49
77
|
`Hang snapshot: pid=${request.pid} pgid=${request.pgid ?? 'unknown'} startedAtMs=${startedAtMs}`,
|
|
@@ -53,30 +81,32 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
53
81
|
const during = () => (active.size === 0 ? 'process census' : [...active].join(', '));
|
|
54
82
|
let finished = false;
|
|
55
83
|
let waits = [];
|
|
84
|
+
let rising = [];
|
|
56
85
|
// This package targets lib es2022, which does not declare Promise.withResolvers.
|
|
57
86
|
return new Promise((resolve) => {
|
|
58
87
|
const finish = (outcome) => {
|
|
59
88
|
if (finished)
|
|
60
89
|
return;
|
|
61
90
|
finished = true;
|
|
62
|
-
|
|
91
|
+
cancelTimer();
|
|
63
92
|
request.signal?.removeEventListener('abort', cancelled);
|
|
64
93
|
controller.abort();
|
|
65
94
|
const capturedAtMs = Date.now();
|
|
66
|
-
const offsetFromExpiryMs =
|
|
95
|
+
const offsetFromExpiryMs = awakeExpiresAtMs - awakeNow();
|
|
67
96
|
resolve({
|
|
68
97
|
startedAtMs,
|
|
69
98
|
capturedAtMs,
|
|
70
99
|
offsetFromExpiryMs,
|
|
71
100
|
outcome,
|
|
72
101
|
lockWaits: outcome === 'incomplete' ? [] : waits,
|
|
102
|
+
cpuRising: rising,
|
|
73
103
|
text: `${lines.join('\n')}\nHang snapshot outcome=${outcome} capturedAtMs=${capturedAtMs} offsetFromExpiryMs=${offsetFromExpiryMs}\n`,
|
|
74
104
|
});
|
|
75
105
|
};
|
|
76
|
-
const
|
|
77
|
-
lines.push(`Capture incomplete: ${budgetMs}ms deadline reached during ${during()}; no empty-holder conclusion.`);
|
|
106
|
+
const cancelTimer = atClockDeadline(endsAtMs, awakeNow, () => {
|
|
107
|
+
lines.push(`Capture incomplete: ${Math.ceil(budgetMs)}ms deadline reached during ${during()}; no empty-holder conclusion.`);
|
|
78
108
|
finish('incomplete');
|
|
79
|
-
}
|
|
109
|
+
});
|
|
80
110
|
const cancelled = () => {
|
|
81
111
|
if (finished)
|
|
82
112
|
return;
|
|
@@ -96,7 +126,7 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
96
126
|
const probe = async (name, file, args, limitMs) => {
|
|
97
127
|
active.add(name);
|
|
98
128
|
lines.push(`${name}: ${file} ${args.join(' ')}`);
|
|
99
|
-
const result = await source.probe(file, args, Math.max(0, Math.min(limitMs, endsAtMs -
|
|
129
|
+
const result = await source.probe(file, args, Math.max(0, Math.min(limitMs, endsAtMs - awakeNow())), controller.signal);
|
|
100
130
|
active.delete(name);
|
|
101
131
|
if (!finished) {
|
|
102
132
|
lines.push(`${name}: ${result.status}${result.status === 'exited' ? ` code=${result.code}` : ` ${result.detail}`}`);
|
|
@@ -116,27 +146,37 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
116
146
|
}
|
|
117
147
|
const parsed = [];
|
|
118
148
|
for (const row of result.stdout.split('\n').filter((line) => line.trim() !== '')) {
|
|
119
|
-
const match = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+\s+\S+\s+\d+\s+\d\d:\d\d:\d\d\s+\d{4})\s+(.*)$/.exec(row);
|
|
149
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+\s+\S+\s+\d+\s+\d\d:\d\d:\d\d\s+\d{4})\s+(.*)$/.exec(row);
|
|
120
150
|
if (match === null) {
|
|
121
151
|
lines.push(`${name}: could not decode ps row: ${row}`);
|
|
122
152
|
return null;
|
|
123
153
|
}
|
|
124
|
-
const [, pid, ppid, pgid, stat, , , started, command] = match;
|
|
154
|
+
const [, pid, ppid, pgid, stat, , , cputime, started, command] = match;
|
|
125
155
|
if (pid === undefined ||
|
|
126
156
|
ppid === undefined ||
|
|
127
157
|
pgid === undefined ||
|
|
128
158
|
stat === undefined ||
|
|
159
|
+
cputime === undefined ||
|
|
129
160
|
started === undefined ||
|
|
130
161
|
command === undefined) {
|
|
131
162
|
lines.push(`${name}: incomplete ps row: ${row}`);
|
|
132
163
|
return null;
|
|
133
164
|
}
|
|
134
|
-
parsed.push({
|
|
165
|
+
parsed.push({
|
|
166
|
+
pid: Number(pid),
|
|
167
|
+
ppid: Number(ppid),
|
|
168
|
+
pgid: Number(pgid),
|
|
169
|
+
stat,
|
|
170
|
+
cpu: parseCpuTime(cputime),
|
|
171
|
+
started,
|
|
172
|
+
command,
|
|
173
|
+
raw: row,
|
|
174
|
+
});
|
|
135
175
|
}
|
|
136
176
|
const roots = [request.pid, ...parsed.filter((entry) => entry.pgid === request.pgid).map((entry) => entry.pid)];
|
|
137
177
|
const selected = new Set(withDescendants(parsed, roots).map((entry) => entry.pid));
|
|
138
178
|
const tree = parsed.filter((entry) => selected.has(entry.pid));
|
|
139
|
-
lines.push(`${name}: PID PPID PGID STAT %CPU ELAPSED STARTED COMMAND`);
|
|
179
|
+
lines.push(`${name}: PID PPID PGID STAT %CPU ELAPSED CPUTIME STARTED COMMAND`);
|
|
140
180
|
lines.push(...tree.map((entry) => entry.raw));
|
|
141
181
|
if (!tree.some((entry) => entry.pid === request.pid)) {
|
|
142
182
|
lines.push(`${name}: root pid ${request.pid} exited or is not visible; capture raced or is incomplete.`);
|
|
@@ -144,36 +184,43 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
144
184
|
}
|
|
145
185
|
return tree;
|
|
146
186
|
};
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
* process waits in, which the open-file census cannot. A sample sudo refuses, or one that does not answer, is named
|
|
150
|
-
* as no stack for that process; stacks never change the holder outcome.
|
|
151
|
-
*/
|
|
152
|
-
const stackSamples = async (tree) => {
|
|
187
|
+
/** The runner and up to MAX_SAMPLED_LEAVES leaf processes of `tree` (members with no live child), and the leaves past that bound. */
|
|
188
|
+
const leafSamples = (tree) => {
|
|
153
189
|
const live = tree.filter((entry) => !entry.stat.startsWith('Z'));
|
|
154
190
|
const parents = new Set(live.map((entry) => entry.ppid));
|
|
155
191
|
const leaves = live.filter((entry) => entry.pid !== request.pid && !parents.has(entry.pid));
|
|
156
|
-
|
|
192
|
+
return {
|
|
193
|
+
sampled: [request.pid, ...leaves.slice(0, MAX_SAMPLED_LEAVES).map((entry) => entry.pid)],
|
|
194
|
+
omitted: leaves.slice(MAX_SAMPLED_LEAVES).map((entry) => entry.pid),
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* One one-second call stack of `pid`, until the closing census would have less than its own limit left: a stack
|
|
199
|
+
* names the call a process waits in, which the open-file census cannot. A sample sudo refuses, or one that does
|
|
200
|
+
* not answer, is named as no stack for that process; stacks never change the holder outcome.
|
|
201
|
+
*/
|
|
202
|
+
const sampleStack = async (pid) => {
|
|
203
|
+
const name = `stack sample pid ${pid}`;
|
|
204
|
+
// `-file /dev/stdout` writes the report to the probe's pipe alone, not also to a root-owned file in /tmp.
|
|
205
|
+
const args = ['-n', 'sample', String(pid), String(SAMPLE_SECONDS), '-file', '/dev/stdout'];
|
|
206
|
+
const result = await probe(name, 'sudo', args, endsAtMs - awakeNow() - CENSUS_LIMIT_MS);
|
|
207
|
+
if (finished)
|
|
208
|
+
return;
|
|
209
|
+
const report = callGraph(result.stdout);
|
|
210
|
+
if (result.status === 'exited' && result.code === 0 && report !== '') {
|
|
211
|
+
lines.push(`${name} (${SAMPLE_SECONDS}s; binary image list omitted):\n${report}`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (report !== '')
|
|
215
|
+
lines.push(`Partial ${name} output:\n${report}`);
|
|
216
|
+
lines.push(`${name}: no stack; sudo -n sample did not answer, so the call this process waits in is not observed.`);
|
|
217
|
+
};
|
|
218
|
+
/** The runner's and its tree's leaf processes' stacks, taken at once. */
|
|
219
|
+
const stackSamples = async (tree) => {
|
|
220
|
+
const { sampled, omitted } = leafSamples(tree);
|
|
157
221
|
if (omitted.length > 0)
|
|
158
222
|
lines.push(`Stack samples bounded to the runner and ${MAX_SAMPLED_LEAVES} leaf processes; not sampled: pid ${omitted.join(', ')}`);
|
|
159
|
-
|
|
160
|
-
const sampled = [request.pid, ...leaves.slice(0, MAX_SAMPLED_LEAVES).map((entry) => entry.pid)];
|
|
161
|
-
await Promise.all(sampled.map(async (pid) => {
|
|
162
|
-
const name = `stack sample pid ${pid}`;
|
|
163
|
-
// `-file /dev/stdout` writes the report to the probe's pipe alone, not also to a root-owned file in /tmp.
|
|
164
|
-
const args = ['-n', 'sample', String(pid), String(SAMPLE_SECONDS), '-file', '/dev/stdout'];
|
|
165
|
-
const result = await probe(name, 'sudo', args, limitMs);
|
|
166
|
-
if (finished)
|
|
167
|
-
return;
|
|
168
|
-
const report = callGraph(result.stdout);
|
|
169
|
-
if (result.status === 'exited' && result.code === 0 && report !== '') {
|
|
170
|
-
lines.push(`${name} (${SAMPLE_SECONDS}s; binary image list omitted):\n${report}`);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (report !== '')
|
|
174
|
-
lines.push(`Partial ${name} output:\n${report}`);
|
|
175
|
-
lines.push(`${name}: no stack; sudo -n sample did not answer, so the call this process waits in is not observed.`);
|
|
176
|
-
}));
|
|
223
|
+
await Promise.all(sampled.map(sampleStack));
|
|
177
224
|
};
|
|
178
225
|
/**
|
|
179
226
|
* A process in an uninterruptible kernel wait (state U) is in a file-system or device call no signal ends, and its
|
|
@@ -183,7 +230,7 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
183
230
|
*/
|
|
184
231
|
const kernelWaits = async (tree) => {
|
|
185
232
|
const waiting = tree.filter((entry) => entry.stat.startsWith('U')).slice(0, MAX_SAMPLED_LEAVES);
|
|
186
|
-
const limitMs = endsAtMs -
|
|
233
|
+
const limitMs = endsAtMs - awakeNow() - CENSUS_LIMIT_MS;
|
|
187
234
|
await Promise.all(waiting.map(async ({ pid }) => {
|
|
188
235
|
const name = `fs_usage pid ${pid}`;
|
|
189
236
|
const args = ['-n', 'fs_usage', '-w', '-t', String(FS_USAGE_SECONDS), '-f', 'filesys', String(pid)];
|
|
@@ -203,6 +250,7 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
203
250
|
return;
|
|
204
251
|
if (before === null)
|
|
205
252
|
return finish('incomplete');
|
|
253
|
+
const beforeAtMs = awakeNow();
|
|
206
254
|
let incomplete = false;
|
|
207
255
|
let observed = before.length > 0;
|
|
208
256
|
if (source.platform === 'darwin') {
|
|
@@ -248,6 +296,11 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
248
296
|
}
|
|
249
297
|
else {
|
|
250
298
|
waits = lockWaits(rows, new Set(before.map((entry) => entry.pid)), openers);
|
|
299
|
+
// A lock wait is open-handle evidence: only the waiter's own stack says whether it blocks in the lock
|
|
300
|
+
// call. Each named waiter the leaf samples left out is sampled the same way, inside the same window.
|
|
301
|
+
const stacked = new Set(leafSamples(before).sampled);
|
|
302
|
+
const waiters = [...new Set(waits.flatMap((wait) => wait.waiters))].filter((pid) => !stacked.has(pid));
|
|
303
|
+
await Promise.all(waiters.slice(0, MAX_SAMPLED_LEAVES).map(sampleStack));
|
|
251
304
|
}
|
|
252
305
|
}
|
|
253
306
|
};
|
|
@@ -259,11 +312,20 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
259
312
|
lines.push(`Open-file census not provided on ${source.platform}; observations below name processes only.`);
|
|
260
313
|
lines.push(`Stack samples not provided on ${source.platform}; no blocking call is observed.`);
|
|
261
314
|
}
|
|
315
|
+
const settleMs = Math.min(beforeAtMs + CPU_INTERVAL_MS, endsAtMs - CENSUS_LIMIT_MS) - awakeNow();
|
|
316
|
+
if (settleMs > 0) {
|
|
317
|
+
active.add('CPU interval');
|
|
318
|
+
await source.sleep(settleMs, controller.signal);
|
|
319
|
+
active.delete('CPU interval');
|
|
320
|
+
if (finished)
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
262
323
|
const after = await census('ps after');
|
|
263
324
|
if (finished)
|
|
264
325
|
return;
|
|
265
326
|
if (after === null)
|
|
266
327
|
return finish('incomplete');
|
|
328
|
+
const afterAtMs = awakeNow();
|
|
267
329
|
if (before.length !== after.length ||
|
|
268
330
|
before.some((entry) => !after.some((other) => other.pid === entry.pid &&
|
|
269
331
|
other.ppid === entry.ppid &&
|
|
@@ -274,6 +336,22 @@ export function captureHangDiagnostics(request, source = host) {
|
|
|
274
336
|
incomplete = true;
|
|
275
337
|
lines.push('Process identities or membership changed during capture; open-file census raced.');
|
|
276
338
|
}
|
|
339
|
+
const change = cpuChange(before, after);
|
|
340
|
+
const thresholdsMs = cpuRiseThresholdsMs(before, after);
|
|
341
|
+
rising = change.rising;
|
|
342
|
+
const intervalMs = afterAtMs - beforeAtMs;
|
|
343
|
+
if (change.unread.length > 0) {
|
|
344
|
+
lines.push(`CPU time not read for pid ${change.unread.join(', ')}: ps printed none that parses, so they are not counted idle.`);
|
|
345
|
+
}
|
|
346
|
+
if (rising.length > 0) {
|
|
347
|
+
lines.push(`CPU rose in the tree over about ${intervalMs}ms between the censuses (a rise is named from ${describeCpuThresholds(thresholdsMs)} of CPU):`, ...rising.map((rise) => ` ${describeCpuRise(rise)}`), `Classification: ${CPU_RISING_CLASS}`);
|
|
348
|
+
}
|
|
349
|
+
else if (thresholdsMs.length === 0) {
|
|
350
|
+
lines.push('CPU: no process of the tree had a CPU time ps gave in both censuses, so none was compared.');
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
lines.push(`CPU: no process of the tree gained ${describeCpuThresholds(thresholdsMs)} of CPU over about ${intervalMs}ms between the censuses.`);
|
|
354
|
+
}
|
|
277
355
|
if (!incomplete) {
|
|
278
356
|
for (const wait of waits) {
|
|
279
357
|
lines.push(`Lock wait (open-handle evidence, not a kernel lock owner): ${wait.path} open in the run by pid ${wait.waiters.join(', ')} and outside it by ${describeHolders(wait.holders)}`);
|
|
@@ -306,7 +384,7 @@ export function stopProbe(file, pid) {
|
|
|
306
384
|
return killProcessGroupNow(pid, TEARDOWN_PATIENCE);
|
|
307
385
|
}
|
|
308
386
|
/** A probe owns its group and output pipes; its deadline never waits for an unresponsive child to reap. */
|
|
309
|
-
export function runProbe(file, args, timeoutMs, signal, environment) {
|
|
387
|
+
export function runProbe(file, args, timeoutMs, signal, environment, now = () => performance.now()) {
|
|
310
388
|
// Keep the package's es2022-compatible event-completion convention.
|
|
311
389
|
return new Promise((resolve) => {
|
|
312
390
|
if (signal.aborted) {
|
|
@@ -322,7 +400,7 @@ export function runProbe(file, args, timeoutMs, signal, environment) {
|
|
|
322
400
|
if (settled)
|
|
323
401
|
return;
|
|
324
402
|
settled = true;
|
|
325
|
-
|
|
403
|
+
cancelTimer();
|
|
326
404
|
signal.removeEventListener('abort', aborted);
|
|
327
405
|
child.stdout.destroy();
|
|
328
406
|
child.stderr.destroy();
|
|
@@ -346,7 +424,7 @@ export function runProbe(file, args, timeoutMs, signal, environment) {
|
|
|
346
424
|
finish({ status, detail: detail + killFailure, stdout, stderr });
|
|
347
425
|
};
|
|
348
426
|
const aborted = () => stop('capture deadline reached');
|
|
349
|
-
const
|
|
427
|
+
const cancelTimer = atClockDeadline(now() + timeoutMs, now, () => stop(`probe exceeded ${timeoutMs}ms`));
|
|
350
428
|
signal.addEventListener('abort', aborted, { once: true });
|
|
351
429
|
const append = (stream, chunk) => {
|
|
352
430
|
bytes += Buffer.byteLength(chunk);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { tags } from 'typia';
|
|
2
2
|
/** Peer wait classes from specs/cowshed/05_gateway.md, "Deadlines". */
|
|
3
3
|
export declare const CONTROL_MS = 5000;
|
|
4
|
+
export declare const REAP_MS = 5000;
|
|
4
5
|
export declare const HEARTBEAT_MS = 5000;
|
|
5
6
|
export declare const HEARTBEAT_SILENCE_MS = 15000;
|
|
6
7
|
/** The CPU pool's actor-authored progress, shared by its server and lease client. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lease-wait.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/lease-wait.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAElC,uEAAuE;AACvE,eAAO,MAAM,UAAU,OAAQ,CAAC;AAChC,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M,CAAS;IAEvB,YAA6B,GAAG,GAAE,MAAM,MAAgC,EAGvE;IAED,2FAA2F;IAC3F,IAAI,IAAI,IAAI,CAKX;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAKlC;IAED,qGAAqG;IACrG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMnC;IAED;;;;;OAKG;IACH,IAAI,IAAI,IAAI,CAMX;IAED,qEAAqE;IACrE,WAAW,IAAI,MAAM,CAGpB;IAED,2FAA2F;IAC3F,OAAO,IAAI,cAAc,GAAG,IAAI,CAS/B;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Peer wait classes from specs/cowshed/05_gateway.md, "Deadlines". */
|
|
2
2
|
export const CONTROL_MS = 5_000;
|
|
3
|
+
export const REAP_MS = 5_000;
|
|
3
4
|
export const HEARTBEAT_MS = 5_000;
|
|
4
5
|
export const HEARTBEAT_SILENCE_MS = 15_000;
|
|
5
6
|
/** Pure CPU admission policy; its injected monotonic clock performs no I/O or scheduling. */
|