@smoothbricks/nx-plugin 0.7.18 → 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 +160 -99
- package/dist/.build-inputs.json +35 -29
- package/dist/built-output-packages.js +1 -1
- package/dist/cargo-closure-input.js +1 -1
- package/dist/cargo-source-hash.d.ts +3 -21
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +4 -91
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +2 -1
- 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 +7 -5
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +14 -11
- 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/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.map +1 -1
- package/dist/executors/bounded-exec/executor.js +207 -69
- 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 +3 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +66 -48
- 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 +28 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +30 -9
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +8 -5
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +187 -283
- 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.d.ts +3 -0
- 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/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 +2 -2
- 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 +26 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +26 -5
- 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 +105 -73
- 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/task-results.js +2 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1179 -133
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +105 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/package.json +67 -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/cargo-closure-input.ts +1 -1
- package/src/cargo-source-hash.ts +16 -132
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +1 -2
- 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 +28 -15
- 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/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +280 -106
- 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 +70 -52
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +36 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +213 -182
- 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.ts +37 -2
- 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 +2 -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 +39 -6
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +112 -78
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/workspace-config-policy.ts +161 -43
- package/test-timings.json +157 -147
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
|
@@ -51,7 +51,7 @@ function readLockfile(context) {
|
|
|
51
51
|
throw new Error(`builtOutputPackages names packages, but ${path} does not exist`);
|
|
52
52
|
const contents = packageManager === 'bun' ? readBunLockFile(path) : readFileSync(path, 'utf-8');
|
|
53
53
|
const hash = hashArray([nxVersion, contents]);
|
|
54
|
-
if (published?.hash === hash)
|
|
54
|
+
if (packageManager !== 'bun' && published?.hash === hash)
|
|
55
55
|
return published;
|
|
56
56
|
const { nodes, keyMap } = getLockFileNodes(packageManager, lockFile, contents, hash, context);
|
|
57
57
|
return { packageManager, lockFile, contents, hash, nodes, keyMap };
|
|
@@ -242,7 +242,7 @@ export async function cargoLockNode(directory, sources) {
|
|
|
242
242
|
const paths = new Map(cargo.local.map((pkg) => [pkg.id, `path:${pkg.name}`]));
|
|
243
243
|
const label = (id) => paths.get(id) ?? id;
|
|
244
244
|
const rows = [...closure]
|
|
245
|
-
.map(([id, built]) => [label(id), cargo.
|
|
245
|
+
.map(([id, built]) => [label(id), cargo.pinned.get(id)?.source ?? '', ...built.map(label).sort()].join('\t'))
|
|
246
246
|
.sort();
|
|
247
247
|
hash.update(`${source.manifest}\n${rows.join('\n')}\n\0`);
|
|
248
248
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
+
import { type CargoClosure, type CargoEdge, type PinnedCargoPackage } from '@smoothbricks/build-inputs/cargo-closure';
|
|
1
2
|
import { type FileData } from 'nx/src/native/index.js';
|
|
2
|
-
/** One resolved dependency of a package: the package it resolved to, and whether every declaration of it is a dev one. */
|
|
3
|
-
export interface CargoEdge {
|
|
4
|
-
readonly pkg: string;
|
|
5
|
-
/** Cargo builds this dependency for the dependent's tests, examples and benches only. */
|
|
6
|
-
readonly devOnly: boolean;
|
|
7
|
-
}
|
|
8
|
-
/** Every package Cargo builds for a selection, by package id, each with the dependencies Cargo builds for it. */
|
|
9
|
-
export type CargoClosure = ReadonlyMap<string, readonly string[]>;
|
|
10
3
|
/** A mutable (path) package in Cargo's locked resolve. Every path is canonical. */
|
|
11
4
|
export interface LocalCargoPackage {
|
|
12
5
|
readonly id: string;
|
|
@@ -25,11 +18,8 @@ export interface CargoResolve {
|
|
|
25
18
|
/** The workspace's own members: `root`'s manifest governs each of them. */
|
|
26
19
|
readonly members: ReadonlySet<string>;
|
|
27
20
|
readonly local: readonly LocalCargoPackage[];
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
* dependency names the locked commit that the id alone does not.
|
|
31
|
-
*/
|
|
32
|
-
readonly locked: ReadonlyMap<string, string>;
|
|
21
|
+
/** Every package Cargo.lock pins (registry, git, alternate registry), by package id. */
|
|
22
|
+
readonly pinned: ReadonlyMap<string, PinnedCargoPackage>;
|
|
33
23
|
/** Every dependency edge by package id, or null when Cargo reported no resolution. */
|
|
34
24
|
readonly edges: ReadonlyMap<string, readonly CargoEdge[]> | null;
|
|
35
25
|
}
|
|
@@ -86,14 +76,6 @@ export declare function hashCargoPathInputs(manifestPath: string, workspaceRoot:
|
|
|
86
76
|
* selected.
|
|
87
77
|
*/
|
|
88
78
|
export declare function dependencyClosure(cargo: CargoResolve, directory: string): Promise<CargoClosure>;
|
|
89
|
-
/**
|
|
90
|
-
* The packages Cargo compiles to build, test or run the `selected` ones, each with the dependencies Cargo builds for
|
|
91
|
-
* it. A selected package's targets reach every dependency kind: its library and binaries the normal ones, its build
|
|
92
|
-
* script the build ones, its tests, examples and benches the dev ones. Below the selection Cargo builds a package for
|
|
93
|
-
* its library and build script alone, so a dependency's own dev-dependencies never compile into a selected package's
|
|
94
|
-
* binaries and are not part of what it builds.
|
|
95
|
-
*/
|
|
96
|
-
export declare function buildClosure(cargo: CargoResolve, selected: readonly string[]): CargoClosure;
|
|
97
79
|
/** A compiled-in value, with the source spelling that identifies it across checkouts. */
|
|
98
80
|
export interface CompiledCargoInput {
|
|
99
81
|
readonly file: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-source-hash.d.ts","sourceRoot":"","sources":["../src/cargo-source-hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cargo-source-hash.d.ts","sourceRoot":"","sources":["../src/cargo-source-hash.ts"],"names":[],"mappings":"AAkBA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,SAAS,EAId,KAAK,kBAAkB,EAGxB,MAAM,0CAA0C,CAAC;AAElD,OAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAU/D,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iHAAiH;IACjH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,kGAAkG;AAClG,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACzD,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC;CAClE;AAED,MAAM,W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, realpath, rename, rm, stat,
|
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
7
|
import { homedir } from 'node:os';
|
|
8
8
|
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
9
|
+
import { buildClosure, cargoEdges, localPackagesUnder, parseCargoMetadata, pinnedPackages, } from '@smoothbricks/build-inputs/cargo-closure';
|
|
9
10
|
import { CARGO_ANCESTOR_INPUTS } from '@smoothbricks/cargo-retain/cargo-ancestor-inputs';
|
|
10
11
|
import native from 'nx/src/native/index.js';
|
|
11
12
|
import { workspaceDataDirectoryForWorkspace } from 'nx/src/utils/cache-directory.js';
|
|
@@ -14,65 +15,6 @@ import { describeTeardown, killProcessGroupNow, TEARDOWN_PATIENCE } from './proc
|
|
|
14
15
|
import { rustTokens } from './rust-tokens.js';
|
|
15
16
|
const { IS_WASM, WorkspaceContext, hashArray } = native;
|
|
16
17
|
const cargoResolveEvents = channel('@smoothbricks/nx-plugin:cargo-resolve');
|
|
17
|
-
/**
|
|
18
|
-
* Narrowed field by field, not by typia: graph inference imports this module,
|
|
19
|
-
* and a workspace that loads the plugin from its sources runs them without
|
|
20
|
-
* typia's compile-time transform.
|
|
21
|
-
*/
|
|
22
|
-
function parseCargoMetadata(json) {
|
|
23
|
-
const member = (value, key) => typeof value === 'object' && value !== null && key in value ? Reflect.get(value, key) : undefined;
|
|
24
|
-
const text = (value, field) => {
|
|
25
|
-
if (typeof value !== 'string')
|
|
26
|
-
throw new Error(`cargo metadata reported no valid ${field}`);
|
|
27
|
-
return value;
|
|
28
|
-
};
|
|
29
|
-
const list = (value, field) => {
|
|
30
|
-
if (!Array.isArray(value))
|
|
31
|
-
throw new Error(`cargo metadata reported no valid ${field}`);
|
|
32
|
-
return value;
|
|
33
|
-
};
|
|
34
|
-
const document = JSON.parse(json);
|
|
35
|
-
const resolveGraph = member(document, 'resolve');
|
|
36
|
-
return {
|
|
37
|
-
packages: list(member(document, 'packages'), 'packages').map((pkg) => ({
|
|
38
|
-
id: text(member(pkg, 'id'), 'package id'),
|
|
39
|
-
name: text(member(pkg, 'name'), 'package name'),
|
|
40
|
-
version: text(member(pkg, 'version'), 'package version'),
|
|
41
|
-
source: member(pkg, 'source') === null ? null : text(member(pkg, 'source'), 'package source'),
|
|
42
|
-
manifest_path: text(member(pkg, 'manifest_path'), 'package manifest_path'),
|
|
43
|
-
targets: list(member(pkg, 'targets'), 'package targets').map((target) => ({
|
|
44
|
-
src_path: text(member(target, 'src_path'), 'target src_path'),
|
|
45
|
-
})),
|
|
46
|
-
...(member(pkg, 'governing_manifest_path') === undefined
|
|
47
|
-
? {}
|
|
48
|
-
: { governing_manifest_path: text(member(pkg, 'governing_manifest_path'), 'governing manifest') }),
|
|
49
|
-
})),
|
|
50
|
-
resolve: resolveGraph === null
|
|
51
|
-
? null
|
|
52
|
-
: {
|
|
53
|
-
nodes: list(member(resolveGraph, 'nodes'), 'resolve').map((node) => ({
|
|
54
|
-
id: text(member(node, 'id'), 'resolve node id'),
|
|
55
|
-
deps: list(member(node, 'deps'), 'resolve node deps').map((dependency) => ({
|
|
56
|
-
pkg: text(member(dependency, 'pkg'), 'resolve edge'),
|
|
57
|
-
dep_kinds: dependencyKinds(member(dependency, 'dep_kinds')),
|
|
58
|
-
})),
|
|
59
|
-
})),
|
|
60
|
-
},
|
|
61
|
-
workspace_members: list(member(document, 'workspace_members'), 'workspace_members').map((id) => text(id, 'workspace member')),
|
|
62
|
-
workspace_root: text(member(document, 'workspace_root'), 'workspace_root'),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/** A resolve edge's `dep_kinds`. An edge Cargo reports with no kind is refused: read as dev-only, it would drop a dependency. */
|
|
66
|
-
function dependencyKinds(value) {
|
|
67
|
-
if (!Array.isArray(value) || value.length === 0)
|
|
68
|
-
throw new Error('cargo metadata reported no valid resolve edge kinds');
|
|
69
|
-
return value.map((entry) => {
|
|
70
|
-
const kind = typeof entry === 'object' && entry !== null ? Reflect.get(entry, 'kind') : undefined;
|
|
71
|
-
if (kind !== null && kind !== 'dev' && kind !== 'build')
|
|
72
|
-
throw new Error('cargo metadata reported no valid resolve edge kind');
|
|
73
|
-
return { kind };
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
18
|
/**
|
|
77
19
|
* Nx workers handle termination by exiting, so their exit hook kills owned
|
|
78
20
|
* Cargo groups. Standalone callers need signal forwarding after detaching
|
|
@@ -418,13 +360,8 @@ function cargoFromMetadata(metadata) {
|
|
|
418
360
|
governingManifest: pkg.governing_manifest_path,
|
|
419
361
|
};
|
|
420
362
|
}),
|
|
421
|
-
|
|
422
|
-
edges: metadata
|
|
423
|
-
? null
|
|
424
|
-
: new Map(metadata.resolve.nodes.map((node) => [
|
|
425
|
-
node.id,
|
|
426
|
-
node.deps.map((dep) => ({ pkg: dep.pkg, devOnly: dep.dep_kinds.every(({ kind }) => kind === 'dev') })),
|
|
427
|
-
])),
|
|
363
|
+
pinned: pinnedPackages(metadata),
|
|
364
|
+
edges: cargoEdges(metadata),
|
|
428
365
|
};
|
|
429
366
|
}
|
|
430
367
|
async function loadResolveCache(file) {
|
|
@@ -916,35 +853,11 @@ export async function hashCargoPathInputs(manifestPath, workspaceRoot, options)
|
|
|
916
853
|
*/
|
|
917
854
|
export async function dependencyClosure(cargo, directory) {
|
|
918
855
|
const base = await realpath(directory);
|
|
919
|
-
const selected = cargo.local
|
|
920
|
-
.filter((pkg) => pkg.directory === base || pkg.directory.startsWith(`${base}${sep}`))
|
|
921
|
-
.map((pkg) => pkg.id);
|
|
856
|
+
const selected = localPackagesUnder(cargo.local, base).map((pkg) => pkg.id);
|
|
922
857
|
if (selected.length === 0)
|
|
923
858
|
throw new Error(`no local Cargo package lies under ${directory}`);
|
|
924
859
|
return buildClosure(cargo, selected);
|
|
925
860
|
}
|
|
926
|
-
/**
|
|
927
|
-
* The packages Cargo compiles to build, test or run the `selected` ones, each with the dependencies Cargo builds for
|
|
928
|
-
* it. A selected package's targets reach every dependency kind: its library and binaries the normal ones, its build
|
|
929
|
-
* script the build ones, its tests, examples and benches the dev ones. Below the selection Cargo builds a package for
|
|
930
|
-
* its library and build script alone, so a dependency's own dev-dependencies never compile into a selected package's
|
|
931
|
-
* binaries and are not part of what it builds.
|
|
932
|
-
*/
|
|
933
|
-
export function buildClosure(cargo, selected) {
|
|
934
|
-
if (cargo.edges === null)
|
|
935
|
-
throw new Error('cargo metadata reported no dependency resolution');
|
|
936
|
-
const roots = new Set(selected);
|
|
937
|
-
const reached = new Map();
|
|
938
|
-
const pending = [...selected];
|
|
939
|
-
for (let id = pending.pop(); id !== undefined; id = pending.pop()) {
|
|
940
|
-
if (reached.has(id))
|
|
941
|
-
continue;
|
|
942
|
-
const built = (cargo.edges.get(id) ?? []).filter((edge) => roots.has(id) || !edge.devOnly).map((edge) => edge.pkg);
|
|
943
|
-
reached.set(id, built);
|
|
944
|
-
pending.push(...built);
|
|
945
|
-
}
|
|
946
|
-
return reached;
|
|
947
|
-
}
|
|
948
861
|
/**
|
|
949
862
|
* Whether git ignores a path beneath one of the package directories. A
|
|
950
863
|
* package whose own directory is ignored (an installed dependency, say) keeps
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* wrapper's object, and one entry covers all three.
|
|
17
17
|
*
|
|
18
18
|
* rustc and cargo are not here on purpose. Cargo keys units on the output of `rustc -vV`, never on rustc's path, and the
|
|
19
|
-
* version recipe beside this one hashes it.
|
|
20
|
-
*
|
|
19
|
+
* version recipe beside this one hashes it. Shells of one host may carry different rust-std targets, so a rustc path
|
|
20
|
+
* would split one target's key between them.
|
|
21
21
|
*
|
|
22
22
|
* Only a path in the Nix store counts. A store object is named by the hash of everything it was built from, so one
|
|
23
23
|
* shell gives one object on every machine of a platform. A path elsewhere belongs to the machine and takes no part.
|
|
@@ -18,8 +18,8 @@ import { delimiter, join } from 'node:path';
|
|
|
18
18
|
* wrapper's object, and one entry covers all three.
|
|
19
19
|
*
|
|
20
20
|
* rustc and cargo are not here on purpose. Cargo keys units on the output of `rustc -vV`, never on rustc's path, and the
|
|
21
|
-
* version recipe beside this one hashes it.
|
|
22
|
-
*
|
|
21
|
+
* version recipe beside this one hashes it. Shells of one host may carry different rust-std targets, so a rustc path
|
|
22
|
+
* would split one target's key between them.
|
|
23
23
|
*
|
|
24
24
|
* Only a path in the Nix store counts. A store object is named by the hash of everything it was built from, so one
|
|
25
25
|
* shell gives one object on every machine of a platform. A path elsewhere belongs to the machine and takes no part.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cargo-workspace.d.ts","sourceRoot":"","sources":["../src/cargo-workspace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cargo-workspace.d.ts","sourceRoot":"","sources":["../src/cargo-workspace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAExB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,+BAAgC,SAAQ,qBAAqB;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,0BAA0B,CAAC,mBAAmB,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAkF/F;AA0ED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,SAAS,qBAAqB,EAAE,EAC1C,QAAQ,EAAE,SAAS,qBAAqB,EAAE,GACzC,+BAA+B,EAAE,CAgBnC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,uBAAuB,CAAC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DAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAC;IACf,qGAAqG;IACrG,KAAK,EAAE,oBAAoB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,GAAG,eAAe,EAAE,CAuC7E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAMhE;AAmKD,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,sDAAsD,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB,yBAAyB,CAAC"}
|
package/dist/cargo-workspace.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { readFile, realpath } from 'node:fs/promises';
|
|
3
3
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { buildClosure } from '@smoothbricks/build-inputs/cargo-closure';
|
|
4
5
|
import { readNxJson } from 'nx/src/config/nx-json.js';
|
|
5
6
|
import { parse as parseToml } from 'smol-toml';
|
|
6
|
-
import {
|
|
7
|
+
import { compiledInFiles, } from './cargo-source-hash.js';
|
|
7
8
|
export function listCargoWorkspacePackages(absoluteProjectRoot) {
|
|
8
9
|
const workspaceTomlPath = join(absoluteProjectRoot, 'Cargo.toml');
|
|
9
10
|
if (!existsSync(workspaceTomlPath)) {
|
|
@@ -22,6 +22,8 @@ export interface ObservationHost {
|
|
|
22
22
|
step(event: BoundEvent): void;
|
|
23
23
|
/** Whether the command is running a test. */
|
|
24
24
|
testing(): boolean;
|
|
25
|
+
/** Same sleep-excluding clock as the executor's idle bound. */
|
|
26
|
+
awakeNow(): number;
|
|
25
27
|
readonly queueHost: QueueHost | undefined;
|
|
26
28
|
}
|
|
27
29
|
/** One run's view of the admission queue its leaf waits in. */
|
|
@@ -37,7 +39,7 @@ export declare class AdmissionObservation {
|
|
|
37
39
|
* and ends nothing: the bounds decide, and an idle expiry names it.
|
|
38
40
|
*/
|
|
39
41
|
private failure;
|
|
40
|
-
/** When the last successful snapshot completed
|
|
42
|
+
/** When the last successful snapshot completed on the awake clock: credit runs to it and no further. */
|
|
41
43
|
private confirmedAt;
|
|
42
44
|
private readonly abort;
|
|
43
45
|
private timer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admission-queue.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/admission-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,UAAU,EAAwC,MAAM,aAAa,CAAC;AAErG,OAAO,EAA4C,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAE,KAAK,kBAAkB,EAA0B,MAAM,cAAc,CAAC;AAE/E;;;;GAIG;AAEH,8FAA8F;AAC9F,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,IAAI,IAAI,OAAO,CAAC;IAChB,6CAA6C;IAC7C,GAAG,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1B,kFAAkF;IAClF,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC;IACjC,0BAA0B;IAC1B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,8BAA8B;IAC9B,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,6CAA6C;IAC7C,OAAO,IAAI,OAAO,CAAC;IACnB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG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AAQ,UAAS;IACjB,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,QAAQ,CAAmC;IACnD;;;;OAIG;IACH,OAAO,CAAC,OAAO,CAAuB;IACtC,wGAAwG;IACxG,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;IAC/C,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,uBAAuB,CAAM;IAErC,YAA6B,IAAI,EAAE,eAAe,EAAI;IAEtD,8EAA8E;IAC9E,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAItD;IAED,qEAAqE;IACrE,OAAO,IAAI,IAAI,CAEd;IAED,0GAA0G;IAC1G,IAAI,IAAI,IAAI,CAKX;IAED,yFAAyF;IACzF,IAAI,IAAI,IAAI,CAIX;IAED,oDAAoD;IAC9C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1B;IAED,OAAO,CAAC,SAAS;IAmBjB,2DAA2D;IACrD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C3C;CACF"}
|
|
@@ -15,7 +15,7 @@ export class AdmissionObservation {
|
|
|
15
15
|
* and ends nothing: the bounds decide, and an idle expiry names it.
|
|
16
16
|
*/
|
|
17
17
|
failure = null;
|
|
18
|
-
/** When the last successful snapshot completed
|
|
18
|
+
/** When the last successful snapshot completed on the awake clock: credit runs to it and no further. */
|
|
19
19
|
confirmedAt = null;
|
|
20
20
|
abort = new AbortController();
|
|
21
21
|
timer;
|
|
@@ -37,11 +37,11 @@ export class AdmissionObservation {
|
|
|
37
37
|
queueWait(reserved) {
|
|
38
38
|
return this.admitted || (this.requests.length === 0 && !reserved)
|
|
39
39
|
? null
|
|
40
|
-
: { waitedMs: admissionWaitMs(this.wait,
|
|
40
|
+
: { waitedMs: admissionWaitMs(this.wait, this.host.awakeNow()), requests: this.requests };
|
|
41
41
|
}
|
|
42
42
|
/** A reserved leaf's request began to wait on its run's endpoint. */
|
|
43
43
|
waiting() {
|
|
44
|
-
this.wait = stepAdmissionWait(this.wait, { kind: 'snapshot', at:
|
|
44
|
+
this.wait = stepAdmissionWait(this.wait, { kind: 'snapshot', at: this.host.awakeNow(), waiting: true });
|
|
45
45
|
}
|
|
46
46
|
/** Only mbx's activity report says whether a Cargo leaf's compiler or test waits in the pool: poll it. */
|
|
47
47
|
poll() {
|
|
@@ -52,7 +52,7 @@ export class AdmissionObservation {
|
|
|
52
52
|
}
|
|
53
53
|
/** The run ended: the wait stops counting and no snapshot is taken or credited again. */
|
|
54
54
|
stop() {
|
|
55
|
-
this.wait = stepAdmissionWait(this.wait, { kind: 'stop', at:
|
|
55
|
+
this.wait = stepAdmissionWait(this.wait, { kind: 'stop', at: this.host.awakeNow() });
|
|
56
56
|
clearInterval(this.timer);
|
|
57
57
|
this.abort.abort();
|
|
58
58
|
}
|
|
@@ -68,11 +68,11 @@ export class AdmissionObservation {
|
|
|
68
68
|
}
|
|
69
69
|
this.failure = detail;
|
|
70
70
|
this.requests = [];
|
|
71
|
-
this.wait = stepAdmissionWait(this.wait, { kind: 'snapshot', at:
|
|
71
|
+
this.wait = stepAdmissionWait(this.wait, { kind: 'snapshot', at: this.host.awakeNow(), waiting: false });
|
|
72
72
|
// The wait since the last confirmed snapshot is unconfirmed: the idle bound resumes from that snapshot.
|
|
73
73
|
this.host.step({
|
|
74
74
|
kind: 'admission-queue',
|
|
75
|
-
at: this.confirmedAt ??
|
|
75
|
+
at: this.confirmedAt ?? this.host.awakeNow(),
|
|
76
76
|
waiting: false,
|
|
77
77
|
testing: this.host.testing(),
|
|
78
78
|
});
|
|
@@ -98,9 +98,8 @@ export class AdmissionObservation {
|
|
|
98
98
|
}
|
|
99
99
|
this.lastSnapshotDiagnostics = diagnostics;
|
|
100
100
|
const waiting = snapshot.requests.length > 0;
|
|
101
|
-
const observedAt =
|
|
102
|
-
|
|
103
|
-
this.wait = stepAdmissionWait(this.wait, { kind: 'snapshot', at: observedWaitAt, waiting });
|
|
101
|
+
const observedAt = this.host.awakeNow();
|
|
102
|
+
this.wait = stepAdmissionWait(this.wait, { kind: 'snapshot', at: observedAt, waiting });
|
|
104
103
|
this.failure = null;
|
|
105
104
|
this.confirmedAt = observedAt;
|
|
106
105
|
if (waiting) {
|
|
@@ -109,7 +108,7 @@ export class AdmissionObservation {
|
|
|
109
108
|
if (positions !== this.lastDiagnostic ||
|
|
110
109
|
this.lastDiagnosticAt === null ||
|
|
111
110
|
Date.now() - this.lastDiagnosticAt >= HANG_CAPTURE_MS) {
|
|
112
|
-
const waitedMs = admissionWaitMs(this.wait,
|
|
111
|
+
const waitedMs = admissionWaitMs(this.wait, observedAt);
|
|
113
112
|
this.host.tell(`cowshed: mbx ${describeAdmissionQueue({ waitedMs, requests: snapshot.requests })}\n`);
|
|
114
113
|
this.lastDiagnostic = positions;
|
|
115
114
|
this.lastDiagnosticAt = Date.now();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The idle clock tracks awake time, not wall time or CPU consumed by this process. */
|
|
2
|
+
export declare function openAwakeClock(): Promise<() => number>;
|
|
3
|
+
/** A timer is only a wake-up. An early callback arms the remaining time on the same clock. */
|
|
4
|
+
export declare function atClockDeadline(at: number, now: () => number, reached: () => void): () => void;
|
|
5
|
+
//# sourceMappingURL=awake-clock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awake-clock.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/awake-clock.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,MAAM,CAAC,CAO5D;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAQ9F"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The idle clock tracks awake time, not wall time or CPU consumed by this process. */
|
|
2
|
+
export async function openAwakeClock() {
|
|
3
|
+
// Bun 1.4.4 uses Rust Instant, and Linux Node uses CLOCK_MONOTONIC. Darwin Node's libuv uses
|
|
4
|
+
// mach_continuous_time, which includes sleep; its awake reading comes from the cowshed addon.
|
|
5
|
+
if (process.platform !== 'darwin' || process.versions.bun !== undefined)
|
|
6
|
+
return () => performance.now();
|
|
7
|
+
const { awakeTimeMs } = await import('@smoothbricks/cowshed/awake-clock');
|
|
8
|
+
awakeTimeMs(); // Refuse a missing or stale addon before the executor spawns anything.
|
|
9
|
+
return awakeTimeMs;
|
|
10
|
+
}
|
|
11
|
+
/** A timer is only a wake-up. An early callback arms the remaining time on the same clock. */
|
|
12
|
+
export function atClockDeadline(at, now, reached) {
|
|
13
|
+
const wake = () => {
|
|
14
|
+
const remaining = at - now();
|
|
15
|
+
if (remaining > 0)
|
|
16
|
+
timer = setTimeout(wake, Math.ceil(remaining));
|
|
17
|
+
else
|
|
18
|
+
reached();
|
|
19
|
+
};
|
|
20
|
+
let timer = setTimeout(wake, Math.ceil(Math.max(0, at - now())));
|
|
21
|
+
return () => clearTimeout(timer);
|
|
22
|
+
}
|
|
@@ -18,8 +18,8 @@ export interface BoundLimits {
|
|
|
18
18
|
readonly totalMs?: number;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* When each armed bound expires
|
|
22
|
-
* its pool's grant, so
|
|
21
|
+
* When each armed bound expires: idle on the awake clock, fixture and total on the wall clock. A null bound is not
|
|
22
|
+
* armed. A queued run waits for its pool's grant, so only a fixture started at spawn can have a ceiling then.
|
|
23
23
|
*/
|
|
24
24
|
export interface Bounds {
|
|
25
25
|
readonly idle: number | null;
|
|
@@ -35,11 +35,12 @@ export type BoundEvent =
|
|
|
35
35
|
/**
|
|
36
36
|
* The command started; `testing` is the lifecycle's answer then, `fixture` whether a supervised fixture leads it,
|
|
37
37
|
* `queued` whether mbx schedules this leaf, as known before spawn, and `fixtureFirst` whether that fixture runs
|
|
38
|
-
* before the leaf's reservation (
|
|
38
|
+
* before the leaf's reservation (every reserved leaf's does), so its ceiling starts now, not at the grant.
|
|
39
39
|
*/
|
|
40
40
|
{
|
|
41
41
|
readonly kind: 'spawn';
|
|
42
42
|
readonly at: number;
|
|
43
|
+
readonly wallAt: number;
|
|
43
44
|
readonly testing: boolean;
|
|
44
45
|
readonly fixture: boolean;
|
|
45
46
|
readonly queued: boolean;
|
|
@@ -49,6 +50,7 @@ export type BoundEvent =
|
|
|
49
50
|
| {
|
|
50
51
|
readonly kind: 'granted';
|
|
51
52
|
readonly at: number;
|
|
53
|
+
readonly wallAt: number;
|
|
52
54
|
readonly testing: boolean;
|
|
53
55
|
readonly fixture: boolean;
|
|
54
56
|
} | {
|
|
@@ -90,9 +92,9 @@ export declare const UNARMED: Bounds;
|
|
|
90
92
|
/** The bounds after `event`. */
|
|
91
93
|
export declare function stepBounds(bounds: Bounds, limits: BoundLimits, event: BoundEvent): Bounds;
|
|
92
94
|
/** The bound that expires first, or `null` when none is armed. A tie names the total, then the fixture, then idle. */
|
|
93
|
-
export declare function earliestBound(bounds: Bounds): {
|
|
95
|
+
export declare function earliestBound(bounds: Bounds, awakeNow: number, wallNow: number): {
|
|
94
96
|
readonly kind: BoundKind;
|
|
95
|
-
readonly
|
|
97
|
+
readonly remainingMs: number;
|
|
96
98
|
} | null;
|
|
97
99
|
/** Observed queue duration on a monotonic clock; stopping closes its interval permanently, before cleanup begins. */
|
|
98
100
|
export type AdmissionWait = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/bounds.ts"],"names":[],"mappings":"AAA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,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxF;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC7E;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,aAA+D,CAAC;AAEhG,2GAA2G;AAC3G,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAK/F"}
|
|
@@ -20,12 +20,12 @@ export const UNARMED = {
|
|
|
20
20
|
holds: null,
|
|
21
21
|
idleRemaining: null,
|
|
22
22
|
};
|
|
23
|
-
/** The bounds a command
|
|
24
|
-
function armed(limits,
|
|
23
|
+
/** The bounds a command arms when it starts running. */
|
|
24
|
+
function armed(limits, event) {
|
|
25
25
|
return {
|
|
26
|
-
idle: testing && limits.idleMs !== undefined ? at + limits.idleMs : null,
|
|
27
|
-
fixture: fixture && limits.fixtureMs !== undefined ?
|
|
28
|
-
total: limits.totalMs !== undefined ?
|
|
26
|
+
idle: event.testing && limits.idleMs !== undefined ? event.at + limits.idleMs : null,
|
|
27
|
+
fixture: event.fixture && limits.fixtureMs !== undefined ? event.wallAt + limits.fixtureMs : null,
|
|
28
|
+
total: limits.totalMs !== undefined ? event.wallAt + limits.totalMs : null,
|
|
29
29
|
queued: false,
|
|
30
30
|
admissionWaiting: false,
|
|
31
31
|
holds: null,
|
|
@@ -42,14 +42,14 @@ export function stepBounds(bounds, limits, event) {
|
|
|
42
42
|
queued: true,
|
|
43
43
|
holds: 0,
|
|
44
44
|
idleRemaining: limits.idleMs ?? null,
|
|
45
|
-
fixture: event.fixtureFirst && limits.fixtureMs !== undefined ? event.
|
|
45
|
+
fixture: event.fixtureFirst && limits.fixtureMs !== undefined ? event.wallAt + limits.fixtureMs : null,
|
|
46
46
|
}
|
|
47
|
-
: armed(limits, event
|
|
47
|
+
: armed(limits, event);
|
|
48
48
|
case 'granted': {
|
|
49
49
|
if (bounds.holds === null)
|
|
50
50
|
return bounds;
|
|
51
51
|
if (bounds.queued) {
|
|
52
|
-
const admitted = armed(limits, event
|
|
52
|
+
const admitted = armed(limits, event);
|
|
53
53
|
return {
|
|
54
54
|
...admitted,
|
|
55
55
|
holds: 1,
|
|
@@ -117,12 +117,15 @@ export function stepBounds(bounds, limits, event) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
/** The bound that expires first, or `null` when none is armed. A tie names the total, then the fixture, then idle. */
|
|
120
|
-
export function earliestBound(bounds) {
|
|
120
|
+
export function earliestBound(bounds, awakeNow, wallNow) {
|
|
121
121
|
let earliest = null;
|
|
122
122
|
for (const kind of ['total', 'fixture', 'idle']) {
|
|
123
123
|
const at = bounds[kind];
|
|
124
|
-
if (at
|
|
125
|
-
|
|
124
|
+
if (at === null)
|
|
125
|
+
continue;
|
|
126
|
+
const remainingMs = at - (kind === 'idle' ? awakeNow : wallNow);
|
|
127
|
+
if (earliest === null || remainingMs < earliest.remainingMs)
|
|
128
|
+
earliest = { kind, remainingMs };
|
|
126
129
|
}
|
|
127
130
|
return earliest;
|
|
128
131
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reserved nextest leaf's case gate (specs/cowshed/05_gateway.md, "A case starts on a core"). The leaf's runner
|
|
3
|
+
* starts every thread of its ask, and each case takes a core before it runs: one of the leaf's grant when one is free,
|
|
4
|
+
* else one reserved for that case alone, which the leaf's executor asks its run's endpoint for and gives back when the
|
|
5
|
+
* case ends. A grant never grows, so this is how the cores other work frees after the leaf's grant reach it.
|
|
6
|
+
*
|
|
7
|
+
* The gate is a Unix stream socket the executor serves for one run and names in the command's environment as
|
|
8
|
+
* {@link TEST_GATE_ENV}. mbx's test shim, through which nextest starts every case, connects before the case starts,
|
|
9
|
+
* writes one line ({@link CaseLine}), starts the case when the line {@link GO} answers, and keeps the connection until
|
|
10
|
+
* the case has exited: the connection's end is the case's end.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TEST_GATE_ENV = "MBX_TEST_GATE";
|
|
13
|
+
/**
|
|
14
|
+
* Set to `1` in a run's environment once its endpoint answered that the installed mbx's shim gates its cases
|
|
15
|
+
* (endpoint-life.ts, `gatesTests`): without it a leaf's runner is sized to its grant.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TEST_GATE_SERVED_ENV = "BOUNDED_EXEC_MBX_TEST_GATE";
|
|
18
|
+
/** The line that starts a case. */
|
|
19
|
+
export declare const GO = "go";
|
|
20
|
+
/** A case's id as its result names it (progress.ts): the binary id, `::`, the test. */
|
|
21
|
+
export declare function caseId(binary: string, test: string): string;
|
|
22
|
+
/** What the gate does outside itself. */
|
|
23
|
+
export interface CaseGateEffects {
|
|
24
|
+
/** Start the case: answer its connection. */
|
|
25
|
+
readonly start: (id: string) => void;
|
|
26
|
+
/** Ask the pool for one core in the case's name. */
|
|
27
|
+
readonly reserve: (id: string) => void;
|
|
28
|
+
/** Give the case's core back to the pool, or withdraw its request while it waits. */
|
|
29
|
+
readonly release: (id: string) => void;
|
|
30
|
+
}
|
|
31
|
+
/** What a leaf's cases did at its gate. */
|
|
32
|
+
export interface CaseGateSummary {
|
|
33
|
+
/** Cases that ran on the leaf's grant, and on a core of their own. */
|
|
34
|
+
readonly own: number;
|
|
35
|
+
readonly lent: number;
|
|
36
|
+
/** How long the cases on a core of their own held it, summed. */
|
|
37
|
+
readonly lentCoreMs: number;
|
|
38
|
+
/** How long the cases waited at the gate, summed. */
|
|
39
|
+
readonly waitedCaseMs: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The gate's decisions, as a state machine over three events: a case arrived, the pool granted a case's request, a
|
|
43
|
+
* case ended. `own` is the leaf's granted cores; `wall` a case's last recorded wall, by which a freed core of the
|
|
44
|
+
* grant picks the longest waiting case, so the cores the pool gives go to the shorter ones and come back soonest.
|
|
45
|
+
*/
|
|
46
|
+
export declare class CaseGate {
|
|
47
|
+
#private;
|
|
48
|
+
private readonly own;
|
|
49
|
+
private readonly wall;
|
|
50
|
+
private readonly effects;
|
|
51
|
+
private readonly now;
|
|
52
|
+
constructor(own: number, wall: (id: string) => number, effects: CaseGateEffects, now?: () => number);
|
|
53
|
+
/** A case's shim connected. False for a case already at the gate, which its second connection may not join. */
|
|
54
|
+
arrived(id: string): boolean;
|
|
55
|
+
/** The pool granted the case's request. One whose case no longer waits gives the core straight back. */
|
|
56
|
+
granted(id: string): void;
|
|
57
|
+
/** A case's connection ended: its core goes back where it came from, a waiting case's request is withdrawn. */
|
|
58
|
+
ended(id: string): void;
|
|
59
|
+
/** How long the case waited at the gate before it started, in ms; zero for one that never did. */
|
|
60
|
+
waitedMs(id: string): number;
|
|
61
|
+
/** The last recorded walls of the cases that ran and ended, summed. */
|
|
62
|
+
ranWallMs(): number;
|
|
63
|
+
summary(): CaseGateSummary;
|
|
64
|
+
}
|
|
65
|
+
/** One core asked of a pool for one case: whether the pool granted it, and how it is given back or withdrawn. */
|
|
66
|
+
export interface CaseCore {
|
|
67
|
+
/** Settles once the pool grants the core (true), or refuses, loses or is withdrawn the request (false). */
|
|
68
|
+
readonly granted: Promise<boolean>;
|
|
69
|
+
/** Gives the core back, or withdraws the request while it waits. Later calls do nothing. */
|
|
70
|
+
release(): void;
|
|
71
|
+
}
|
|
72
|
+
/** A leaf's gate decisions and the cores its waiting cases asked their pool for. */
|
|
73
|
+
export interface GatedCases {
|
|
74
|
+
readonly cases: CaseGate;
|
|
75
|
+
/** Gives back every core a case still holds and withdraws every request that waits. */
|
|
76
|
+
releaseAll(): void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The gate of a leaf that holds `own` cores, over whichever pool `ask` asks: mbx's, through the run's reservation
|
|
80
|
+
* endpoint, or the run's own token pool (cpu-pool.ts, `lendParentToken`). `start` answers a case's connection.
|
|
81
|
+
* `walls` are the cases' last recorded walls; a request is told the work the leaf has left, their sum less the walls
|
|
82
|
+
* of the cases that ran, by which a token pool lends to the leaf that would otherwise end last.
|
|
83
|
+
*/
|
|
84
|
+
export declare function gateCases(own: number, walls: ReadonlyMap<string, number>, start: (id: string) => void, ask: (id: string, leftMs: number) => CaseCore): GatedCases;
|
|
85
|
+
/**
|
|
86
|
+
* A case's wall as its result records it: nextest times a case from the shim's start, so its own duration includes the
|
|
87
|
+
* wait at the gate, which is taken off. Never below zero.
|
|
88
|
+
*/
|
|
89
|
+
export declare function runWallMs(nextestMs: number, waitedMs: number): number;
|
|
90
|
+
export interface CaseGateServer {
|
|
91
|
+
/** The socket's path, as the command's environment names it. */
|
|
92
|
+
readonly socket: string;
|
|
93
|
+
/** Answer the case's connection: it starts. */
|
|
94
|
+
start(id: string): void;
|
|
95
|
+
/** Ends every connection and removes the socket's directory; the error that left something behind, or null. */
|
|
96
|
+
close(): Promise<string | null>;
|
|
97
|
+
}
|
|
98
|
+
export interface CaseGateHandlers {
|
|
99
|
+
/** A case's shim connected and named it. False refuses the connection. */
|
|
100
|
+
readonly arrived: (id: string) => boolean;
|
|
101
|
+
/** A named case's connection ended. */
|
|
102
|
+
readonly ended: (id: string) => void;
|
|
103
|
+
/** A client wrote something that is no case line, or named a case already at the gate; its connection is ended. */
|
|
104
|
+
readonly invalid: (detail: string) => void;
|
|
105
|
+
}
|
|
106
|
+
/** Serve one run's case gate; a gate that cannot be served is the run's refusal. */
|
|
107
|
+
export declare function serveCaseGate(handlers: CaseGateHandlers): Promise<{
|
|
108
|
+
ok: true;
|
|
109
|
+
gate: CaseGateServer;
|
|
110
|
+
} | {
|
|
111
|
+
ok: false;
|
|
112
|
+
error: string;
|
|
113
|
+
}>;
|
|
114
|
+
//# sourceMappingURL=case-gate.d.ts.map
|