@roomi-fields/grillhouse 0.44.0 → 0.45.1
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +32 -0
- package/cadre/templates/projet/.claude/settings.json +5 -0
- package/cadre/templates/projet/CLAUDE.md +15 -2
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/charte.md +3 -2
- package/dist/temporal/circuit/client.d.ts +7 -0
- package/dist/temporal/circuit/client.js +12 -2
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/commande.js +8 -1
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/installation.d.ts +26 -1
- package/dist/temporal/installation.js +113 -14
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/tickets/activites.js +3 -1
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/docs/ARCHITECTURE.md +207 -68
- package/docs/INTERFACE.md +24 -16
- package/package.json +1 -1
- package/scripts/activites.mjs +66 -46
- package/scripts/aiguillage.mjs +1 -0
- package/scripts/attente-de-la-machine.mjs +312 -0
- package/scripts/avancement.mjs +38 -31
- package/scripts/bilan.mjs +30 -5
- package/scripts/circuit.mjs +10 -7
- package/scripts/codes-de-sortie.mjs +1 -1
- package/scripts/coeurs-dedies.mjs +427 -0
- package/scripts/composants-affectes.mjs +3 -1
- package/scripts/consommation-des-passes.mjs +382 -0
- package/scripts/consommation.mjs +45 -0
- package/scripts/copies-finies.mjs +2 -2
- package/scripts/depart-du-ticket.mjs +3 -1
- package/scripts/disque-des-copies.mjs +1 -1
- package/scripts/echantillonneur-de-la-passe.mjs +103 -0
- package/scripts/enveloppe/enveloppe.mjs +1 -11
- package/scripts/enveloppe/travail-de-la-copie.mjs +3 -2
- package/scripts/grillhouse-maj.mjs +8 -4
- package/scripts/integration/file.mjs +10 -4
- package/scripts/jointure.d.ts +20 -9
- package/scripts/langages/cargo/commandes.mjs +8 -8
- package/scripts/langages/python/commandes.mjs +7 -6
- package/scripts/langages/typescript/tests-de-nuit.mjs +17 -4
- package/scripts/langages/typescript/tests.mjs +15 -6
- package/scripts/langages/typescript/verifier.mjs +23 -17
- package/scripts/langages/typescript/vitest-config/base.mjs +3 -3
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -7
- package/scripts/mesure/base-de-passe.mjs +1 -1
- package/scripts/migrations/0.44.0-seuil-des-codes-de-tickets.mjs +47 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/passe-de-la-machine.mjs +456 -31
- package/scripts/places-de-la-machine.mjs +508 -61
- package/scripts/plafond-de-la-machine.d.mts +47 -2
- package/scripts/plafond-de-la-machine.mjs +197 -5
- package/scripts/preparation.mjs +1 -0
- package/scripts/regles-des-places.d.mts +40 -0
- package/scripts/regles-des-places.mjs +91 -0
- package/scripts/retirer-les-copies-finies.mjs +1 -1
- package/scripts/seances.mjs +4 -3
- package/scripts/services-du-noyau.mjs +3 -3
- package/scripts/sous-commandes.mjs +6 -7
- package/scripts/tableau.mjs +121 -112
- package/scripts/verrou-de-machine.mjs +0 -829
|
@@ -1,16 +1,62 @@
|
|
|
1
|
-
// A pass
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
|
|
1
|
+
// A pass on the machine: each takes its part of the budget (scripts/places-de-la-machine.mjs
|
|
2
|
+
// `prendreUnePart`), waiting for it when the parts held leave too little, and plays held to that
|
|
3
|
+
// part by the system: a control group of its own (`systemd-run --user --scope`) whose CPU weight
|
|
4
|
+
// and memory bound come from the part, with no hard CPU ceiling (a ceiling pauses a pass by jerks;
|
|
5
|
+
// a weight slows nothing on a free machine, as the `cpu.weight` of the kernel shares the cores
|
|
6
|
+
// only when they are short). Its tools receive the processes of its part
|
|
7
|
+
// (GRILLHOUSE_TRAVAILLEURS). A pass takes no place of the machine: a place is a session of an
|
|
8
|
+
// agent or a circuit.
|
|
9
|
+
//
|
|
10
|
+
// - A pass out of the envelope of an agent is held to its part: the heavy pass of a circuit (its
|
|
11
|
+
// command, launched by the circuit), `npm run verifier`, a targeted `npm test`, the CI on a
|
|
12
|
+
// machine of ours, the night. The commands an agent launches in its envelope take no part (the
|
|
13
|
+
// place of its session covers them) and play without a group; where the system gives no group
|
|
14
|
+
// (no manager of the user), the pass plays without one too; each says it once, « joue sans part
|
|
15
|
+
// tenue ».
|
|
16
|
+
// - A heavy pass keeps what it consumes (scripts/consommation-des-passes.mjs): a pass that is the
|
|
17
|
+
// process itself (`npm run verifier`) enters its group by `StartTransientUnit` of the manager
|
|
18
|
+
// of the user, the weight and the bound of its part among its properties; a pass the circuit
|
|
19
|
+
// launches as a command (`mode: 'commande'`) runs in the group `commandeDuGroupe` builds, its
|
|
20
|
+
// unit named, which a sampler reads. A pass that consumes clearly more than its part is said to
|
|
21
|
+
// the board and to the figures (`depasseLaPart`).
|
|
22
|
+
// - A pass under the part its parent holds (GRILLHOUSE_PART_TENUE) takes none of its own.
|
|
23
|
+
import { spawnSync } from 'node:child_process';
|
|
24
|
+
import { readFileSync } from 'node:fs';
|
|
7
25
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
26
|
+
coeursDeLaMachine,
|
|
27
|
+
depasseLaPart,
|
|
28
|
+
garderLaConsommation,
|
|
29
|
+
poidsDeLaPart,
|
|
30
|
+
scopeDeCommande,
|
|
31
|
+
scopeSystemd,
|
|
32
|
+
sorteDeLaPasse,
|
|
33
|
+
} from './consommation-des-passes.mjs';
|
|
34
|
+
import { AttenteDeLaMachine } from './attente-de-la-machine.mjs';
|
|
35
|
+
import {
|
|
36
|
+
attacheDesCoeurs,
|
|
37
|
+
chargeHorsMesure,
|
|
38
|
+
codeDeLaMesure,
|
|
39
|
+
ecartDesProgrammes,
|
|
40
|
+
listeDeCoeurs,
|
|
41
|
+
lireLesTempsOccupes,
|
|
42
|
+
OUTIL_D_AFFINITE,
|
|
43
|
+
tempsDuSysteme,
|
|
44
|
+
} from './coeurs-dedies.mjs';
|
|
45
|
+
import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
|
|
46
|
+
import {
|
|
47
|
+
dossierDesParts,
|
|
48
|
+
prendreUnePart,
|
|
49
|
+
sousNiceEtIonice,
|
|
11
50
|
travailleursDe,
|
|
51
|
+
VARIABLE_TRAVAILLEURS,
|
|
12
52
|
} from './places-de-la-machine.mjs';
|
|
13
53
|
|
|
54
|
+
// The launcher of a command in a control group of the manager of the user.
|
|
55
|
+
const LANCEUR_DE_GROUPE = 'systemd-run';
|
|
56
|
+
// The slice of the user's manager the groups of the frame live under, beside `app.slice`, which the
|
|
57
|
+
// programs out of the frame are in: the cores kept from them are not kept from the frame's groups.
|
|
58
|
+
const TRANCHE_DU_CADRE = 'grillhouse.slice';
|
|
59
|
+
|
|
14
60
|
/**
|
|
15
61
|
* Whether the npm command of a step is a heavy pass: `npm run verifier`, whatever its step.
|
|
16
62
|
* @param {{ etape: string, args: string[] }} o
|
|
@@ -20,10 +66,9 @@ export function passeLourde({ args }) {
|
|
|
20
66
|
}
|
|
21
67
|
|
|
22
68
|
/**
|
|
23
|
-
* What a
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `ionice`, GRILLHOUSE_TRAVAILLEURS set to max(1, cores ÷ places).
|
|
69
|
+
* What a session out of the envelope launches: its command under `nice` and `ionice`,
|
|
70
|
+
* GRILLHOUSE_TRAVAILLEURS set to max(1, cores ÷ places); a heavy one runs its command as it is,
|
|
71
|
+
* without the workers it inherits.
|
|
27
72
|
* @param {{ lourde: boolean, cmd: string, args: string[], env: Record<string, string | undefined> }} o
|
|
28
73
|
* @returns {{ cmd: string, args: string[], env: Record<string, string | undefined> }}
|
|
29
74
|
*/
|
|
@@ -41,32 +86,412 @@ export function lancementDeLaPasse({ lourde, cmd, args, env }) {
|
|
|
41
86
|
}
|
|
42
87
|
|
|
43
88
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* the
|
|
89
|
+
* The command line that runs <cmd> in a control group of its own under the part <part>: `systemd-run
|
|
90
|
+
* --user --scope` (the manager of the user, no privilege), its CPU weight and its memory bound
|
|
91
|
+
* drawn from the part, no hard ceiling of CPU, the command of the pass whole at the end after
|
|
92
|
+
* `--`. <unite> names the scope, which a sampler reads. With <fils> (the precise threads of the
|
|
93
|
+
* part, the system delegating the cpuset controller to the account) the group allows those
|
|
94
|
+
* threads only (`AllowedCPUs`), under the slice of the frame, which the programs out of the frame
|
|
95
|
+
* are kept out of.
|
|
96
|
+
* @param {{ part: { coeurs: number, memoire: number }, cmd: string, args: string[],
|
|
97
|
+
* unite?: string | null, fils?: number[] | null }} o
|
|
98
|
+
* @returns {{ cmd: string, args: string[] }}
|
|
99
|
+
*/
|
|
100
|
+
export function commandeDuGroupe({ part, cmd, args, unite = null, fils = null }) {
|
|
101
|
+
return {
|
|
102
|
+
cmd: LANCEUR_DE_GROUPE,
|
|
103
|
+
args: [
|
|
104
|
+
'--user',
|
|
105
|
+
'--scope',
|
|
106
|
+
'--quiet',
|
|
107
|
+
...(unite ? [`--unit=${unite}`] : []),
|
|
108
|
+
...(fils ? [`--slice=${TRANCHE_DU_CADRE}`] : []),
|
|
109
|
+
'-p',
|
|
110
|
+
'CPUAccounting=yes',
|
|
111
|
+
'-p',
|
|
112
|
+
'MemoryAccounting=yes',
|
|
113
|
+
'-p',
|
|
114
|
+
`CPUWeight=${poidsDeLaPart(part)}`,
|
|
115
|
+
'-p',
|
|
116
|
+
`MemoryMax=${Math.floor(part.memoire)}`,
|
|
117
|
+
...(fils ? ['-p', `AllowedCPUs=${listeDeCoeurs(fils)}`] : []),
|
|
118
|
+
'--',
|
|
119
|
+
cmd,
|
|
120
|
+
...args,
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* What a pass under its part launches: its command, in its control group when the system gives
|
|
127
|
+
* one (<groupe>), as it is otherwise, GRILLHOUSE_TRAVAILLEURS set to the cores of its part. Its
|
|
128
|
+
* precise threads <fils> hold it to them: the allowed cores of its group (the cpuset controller
|
|
129
|
+
* delegated to the account), or, with <affinite>, the affinity of the launch (`taskset`, which its
|
|
130
|
+
* children inherit); without either of the two, nothing is attached.
|
|
131
|
+
* @param {{ part: { coeurs: number, memoire: number }, cmd: string, args: string[],
|
|
132
|
+
* env: Record<string, string | undefined>, groupe: boolean, unite?: string | null,
|
|
133
|
+
* fils?: number[] | null, affinite?: boolean }} o
|
|
134
|
+
* @returns {{ cmd: string, args: string[], env: Record<string, string | undefined> }}
|
|
135
|
+
*/
|
|
136
|
+
export function lancementSousPart({
|
|
137
|
+
part,
|
|
138
|
+
cmd,
|
|
139
|
+
args,
|
|
140
|
+
env,
|
|
141
|
+
groupe,
|
|
142
|
+
unite = null,
|
|
143
|
+
fils = null,
|
|
144
|
+
affinite = false,
|
|
145
|
+
}) {
|
|
146
|
+
const { [VARIABLE_TRAVAILLEURS]: _herite, ...sans } = env;
|
|
147
|
+
const e = { ...sans, [VARIABLE_TRAVAILLEURS]: String(part.coeurs) };
|
|
148
|
+
const attachee =
|
|
149
|
+
affinite && fils ? { cmd: OUTIL_D_AFFINITE, args: ['-c', listeDeCoeurs(fils), cmd, ...args] } : { cmd, args };
|
|
150
|
+
return groupe
|
|
151
|
+
? {
|
|
152
|
+
...commandeDuGroupe({ part, ...attachee, unite, fils: affinite ? null : fils }),
|
|
153
|
+
env: e,
|
|
154
|
+
}
|
|
155
|
+
: { ...attachee, env: e };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Whether the manager of the user starts a scope: the probe of the system, asked once.
|
|
159
|
+
let sondeLue = null;
|
|
160
|
+
const sondeDuSysteme = () => {
|
|
161
|
+
sondeLue ??=
|
|
162
|
+
spawnSync(
|
|
163
|
+
LANCEUR_DE_GROUPE,
|
|
164
|
+
// The probe starts a scope with the properties a part sets, so that a manager that refuses
|
|
165
|
+
// them is known before a pass runs in it.
|
|
166
|
+
['--user', '--scope', '--quiet', '-p', 'CPUWeight=100', '-p', 'MemoryMax=infinity', 'true'],
|
|
167
|
+
{ stdio: 'ignore', timeout: 20_000 }
|
|
168
|
+
).status === 0;
|
|
169
|
+
return sondeLue;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Why a pass plays without a control group of its own, null when the system gives one: the
|
|
174
|
+
* commands of an agent, in its envelope, play without (its session's place covers them); so does
|
|
175
|
+
* a system whose manager of the user does not answer (<sonde>, asked only out of the envelope).
|
|
176
|
+
* @param {{ env: Record<string, string | undefined>, sonde?: () => boolean }} o
|
|
177
|
+
* @returns {string | null}
|
|
178
|
+
*/
|
|
179
|
+
export function groupeIndisponible({ env, sonde = sondeDuSysteme }) {
|
|
180
|
+
if (paquetsDeLEnveloppe(env) !== null) {
|
|
181
|
+
return "dans l'enveloppe d'un agent";
|
|
182
|
+
}
|
|
183
|
+
return sonde() ? null : 'aucun gestionnaire de groupes de contrôle de l’utilisateur joignable';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The line-writer <dire> of a pass, which writes a line once: the same pass says « joue sans part
|
|
188
|
+
* tenue » one time, however often it asks.
|
|
189
|
+
* @param {(l: string) => void} dire
|
|
190
|
+
* @returns {(l: string) => void}
|
|
191
|
+
*/
|
|
192
|
+
export function direUneFois(dire) {
|
|
193
|
+
let dit = false;
|
|
194
|
+
return l => {
|
|
195
|
+
if (!dit) {
|
|
196
|
+
dit = true;
|
|
197
|
+
dire(l);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// How a pass ended, from what it returns: a number or a `{ status, signal, error }` of a child
|
|
203
|
+
// process; `interrompue` for a signal, `rouge` for a failure, `verte` otherwise.
|
|
204
|
+
const issueDe = r => {
|
|
205
|
+
if (typeof r === 'number') {
|
|
206
|
+
return r === 0 ? 'verte' : 'rouge';
|
|
207
|
+
}
|
|
208
|
+
if (r && typeof r === 'object') {
|
|
209
|
+
if (r.signal) {
|
|
210
|
+
return 'interrompue';
|
|
211
|
+
}
|
|
212
|
+
if (r.error !== undefined || (r.status !== undefined && r.status !== 0)) {
|
|
213
|
+
return 'rouge';
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return 'verte';
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// Plays <jouer> in the group <ouvert> (`ouvrir()` of a scope), reads what it consumed before the
|
|
220
|
+
// group goes, and, for a heavy pass, keeps the line in the register of the project, the pass red
|
|
221
|
+
// or interrupted included: the figures, its part, and what exceeds it.
|
|
222
|
+
function jouerMesuree(jouer, { ouvert, racine, ticket, sorte, part, horloge, coeurs, lourde }) {
|
|
223
|
+
const debut = horloge();
|
|
224
|
+
let issue = 'rouge';
|
|
225
|
+
try {
|
|
226
|
+
const r = jouer();
|
|
227
|
+
issue = issueDe(r);
|
|
228
|
+
return r;
|
|
229
|
+
} finally {
|
|
230
|
+
let lecture = null;
|
|
231
|
+
try {
|
|
232
|
+
lecture = ouvert.lire();
|
|
233
|
+
} catch {
|
|
234
|
+
// an unreadable scope keeps a line without values
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
if (lourde) {
|
|
238
|
+
const dureeMs = horloge() - debut;
|
|
239
|
+
garderLaConsommation(racine, {
|
|
240
|
+
sorte,
|
|
241
|
+
...(ticket ? { ticket } : {}),
|
|
242
|
+
dureeMs,
|
|
243
|
+
cpuNs: lecture?.cpuNs ?? null,
|
|
244
|
+
memoirePic: lecture?.memoirePic ?? null,
|
|
245
|
+
coeurs,
|
|
246
|
+
partCoeurs: part.coeurs,
|
|
247
|
+
partMemoire: part.memoire,
|
|
248
|
+
...(lecture
|
|
249
|
+
? (d => (d ? { depasse: d } : {}))(
|
|
250
|
+
depasseLaPart({ part, cpuNs: lecture.cpuNs, dureeMs, memoirePic: lecture.memoirePic })
|
|
251
|
+
)
|
|
252
|
+
: {}),
|
|
253
|
+
issue,
|
|
254
|
+
fin: new Date().toISOString(),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} finally {
|
|
258
|
+
ouvert.clore?.();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Plays <mesure> on its part of the machine, held to it by the system, and returns what it
|
|
265
|
+
* returns; <mesure> receives the environment of its children (the mark of the part, the workers
|
|
266
|
+
* of its tools) and `{ part, groupe, unite }`: the part held (null where none is), whether its
|
|
267
|
+
* command is to run in a control group of its own (`mode: 'commande'`, `lancementSousPart`), and
|
|
268
|
+
* the name of that group. The wait for the part says its reason and stops at the bound (75). A
|
|
269
|
+
* heavy pass (<lourde>) keeps what it consumes.
|
|
47
270
|
* @template T
|
|
48
|
-
* @param {(env: Record<string, string | undefined
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
271
|
+
* @param {(env: Record<string, string | undefined>,
|
|
272
|
+
* contexte: { part: { coeurs: number, memoire: number } | null, groupe: boolean,
|
|
273
|
+
* unite: string | null }) => T} mesure
|
|
274
|
+
* @param {{ lourde?: boolean, mode?: 'processus' | 'commande', entiere?: boolean,
|
|
275
|
+
* env?: Record<string, string | undefined>, racine?: string, ticket?: string, sorte?: string,
|
|
276
|
+
* dire?: (l: string) => void, borneMs?: number, rappelMs?: number, scope?: object,
|
|
277
|
+
* horloge?: () => number, coeurs?: number, sonde?: () => boolean } & Record<string, unknown>} options
|
|
278
|
+
* `mode` « processus » (by default): the pass is the process itself, which enters its group;
|
|
279
|
+
* `entiere`: the whole budget, the night's part; `mesure`: a measure of time, which plays on
|
|
280
|
+
* dedicated cores (scripts/coeurs-dedies.mjs), attached to them (`contexte.fils`,
|
|
281
|
+
* `contexte.affinite`) and judged on the load of those cores out of it
|
|
52
282
|
* @returns {T}
|
|
53
283
|
*/
|
|
54
284
|
export function avecLaPasse(
|
|
55
285
|
mesure,
|
|
56
|
-
{
|
|
286
|
+
{
|
|
287
|
+
lourde = true,
|
|
288
|
+
mode = 'processus',
|
|
289
|
+
env = process.env,
|
|
290
|
+
racine = process.cwd(),
|
|
291
|
+
ticket,
|
|
292
|
+
sorte,
|
|
293
|
+
dire = l => process.stdout.write(`${l}\n`),
|
|
294
|
+
scope,
|
|
295
|
+
horloge = Date.now,
|
|
296
|
+
coeurs = coeursDeLaMachine(),
|
|
297
|
+
sonde,
|
|
298
|
+
delegation,
|
|
299
|
+
affinite,
|
|
300
|
+
ecarter = ecarterLesProgrammes,
|
|
301
|
+
...options
|
|
302
|
+
} = {}
|
|
57
303
|
) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
304
|
+
const prise = prendreUnePart({ ...options, env, racine, ticket, sorte, dire });
|
|
305
|
+
try {
|
|
306
|
+
const direSansPart = direUneFois(dire);
|
|
307
|
+
// How the precise threads of the part are held: the allowed cores of a group, the affinity of
|
|
308
|
+
// the launch, or not at all; a measure of time says it once.
|
|
309
|
+
const attache = prise.fils
|
|
310
|
+
? attacheDesCoeurs({
|
|
311
|
+
env,
|
|
312
|
+
...(delegation ? { delegation } : {}),
|
|
313
|
+
...(affinite ? { affinite } : {}),
|
|
314
|
+
})
|
|
315
|
+
: null;
|
|
316
|
+
if (attache?.dit && prise.dediee) {
|
|
317
|
+
dire(attache.dit);
|
|
318
|
+
}
|
|
319
|
+
const contexteDe = (groupe, unite) => ({
|
|
320
|
+
part: prise.part,
|
|
321
|
+
groupe,
|
|
322
|
+
unite,
|
|
323
|
+
fils: attache && attache.voie !== 'aucune' ? prise.fils : null,
|
|
324
|
+
affinite: attache?.voie === 'affinite',
|
|
325
|
+
});
|
|
326
|
+
const sans = raison => {
|
|
327
|
+
direSansPart(`joue sans part tenue : ${raison}`);
|
|
328
|
+
return mesure(prise.env, contexteDe(false, null));
|
|
329
|
+
};
|
|
330
|
+
if (prise.part === null) {
|
|
331
|
+
return prise.raison === "dans l'enveloppe d'un agent"
|
|
332
|
+
? sans(prise.raison)
|
|
333
|
+
: mesure(prise.env, { part: null, groupe: false, unite: null });
|
|
334
|
+
}
|
|
335
|
+
const indisponible = groupeIndisponible({ env, ...(sonde ? { sonde } : {}) });
|
|
336
|
+
if (indisponible !== null) {
|
|
337
|
+
return sans(indisponible);
|
|
338
|
+
}
|
|
339
|
+
// The programs out of the frame kept away from the dedicated cores while a measure plays (the
|
|
340
|
+
// cpuset controller delegated), and the cores given back at its end; the pass plays as it is
|
|
341
|
+
// when the system refuses it, which it says.
|
|
342
|
+
let rendreLesCoeurs = () => {};
|
|
343
|
+
if (attache?.voie === 'groupe' && prise.dediee) {
|
|
344
|
+
const tous = prise.topologie.coeurs.flatMap(c => c.fils);
|
|
345
|
+
if (!ecarter({ dedies: prise.fils, fils: tous })) {
|
|
346
|
+
dire(
|
|
347
|
+
'les programmes hors du cadre ne sont pas tenus à l’écart des cœurs dédiés : le système refuse de régler leur groupe.'
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
rendreLesCoeurs = () => void ecarter({ dedies: [], fils: tous });
|
|
351
|
+
}
|
|
352
|
+
const identite = {
|
|
353
|
+
racine,
|
|
354
|
+
sorte: sorteDeLaPasse(sorte ?? (env.GRILLHOUSE_VERIFICATION_SORTE || 'verification')),
|
|
355
|
+
ticket: ticket ?? (env.GRILLHOUSE_VERIFICATION_TICKET || undefined),
|
|
356
|
+
coeurs,
|
|
357
|
+
part: { ...prise.part, dossier: dossierDesParts(env), id: prise.id },
|
|
358
|
+
mesurer: lourde,
|
|
359
|
+
};
|
|
360
|
+
const mesuree = { racine, ticket: identite.ticket, sorte: identite.sorte, part: prise.part, horloge, coeurs, lourde };
|
|
361
|
+
// A measure of time judges the load of its dedicated cores while it plays: the busy time of
|
|
362
|
+
// those cores out of its own (read from its group), a red on loaded cores « à repasser ».
|
|
363
|
+
const jugee = (jouer, ouvert) => () => {
|
|
364
|
+
if (!prise.dediee || !attache || attache.voie === 'aucune') {
|
|
365
|
+
return jouer();
|
|
366
|
+
}
|
|
367
|
+
const avant = lireLesTempsOccupes(tempsDuSysteme());
|
|
368
|
+
const r = jouer();
|
|
369
|
+
let cpuNs = null;
|
|
370
|
+
try {
|
|
371
|
+
cpuNs = ouvert.lire?.()?.cpuNs ?? null;
|
|
372
|
+
} catch {
|
|
373
|
+
// an unreadable group gives no measure's own time
|
|
374
|
+
}
|
|
375
|
+
const charge =
|
|
376
|
+
cpuNs === null
|
|
377
|
+
? null
|
|
378
|
+
: chargeHorsMesure({
|
|
379
|
+
avant,
|
|
380
|
+
apres: lireLesTempsOccupes(tempsDuSysteme()),
|
|
381
|
+
fils: prise.fils,
|
|
382
|
+
mesureNs: cpuNs,
|
|
383
|
+
});
|
|
384
|
+
if (charge === null) {
|
|
385
|
+
dire('la charge des cœurs dédiés pendant la mesure ne se lit pas : la mesure ne la juge pas.');
|
|
386
|
+
return r;
|
|
387
|
+
}
|
|
388
|
+
const code = typeof r === 'number' ? r : (r?.status ?? 0);
|
|
389
|
+
const juge = codeDeLaMesure({ code, charge });
|
|
390
|
+
if (juge === code) {
|
|
391
|
+
return r;
|
|
392
|
+
}
|
|
393
|
+
dire(
|
|
394
|
+
`les cœurs dédiés étaient chargés à ${Math.round(charge * 100)} % hors la mesure pendant son jeu : son échec est à repasser (code ${juge}).`
|
|
395
|
+
);
|
|
396
|
+
return typeof r === 'number' ? juge : { ...r, status: juge };
|
|
397
|
+
};
|
|
398
|
+
try {
|
|
399
|
+
if (mode === 'commande') {
|
|
400
|
+
const ouvert = (scope ?? scopeDeCommande(identite)).ouvrir();
|
|
401
|
+
const contexte = contexteDe(true, ouvert.unite ?? null);
|
|
402
|
+
return jouerMesuree(jugee(() => mesure(prise.env, contexte), ouvert), { ...mesuree, ouvert });
|
|
403
|
+
}
|
|
404
|
+
const ouvert = (
|
|
405
|
+
scope ??
|
|
406
|
+
scopeSystemd({ ...identite, ...(attache?.voie === 'groupe' ? { fils: prise.fils } : {}) })
|
|
407
|
+
).ouvrir();
|
|
408
|
+
if ('raison' in ouvert) {
|
|
409
|
+
return sans(ouvert.raison);
|
|
410
|
+
}
|
|
411
|
+
// The pass is the process itself: under the affinity of the launch, it takes its cores and
|
|
412
|
+
// gives its own back at its end, its children inheriting them in between.
|
|
413
|
+
const rendreLAffinite =
|
|
414
|
+
attache?.voie === 'affinite' ? attacherLeProcessus(prise.fils) : () => {};
|
|
415
|
+
try {
|
|
416
|
+
return jouerMesuree(
|
|
417
|
+
jugee(() => mesure(prise.env, contexteDe(false, null)), ouvert),
|
|
418
|
+
{ ...mesuree, ouvert }
|
|
419
|
+
);
|
|
420
|
+
} finally {
|
|
421
|
+
rendreLAffinite();
|
|
422
|
+
}
|
|
423
|
+
} finally {
|
|
424
|
+
rendreLesCoeurs();
|
|
425
|
+
}
|
|
426
|
+
} finally {
|
|
427
|
+
prise.rendre();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Sets the programs out of the frame away from the dedicated cores (`ecartDesProgrammes`): whether
|
|
432
|
+
// the system took it.
|
|
433
|
+
function ecarterLesProgrammes({ dedies, fils }) {
|
|
434
|
+
const l = ecartDesProgrammes({ dedies, fils });
|
|
435
|
+
return spawnSync(l.cmd, l.args, { stdio: 'ignore', timeout: 20_000 }).status === 0;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Pins this process, its threads and its future children to <fils> (`taskset`); a function that
|
|
439
|
+
// gives it its former cores back. Nothing changes when the system refuses.
|
|
440
|
+
function attacherLeProcessus(fils) {
|
|
441
|
+
let avant = null;
|
|
442
|
+
try {
|
|
443
|
+
avant = /^Cpus_allowed_list:\s*(\S+)/m.exec(readFileSync('/proc/self/status', 'utf8'))?.[1] ?? null;
|
|
444
|
+
} catch {
|
|
445
|
+
// unreadable: the former cores are not given back
|
|
446
|
+
}
|
|
447
|
+
const poser = liste =>
|
|
448
|
+
spawnSync(OUTIL_D_AFFINITE, ['-a', '-p', '-c', liste, String(process.pid)], {
|
|
449
|
+
stdio: 'ignore',
|
|
450
|
+
timeout: 20_000,
|
|
451
|
+
}).status === 0;
|
|
452
|
+
if (!poser(listeDeCoeurs(fils)) || avant === null) {
|
|
453
|
+
return () => {};
|
|
454
|
+
}
|
|
455
|
+
return () => void poser(avant);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Plays <passe> on its part of the machine, as a command a person runs (`npm test`): its exit
|
|
460
|
+
* code, or, a wait that stops (its bound, 75; a faulty key or reserve, 1), its reason said and
|
|
461
|
+
* its code. <passe> receives the environment of its children and its part (null where none is
|
|
462
|
+
* held, in the envelope of an agent).
|
|
463
|
+
* @param {(env: Record<string, string | undefined>,
|
|
464
|
+
* part: { coeurs: number, memoire: number } | null) => number} passe
|
|
465
|
+
* @param {{ env?: Record<string, string | undefined>, racine?: string, entiere?: boolean,
|
|
466
|
+
* mesure?: boolean, dire?: (l: string) => void }} [o] `entiere`: the whole budget as its part
|
|
467
|
+
* (the night); `mesure`: dedicated physical cores as its part (a measure of time)
|
|
468
|
+
* @returns {number}
|
|
469
|
+
*/
|
|
470
|
+
export function surUnePart(
|
|
471
|
+
passe,
|
|
472
|
+
{
|
|
473
|
+
env = process.env,
|
|
474
|
+
racine = process.cwd(),
|
|
475
|
+
entiere = false,
|
|
476
|
+
mesure = false,
|
|
477
|
+
dire = l => process.stderr.write(`${l}\n`),
|
|
478
|
+
} = {}
|
|
479
|
+
) {
|
|
480
|
+
try {
|
|
481
|
+
return avecLaPasse((e, { part }) => passe(e, part), {
|
|
482
|
+
lourde: false,
|
|
483
|
+
entiere,
|
|
484
|
+
mesure,
|
|
61
485
|
env,
|
|
62
486
|
racine,
|
|
63
|
-
|
|
64
|
-
sorte,
|
|
65
|
-
...(rang !== undefined ? { rang } : {}),
|
|
66
|
-
...(dire ? { dire } : {}),
|
|
67
|
-
...(borneMs !== undefined ? { borneMs } : {}),
|
|
68
|
-
...(rappelMs !== undefined ? { rappelMs } : {}),
|
|
487
|
+
dire,
|
|
488
|
+
sorte: 'Tests',
|
|
69
489
|
});
|
|
490
|
+
} catch (e) {
|
|
491
|
+
if (!(e instanceof AttenteDeLaMachine)) {
|
|
492
|
+
throw e;
|
|
493
|
+
}
|
|
494
|
+
dire(e.message);
|
|
495
|
+
return e.code;
|
|
70
496
|
}
|
|
71
|
-
return avecUnePlace(place => mesure(place.env), { ...options, env, ticket });
|
|
72
497
|
}
|