@roomi-fields/grillhouse 0.47.1 → 0.49.0
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 +116 -0
- package/agents/direct.md +9 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +24 -38
- package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -0
- package/cadre/templates/projet/.github/workflows/nuit.yml +14 -2
- package/cadre/templates/projet/CLAUDE.md +31 -10
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/turbo/paquets.json +3 -1
- package/cadre/templates/turbo/sans-paquets.json +3 -1
- package/charte.md +46 -13
- package/dist/temporal/circuit/appel.d.ts +4 -1
- package/dist/temporal/circuit/appel.js +15 -1
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +7 -1
- package/dist/temporal/circuit/client.js +54 -1
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +35 -60
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +2 -1
- package/dist/temporal/circuit/contrat.js +2 -1
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +9 -2
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +2 -13
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/deroules.d.ts +1 -1
- package/dist/temporal/deroules.js +2 -2
- package/dist/temporal/deroules.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +1 -4
- package/dist/temporal/file/activites.js +13 -14
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +34 -91
- package/dist/temporal/file/contrat.js +33 -5
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.d.ts +1 -9
- package/dist/temporal/file/deroule.js +57 -166
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +26 -1
- package/dist/temporal/installation.js +111 -2
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/activites.d.ts +5 -10
- package/dist/temporal/nuits/activites.js +9 -57
- package/dist/temporal/nuits/activites.js.map +1 -1
- package/dist/temporal/nuits/choix.d.ts +15 -0
- package/dist/temporal/nuits/choix.js +20 -0
- package/dist/temporal/nuits/choix.js.map +1 -1
- package/dist/temporal/nuits/contrat.d.ts +11 -16
- package/dist/temporal/nuits/deroule.js +38 -67
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/client.d.ts +9 -11
- package/dist/temporal/places/client.js +11 -19
- package/dist/temporal/places/client.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +25 -24
- package/dist/temporal/places/contrat.js +5 -7
- package/dist/temporal/places/contrat.js.map +1 -1
- package/dist/temporal/places/deroule.js +26 -36
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/tickets/activites.js +4 -2
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +2 -1
- package/docs/ARCHITECTURE.md +453 -133
- package/docs/CADRE.md +16 -13
- package/docs/INTERFACE.md +100 -25
- package/hooks/hooks.json +9 -0
- package/hooks/register.tsx +59 -5
- package/package.json +1 -1
- package/scripts/activites.mjs +319 -52
- package/scripts/aiguillage.mjs +5 -1
- package/scripts/attente-a-l-arret.mjs +2 -5
- package/scripts/attente-au-tour.mjs +2 -5
- package/scripts/bilan.mjs +125 -2
- package/scripts/branche-de-nuit.mjs +32 -44
- package/scripts/ci-de-main.mjs +215 -16
- package/scripts/circuit.mjs +275 -189
- package/scripts/circuits-cles.d.mts +3 -3
- package/scripts/circuits-cles.mjs +6 -5
- package/scripts/coeurs-dedies.mjs +4 -4
- package/scripts/commandes-composees.mjs +12 -5
- package/scripts/composition-des-langages.mjs +2 -0
- package/scripts/crochets.mjs +2 -2
- package/scripts/dette.d.ts +2 -1
- package/scripts/dette.mjs +49 -6
- package/scripts/direct.mjs +343 -0
- package/scripts/droits.mjs +19 -0
- package/scripts/effets.mjs +6 -5
- package/scripts/engendres.mjs +2 -1
- package/scripts/enveloppe/enveloppe.mjs +127 -18
- package/scripts/enveloppe/lancer.sh +14 -3
- package/scripts/enveloppe/paquets-du-plan.mjs +9 -0
- package/scripts/enveloppe/travail-de-la-copie.mjs +121 -21
- package/scripts/etapes.mjs +14 -4
- package/scripts/etat-du-depot.mjs +23 -0
- package/scripts/faits-du-circuit.mjs +24 -34
- package/scripts/fermeture-de-la-machine.d.mts +27 -0
- package/scripts/fermeture-de-la-machine.mjs +98 -0
- package/scripts/fichiers-nommes.mjs +27 -1
- package/scripts/file-des-tickets.d.mts +18 -1
- package/scripts/file-des-tickets.mjs +63 -15
- package/scripts/greffons.mjs +1 -1
- package/scripts/grillhouse-maj.mjs +13 -25
- package/scripts/groupe-cles.d.mts +6 -0
- package/scripts/groupe-cles.mjs +29 -1
- package/scripts/integration/file.mjs +162 -48
- package/scripts/integration/integrer.mjs +2 -0
- package/scripts/jointure.d.ts +22 -3
- package/scripts/journal-des-etats.d.mts +16 -0
- package/scripts/journal-des-etats.mjs +44 -2
- package/scripts/journal.mjs +3 -0
- package/scripts/langages/c/commandes.mjs +5 -5
- package/scripts/langages/c/composants.mjs +13 -5
- package/scripts/langages/c/index.mjs +2 -0
- package/scripts/langages/c/squelette.mjs +1 -1
- package/scripts/langages/cargo/commandes.mjs +5 -6
- package/scripts/langages/cargo/index.mjs +2 -0
- package/scripts/langages/python/commandes.mjs +5 -5
- package/scripts/langages/python/composants.mjs +10 -2
- package/scripts/langages/python/index.mjs +2 -0
- package/scripts/langages/typescript/composants.mjs +10 -3
- package/scripts/langages/typescript/construire.mjs +2 -0
- package/scripts/langages/typescript/exemples.mjs +33 -1
- package/scripts/langages/typescript/index.mjs +22 -0
- package/scripts/langages/typescript/migrations/0.49.0-tests-equipes.mjs +32 -0
- package/scripts/langages/typescript/module-absent.mjs +24 -0
- package/scripts/langages/typescript/tests-de-nuit.mjs +152 -32
- package/scripts/langages/typescript/tests-du-poste.mjs +65 -23
- package/scripts/langages/typescript/titres-de-tests.mjs +11 -7
- package/scripts/langages/typescript/turbo-des-paquets.mjs +40 -5
- package/scripts/langages/typescript/verifier.mjs +3 -5
- package/scripts/langages/typescript/verrou-des-dependances.mjs +161 -0
- package/scripts/langages/typescript/vitest-config/cibles.mjs +57 -6
- package/scripts/langages/typescript/vitest-config/lances.mjs +3 -1
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +11 -5
- package/scripts/langages/typescript/vitest.nuit.config.mjs +53 -5
- package/scripts/langages.mjs +25 -3
- package/scripts/machine.mjs +103 -0
- package/scripts/matieres-cles.mjs +17 -0
- package/scripts/matieres-lues.mjs +104 -0
- package/scripts/mesure/base-de-passe.mjs +2 -1
- package/scripts/migrations/0.48.0-ci-declenchee-par-la-file.mjs +32 -0
- package/scripts/migrations/0.48.0-poussee-retiree.mjs +31 -0
- package/scripts/migrations/0.49.0-reservation-de-trois-coeurs.mjs +30 -0
- package/scripts/migrations.mjs +6 -0
- package/scripts/nuit.sh +113 -46
- package/scripts/paquet.mjs +16 -5
- package/scripts/paquets.d.ts +4 -0
- package/scripts/paquets.mjs +57 -0
- package/scripts/passe-de-la-machine.mjs +13 -14
- package/scripts/places-de-la-machine.mjs +120 -44
- package/scripts/places-du-serveur.mjs +29 -8
- package/scripts/plafond-de-la-machine.d.mts +7 -13
- package/scripts/plafond-de-la-machine.mjs +19 -35
- package/scripts/poussee-retiree.mjs +18 -0
- package/scripts/prefixe-des-tickets.mjs +1 -1
- package/scripts/references-changees.mjs +159 -0
- package/scripts/registre.d.mts +2 -2
- package/scripts/regles-des-places.d.mts +20 -12
- package/scripts/regles-des-places.mjs +27 -30
- package/scripts/repli-de-la-nuit.mjs +112 -0
- package/scripts/reponses-du-circuit.d.mts +4 -2
- package/scripts/reponses-du-circuit.mjs +44 -9
- package/scripts/reprise.mjs +27 -8
- package/scripts/resultats.mjs +61 -9
- package/scripts/seances.mjs +258 -40
- package/scripts/services-du-noyau.mjs +3 -0
- package/scripts/sous-commandes.mjs +37 -7
- package/scripts/superviseur.mjs +241 -88
- package/scripts/tableau.mjs +327 -131
- package/scripts/taches-du-graphe.mjs +84 -4
- package/scripts/ticket.mjs +345 -0
- package/scripts/transitions.d.mts +52 -0
- package/scripts/transitions.mjs +194 -16
- package/scripts/un-commit-par-ticket.mjs +4 -3
- package/scripts/verdict-de-la-nuit.mjs +47 -20
- package/scripts/verrou-de-fichier.mjs +2 -2
- package/scripts/verrous/ecriture-hors-enveloppe.mjs +86 -0
- package/scripts/verrous/verrou.mjs +17 -1
- package/skills/developpeur/SKILL.md +1 -1
- package/skills/direct/SKILL.md +57 -0
- package/skills/explorateur/SKILL.md +10 -6
- package/skills/pitmaster/SKILL.md +37 -14
- package/skills/pitmaster/references/consigne-agent.md +7 -1
- package/skills/relecteur/SKILL.md +11 -1
- package/skills/testwriter/SKILL.md +10 -0
- package/scripts/poussee-cles.mjs +0 -46
- package/scripts/ticket.sh +0 -25
|
@@ -90,31 +90,33 @@ export function lancementDeLaPasse({ lourde, cmd, args, env }) {
|
|
|
90
90
|
* The command line that runs <cmd> in a control group of its own under the part <part>: `systemd-run
|
|
91
91
|
* --user --scope` (the manager of the user, no privilege), its CPU weight and its memory bound
|
|
92
92
|
* drawn from the part, no hard ceiling of CPU, the command of the pass whole at the end after
|
|
93
|
-
*
|
|
93
|
+
* `--`, given as written (`--expand-environment=no`: systemd-run would otherwise expand each
|
|
94
|
+
* `${…}` of its arguments, a shell script's included). <plafond> adds the hard CPU ceiling (`CPUQuota`, the cores of the part: the group of an
|
|
95
|
+
* agent's session); <memoire> false leaves the memory unbound. <unite> names the scope, which a
|
|
96
|
+
* sampler reads. With <fils> (the precise threads of the
|
|
94
97
|
* part, the system delegating the cpuset controller to the account) the group allows those
|
|
95
98
|
* threads only (`AllowedCPUs`), under the slice of the frame, which the programs out of the frame
|
|
96
99
|
* are kept out of.
|
|
97
100
|
* @param {{ part: { coeurs: number, memoire: number }, cmd: string, args: string[],
|
|
98
|
-
* unite?: string | null, fils?: number[] | null }} o
|
|
101
|
+
* unite?: string | null, fils?: number[] | null, plafond?: boolean, memoire?: boolean }} o
|
|
99
102
|
* @returns {{ cmd: string, args: string[] }}
|
|
100
103
|
*/
|
|
101
|
-
export function commandeDuGroupe({ part, cmd, args, unite = null, fils = null }) {
|
|
104
|
+
export function commandeDuGroupe({ part, cmd, args, unite = null, fils = null, plafond = false, memoire = true }) {
|
|
102
105
|
return {
|
|
103
106
|
cmd: LANCEUR_DE_GROUPE,
|
|
104
107
|
args: [
|
|
105
108
|
'--user',
|
|
106
109
|
'--scope',
|
|
107
110
|
'--quiet',
|
|
111
|
+
'--expand-environment=no',
|
|
108
112
|
...(unite ? [`--unit=${unite}`] : []),
|
|
109
113
|
...(fils ? [`--slice=${TRANCHE_DU_CADRE}`] : []),
|
|
110
114
|
'-p',
|
|
111
|
-
'CPUAccounting=yes',
|
|
112
|
-
'-p',
|
|
113
115
|
'MemoryAccounting=yes',
|
|
114
116
|
'-p',
|
|
115
117
|
`CPUWeight=${poidsDeLaPart(part)}`,
|
|
116
|
-
'-p',
|
|
117
|
-
`
|
|
118
|
+
...(memoire ? ['-p', `MemoryMax=${Math.floor(part.memoire)}`] : []),
|
|
119
|
+
...(plafond ? ['-p', `CPUQuota=${part.coeurs * 100}%`] : []),
|
|
118
120
|
...(fils ? ['-p', `AllowedCPUs=${listeDeCoeurs(fils)}`] : []),
|
|
119
121
|
'--',
|
|
120
122
|
cmd,
|
|
@@ -294,12 +296,12 @@ export const jugeLaChargeDuJeu = ({ dediee, voie, env = process.env }) =>
|
|
|
294
296
|
* @param {(env: Record<string, string | undefined>,
|
|
295
297
|
* contexte: { part: { coeurs: number, memoire: number } | null, groupe: boolean,
|
|
296
298
|
* unite: string | null }) => T} mesure
|
|
297
|
-
* @param {{ lourde?: boolean, mode?: 'processus' | 'commande',
|
|
299
|
+
* @param {{ lourde?: boolean, mode?: 'processus' | 'commande',
|
|
298
300
|
* env?: Record<string, string | undefined>, racine?: string, ticket?: string, sorte?: string,
|
|
299
301
|
* dire?: (l: string) => void, borneMs?: number, rappelMs?: number, scope?: object,
|
|
300
302
|
* horloge?: () => number, coeurs?: number, sonde?: () => boolean } & Record<string, unknown>} options
|
|
301
303
|
* `mode` « processus » (by default): the pass is the process itself, which enters its group;
|
|
302
|
-
* `
|
|
304
|
+
* `mesure`: a measure of time, which plays on
|
|
303
305
|
* dedicated cores (scripts/coeurs-dedies.mjs), attached to them (`contexte.fils`,
|
|
304
306
|
* `contexte.affinite`) and judged on the load of those cores out of it
|
|
305
307
|
* @returns {T}
|
|
@@ -486,9 +488,8 @@ function attacherLeProcessus(fils) {
|
|
|
486
488
|
* held, in the envelope of an agent).
|
|
487
489
|
* @param {(env: Record<string, string | undefined>,
|
|
488
490
|
* part: { coeurs: number, memoire: number } | null) => number} passe
|
|
489
|
-
* @param {{ env?: Record<string, string | undefined>, racine?: string,
|
|
490
|
-
* mesure?: boolean, dire?: (l: string) => void }} [o] `
|
|
491
|
-
* (the night); `mesure`: dedicated physical cores as its part (a measure of time)
|
|
491
|
+
* @param {{ env?: Record<string, string | undefined>, racine?: string,
|
|
492
|
+
* mesure?: boolean, dire?: (l: string) => void }} [o] `mesure`: dedicated physical cores as its part (a measure of time)
|
|
492
493
|
* @returns {number}
|
|
493
494
|
*/
|
|
494
495
|
export function surUnePart(
|
|
@@ -496,7 +497,6 @@ export function surUnePart(
|
|
|
496
497
|
{
|
|
497
498
|
env = process.env,
|
|
498
499
|
racine = process.cwd(),
|
|
499
|
-
entiere = false,
|
|
500
500
|
mesure = false,
|
|
501
501
|
dire = l => process.stderr.write(`${l}\n`),
|
|
502
502
|
} = {}
|
|
@@ -504,7 +504,6 @@ export function surUnePart(
|
|
|
504
504
|
try {
|
|
505
505
|
return avecLaPasse((e, { part }) => passe(e, part), {
|
|
506
506
|
lourde: false,
|
|
507
|
-
entiere,
|
|
508
507
|
mesure,
|
|
509
508
|
env,
|
|
510
509
|
racine,
|
|
@@ -94,16 +94,11 @@ import {
|
|
|
94
94
|
plafondDe,
|
|
95
95
|
reserveDe,
|
|
96
96
|
} from './plafond-de-la-machine.mjs';
|
|
97
|
-
import { duree, refusDePart
|
|
97
|
+
import { duree, refusDePart } from './regles-des-places.mjs';
|
|
98
98
|
import { attendreUnPeu, lacherVerrou, prendreVerrou } from './verrou-de-fichier.mjs';
|
|
99
99
|
|
|
100
|
-
// The spacing
|
|
101
|
-
export {
|
|
102
|
-
ESPACEMENT_MS,
|
|
103
|
-
espacementDe,
|
|
104
|
-
VARIABLE_ESPACEMENT,
|
|
105
|
-
VARIABLE_JETON,
|
|
106
|
-
} from './regles-des-places.mjs';
|
|
100
|
+
// The spacing is a rule (./regles-des-places.mjs), published here too.
|
|
101
|
+
export { ESPACEMENT_MS, espacementDe, VARIABLE_ESPACEMENT } from './regles-des-places.mjs';
|
|
107
102
|
export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
|
|
108
103
|
|
|
109
104
|
/**
|
|
@@ -225,23 +220,19 @@ export function prendreUnRang({ env = process.env } = {}) {
|
|
|
225
220
|
|
|
226
221
|
/**
|
|
227
222
|
* The request of a place for the process <pid>: its start, its ticket, the root of its project,
|
|
228
|
-
* the rank of its circuit
|
|
229
|
-
*
|
|
230
|
-
* machine.
|
|
231
|
-
* @param {{ env?: Record<string, string | undefined>, pid: number, depart?: string | null,
|
|
223
|
+
* and the rank of its circuit.
|
|
224
|
+
* @param {{ pid: number, depart?: string | null,
|
|
232
225
|
* ticket?: string | null, racine?: string, rang?: number | null }} o
|
|
233
226
|
* @returns {{ pid: number, depart: string | null, ticket: string | null, racine?: string | null,
|
|
234
|
-
* rang?: number
|
|
227
|
+
* rang?: number }}
|
|
235
228
|
*/
|
|
236
|
-
export function demandeDePlace({
|
|
237
|
-
const jeton = env[VARIABLE_JETON];
|
|
229
|
+
export function demandeDePlace({ pid, depart, ticket = null, racine, rang }) {
|
|
238
230
|
return {
|
|
239
231
|
pid,
|
|
240
232
|
depart: depart === undefined ? departDe(pid) : depart,
|
|
241
233
|
ticket,
|
|
242
234
|
...(racine === undefined ? {} : { racine: racineDuDepot(racine) }),
|
|
243
235
|
...(rang === undefined || rang === null ? {} : { rang }),
|
|
244
|
-
...(jeton ? { jeton } : {}),
|
|
245
236
|
};
|
|
246
237
|
}
|
|
247
238
|
|
|
@@ -276,11 +267,13 @@ export function prendreUnePlace({
|
|
|
276
267
|
return { id: null, rang: rang ?? null, env, rendre: () => {}, rattacher: () => {} };
|
|
277
268
|
}
|
|
278
269
|
const demande = {
|
|
279
|
-
...demandeDePlace({
|
|
270
|
+
...demandeDePlace({ pid, depart, ticket, racine, rang }),
|
|
280
271
|
borneMs,
|
|
281
272
|
rappelMs,
|
|
282
273
|
};
|
|
283
|
-
|
|
274
|
+
// No deadline of the process: the bridge holds the bound itself (`attendreLaPlace`), and under
|
|
275
|
+
// the supervisor's closure the wait lasts until the reopening.
|
|
276
|
+
const { code, lignes } = auServeur(e, ['prendre', JSON.stringify(demande)], 0);
|
|
284
277
|
for (const l of lignes) {
|
|
285
278
|
if (l.dire) {
|
|
286
279
|
// The wait, said and dated in the journal of states, its reason the message said.
|
|
@@ -465,7 +458,7 @@ export function budgetDeLaPasse(env = process.env) {
|
|
|
465
458
|
* @returns {{ coeurs: number, memoire: number }}
|
|
466
459
|
* @throws {AttenteDeLaMachine} naming the key (code 1) when its value is faulty, before any work
|
|
467
460
|
*/
|
|
468
|
-
export function partDeLaPasse({ racine, env = process.env }) {
|
|
461
|
+
export function partDeLaPasse({ racine, env = process.env, direct = false }) {
|
|
469
462
|
const { declaree, faute } = partDeclareeDe(packageDuDepot(racine));
|
|
470
463
|
if (faute) {
|
|
471
464
|
throw new AttenteDeLaMachine(`✗ ${faute}`, 1);
|
|
@@ -473,7 +466,7 @@ export function partDeLaPasse({ racine, env = process.env }) {
|
|
|
473
466
|
return partDe({
|
|
474
467
|
declaree,
|
|
475
468
|
budget: budgetDeLaPasse(env),
|
|
476
|
-
|
|
469
|
+
...(direct ? { direct } : {}),
|
|
477
470
|
pic: plusGrandPicDeJour(racineDuDepot(racine)),
|
|
478
471
|
});
|
|
479
472
|
}
|
|
@@ -523,12 +516,12 @@ function packageDuDepot(racine) {
|
|
|
523
516
|
* @returns {number}
|
|
524
517
|
* @throws {AttenteDeLaMachine} naming the key (code 1) when its value is faulty, before any work
|
|
525
518
|
*/
|
|
526
|
-
function coeursDeLaMesure({ racine, budget
|
|
519
|
+
function coeursDeLaMesure({ racine, budget }) {
|
|
527
520
|
const { declaree, faute } = mesureDeclareeDe(packageDuDepot(racine));
|
|
528
521
|
if (faute) {
|
|
529
522
|
throw new AttenteDeLaMachine(`✗ ${faute}`, 1);
|
|
530
523
|
}
|
|
531
|
-
return coeursDeLaMesureDe({ declaree, budget
|
|
524
|
+
return coeursDeLaMesureDe({ declaree, budget });
|
|
532
525
|
}
|
|
533
526
|
|
|
534
527
|
const RANGS = { 1: 'mesure du cadre', 2: "mesure d'un projet" };
|
|
@@ -537,11 +530,22 @@ const RANGS = { 1: 'mesure du cadre', 2: "mesure d'un projet" };
|
|
|
537
530
|
const ECHELLE_DES_RANGS = 1e14;
|
|
538
531
|
|
|
539
532
|
// Plays <f> holding the short lock of the admission of <dossier>, so that two passes never judge
|
|
540
|
-
// the same free budget at once.
|
|
533
|
+
// the same free budget at once. The directory is made again when it goes between its making and
|
|
534
|
+
// the lock: another pass that gives its part back removes it while it is empty (`rendreLaPart`).
|
|
535
|
+
// Once the lock lies in it, it stays.
|
|
541
536
|
function sousLAdmission(dossier, f) {
|
|
542
|
-
mkdirSync(dossier, { recursive: true });
|
|
543
537
|
const verrou = path.join(dossier, '.admission');
|
|
544
|
-
|
|
538
|
+
for (;;) {
|
|
539
|
+
mkdirSync(dossier, { recursive: true });
|
|
540
|
+
try {
|
|
541
|
+
prendreVerrou(verrou, { attendre: true });
|
|
542
|
+
break;
|
|
543
|
+
} catch (e) {
|
|
544
|
+
if (e?.code !== 'ENOENT') {
|
|
545
|
+
throw e;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
545
549
|
try {
|
|
546
550
|
return f();
|
|
547
551
|
} finally {
|
|
@@ -567,13 +571,16 @@ export function lecteurDeLaCharge(env = process.env, systeme = chargeDesCoeursDu
|
|
|
567
571
|
* writes on (`attendreDeLaPlace`), then the part: it is taken once it fits in what the parts held
|
|
568
572
|
* leave of the budget and the load and the memory of the machine admit it, the waits of a smaller
|
|
569
573
|
* rank passing first. Its state is one file of the parts (`poserLaPart`), « attend » then
|
|
570
|
-
* « tient ». The night
|
|
571
|
-
*
|
|
574
|
+
* « tient ». The night of a project is a pass like another, of the sort « Nuit »: it takes the part of
|
|
575
|
+
* its project. A <mesure> of time takes dedicated cores (`fils`, whole physical
|
|
572
576
|
* cores), waits for them and for their rest (<chargeDesCoeurs>: the load of the threads it gives,
|
|
573
|
-
* null without a reading, by default `lecteurDeLaCharge`; <topologie>, the topology of the system, for a trial).
|
|
577
|
+
* null without a reading, by default `lecteurDeLaCharge`; <topologie>, the topology of the system, for a trial).
|
|
578
|
+
* The reservation of the machine (<lireLaReservation>, the places of the server by default) is read at each
|
|
579
|
+
* turn of the wait, before the admission lock: under the supervisor's closure the pass waits without bound
|
|
580
|
+
* (« machine fermée par le superviseur »); a reading that fails stands for no reservation. Where no part is taken (the envelope of an agent, a part already
|
|
574
581
|
* held: GRILLHOUSE_PART_TENUE) the part returned holds nothing.
|
|
575
582
|
* @param {{ env?: Record<string, string | undefined>, racine?: string, ticket?: string | null,
|
|
576
|
-
* sorte?: string,
|
|
583
|
+
* sorte?: string, mesure?: boolean, direct?: boolean, borneMs?: number, rappelMs?: number,
|
|
577
584
|
* dire?: (l: string) => void, maintenant?: () => number, dormir?: (ms: number) => void,
|
|
578
585
|
* libre?: (d: string) => number, occupe?: (d: string) => string,
|
|
579
586
|
* occupeLaCopie?: (r: string) => string }} [o]
|
|
@@ -589,8 +596,8 @@ export function prendreUnePart({
|
|
|
589
596
|
racine = process.cwd(),
|
|
590
597
|
ticket,
|
|
591
598
|
sorte,
|
|
592
|
-
entiere = false,
|
|
593
599
|
mesure = false,
|
|
600
|
+
direct = false,
|
|
594
601
|
topologie,
|
|
595
602
|
chargeDesCoeurs = lecteurDeLaCharge(env),
|
|
596
603
|
borneMs = borneDe(env),
|
|
@@ -598,6 +605,7 @@ export function prendreUnePart({
|
|
|
598
605
|
dire = l => process.stdout.write(`${l}\n`),
|
|
599
606
|
maintenant = Date.now,
|
|
600
607
|
dormir = attendreUnPeu,
|
|
608
|
+
lireLaReservation = () => lirePlaces({ env }).reservation ?? null,
|
|
601
609
|
...disques
|
|
602
610
|
} = {}) {
|
|
603
611
|
const sans = raison => ({ id: null, part: null, fils: null, env, rendre: () => {}, raison });
|
|
@@ -622,7 +630,7 @@ export function prendreUnePart({
|
|
|
622
630
|
topo = topologie ?? lireLaTopologie({ nombreDeFils: machineDe(env).coeurs });
|
|
623
631
|
budgetFils = budgetEnFils({ topologie: topo, budget: budget.coeurs });
|
|
624
632
|
if (mesure) {
|
|
625
|
-
const demande = coeursDeLaMesure({ racine, budget
|
|
633
|
+
const demande = coeursDeLaMesure({ racine, budget });
|
|
626
634
|
let fils = filsDeLaMesure({ budget: budgetFils, topologie: topo, demande });
|
|
627
635
|
if (fils === null || !topo.lisible) {
|
|
628
636
|
// No whole core in the budget, or a topology that does not read: each thread is a core.
|
|
@@ -632,7 +640,7 @@ export function prendreUnePart({
|
|
|
632
640
|
}
|
|
633
641
|
part = { coeurs: fils, memoire: Math.floor((budget.memoire * fils) / budget.coeurs) };
|
|
634
642
|
} else {
|
|
635
|
-
part =
|
|
643
|
+
part = partDeLaPasse({ racine, env, direct });
|
|
636
644
|
}
|
|
637
645
|
} catch (e) {
|
|
638
646
|
throw e instanceof AttenteDeLaMachine ? e : new AttenteDeLaMachine(`✗ ${e.message}`, 1);
|
|
@@ -670,14 +678,31 @@ export function prendreUnePart({
|
|
|
670
678
|
return () => {};
|
|
671
679
|
},
|
|
672
680
|
});
|
|
673
|
-
|
|
681
|
+
let debut = maintenant();
|
|
674
682
|
let dit = null;
|
|
675
683
|
for (;;) {
|
|
684
|
+
// The reservation of the machine is read each turn, before the admission lock, bounded by
|
|
685
|
+
// the delay of a call to the server; a reading that fails stands for « no reservation ».
|
|
686
|
+
let reservation = null;
|
|
687
|
+
try {
|
|
688
|
+
reservation = lireLaReservation() ?? null;
|
|
689
|
+
} catch {
|
|
690
|
+
reservation = null;
|
|
691
|
+
}
|
|
692
|
+
const fermee = reservation?.auteur === 'superviseur';
|
|
676
693
|
const refus = sousLAdmission(dossier, () => {
|
|
677
694
|
const { prises, attentes } = lireLesParts(dossier);
|
|
678
695
|
let r = refusDePart(
|
|
679
696
|
{ prises, attentes },
|
|
680
|
-
{
|
|
697
|
+
{
|
|
698
|
+
id: moi.id,
|
|
699
|
+
rang: moi.rang,
|
|
700
|
+
part,
|
|
701
|
+
budget,
|
|
702
|
+
mesurer: () => machineDe(env),
|
|
703
|
+
dediee: mesure,
|
|
704
|
+
reservation,
|
|
705
|
+
}
|
|
681
706
|
);
|
|
682
707
|
let fils = null;
|
|
683
708
|
if (r === null) {
|
|
@@ -707,6 +732,10 @@ export function prendreUnePart({
|
|
|
707
732
|
break;
|
|
708
733
|
}
|
|
709
734
|
const t = maintenant();
|
|
735
|
+
if (fermee) {
|
|
736
|
+
// The supervisor's order lasts until its contrary: no bound, the wait counts from the reopening.
|
|
737
|
+
debut = t;
|
|
738
|
+
}
|
|
710
739
|
if (t - debut >= borneMs) {
|
|
711
740
|
throw new AttenteDeLaMachine(
|
|
712
741
|
`⏱ attente de la part bornée à ${duree(borneMs)} (GRILLHOUSE_ATTENTE_MACHINE_MS), ${RANGS[rangDeLaPasse]} : ${refus} ; à repasser (code ${A_REPASSER}).`,
|
|
@@ -715,7 +744,7 @@ export function prendreUnePart({
|
|
|
715
744
|
}
|
|
716
745
|
if (dit === null) {
|
|
717
746
|
dire(
|
|
718
|
-
`⏳ ${RANGS[rangDeLaPasse]}, la passe attend sa part (${part.coeurs} cœurs) : ${refus} ; ${duree(borneMs)} au plus.`
|
|
747
|
+
`⏳ ${RANGS[rangDeLaPasse]}, la passe attend sa part (${part.coeurs} cœurs) : ${refus}${fermee ? ' ; sans borne, jusqu’à la réouverture.' : ` ; ${duree(borneMs)} au plus.`}`
|
|
719
748
|
);
|
|
720
749
|
} else if (t - dit >= rappelMs) {
|
|
721
750
|
dire(`⏳ la passe attend sa part depuis ${duree(t - debut)} : ${refus}.`);
|
|
@@ -765,6 +794,19 @@ export function prendreUnePart({
|
|
|
765
794
|
GRILLHOUSE_VERIFICATION_TICKET: _ticket,
|
|
766
795
|
...enfant
|
|
767
796
|
} = env;
|
|
797
|
+
// The reservation of the part (cores, memory, who), written at its taking and its return, so
|
|
798
|
+
// that the parts held at an instant are read back from the journal alone.
|
|
799
|
+
const reservation = {
|
|
800
|
+
coeurs: part.coeurs,
|
|
801
|
+
memoireGo: Math.round((part.memoire / 2 ** 30) * 100) / 100,
|
|
802
|
+
qui: [ticket, sorte].filter(Boolean).join(' ') || 'passe',
|
|
803
|
+
};
|
|
804
|
+
const tracer = evenement =>
|
|
805
|
+
ecrireLaTrace(
|
|
806
|
+
racine,
|
|
807
|
+
traceDesPlaces({ evenement, ticket: ticket ?? null, place: moi.id, reservation })
|
|
808
|
+
);
|
|
809
|
+
tracer('prise');
|
|
768
810
|
return {
|
|
769
811
|
id: moi.id,
|
|
770
812
|
part,
|
|
@@ -777,7 +819,10 @@ export function prendreUnePart({
|
|
|
777
819
|
[VARIABLE_PART_TENUE]: moi.id,
|
|
778
820
|
[VARIABLE_TRAVAILLEURS]: String(part.coeurs),
|
|
779
821
|
},
|
|
780
|
-
rendre: () =>
|
|
822
|
+
rendre: () => {
|
|
823
|
+
rendreLaPart(dossier, moi.id);
|
|
824
|
+
tracer('rendue');
|
|
825
|
+
},
|
|
781
826
|
raison: null,
|
|
782
827
|
};
|
|
783
828
|
}
|
|
@@ -846,13 +891,39 @@ export function surUnePart(
|
|
|
846
891
|
* order of arrival `{ id, pid, ticket, rang, raison, depuis }`; none where no place is taken.
|
|
847
892
|
* @param {{ env?: Record<string, string | undefined> }} [o]
|
|
848
893
|
*/
|
|
849
|
-
export function lirePlaces({ env = process.env } = {}) {
|
|
894
|
+
export function lirePlaces({ env = process.env, ms = 30_000 } = {}) {
|
|
850
895
|
const e = surLeServeur(env);
|
|
851
896
|
return e
|
|
852
|
-
? auServeur(e, ['lire']).lignes[0]
|
|
897
|
+
? auServeur(e, ['lire'], ms).lignes[0]
|
|
853
898
|
: { plafond: plafondDe(env), prises: [], attentes: [] };
|
|
854
899
|
}
|
|
855
900
|
|
|
901
|
+
// The command <mode> (`fermer`, `rouvrir`) of the bridge to the server under <env>: its issue. No
|
|
902
|
+
// server where no place is taken (the CI, the envelope of an agent), which cannot close a machine.
|
|
903
|
+
function commandeDeLaFermeture(mode, env) {
|
|
904
|
+
const e = surLeServeur(env);
|
|
905
|
+
if (!e) {
|
|
906
|
+
throw new Error('aucun serveur Temporal ici : la machine ne se ferme que sur le poste');
|
|
907
|
+
}
|
|
908
|
+
return auServeur(e, [mode]).lignes[0];
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Closes the machine under <env> (the supervisor's reservation of the places, `cordon` of
|
|
913
|
+
* kubectl): its issue, `fermee` or `deja-fermee`.
|
|
914
|
+
* @param {{ env?: Record<string, string | undefined> }} [o]
|
|
915
|
+
* @returns {'fermee' | 'deja-fermee'}
|
|
916
|
+
*/
|
|
917
|
+
export const fermerLaMachine = ({ env = process.env } = {}) => commandeDeLaFermeture('fermer', env);
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Reopens the machine under <env>: its issue, `rouverte` or `deja-ouverte`.
|
|
921
|
+
* @param {{ env?: Record<string, string | undefined> }} [o]
|
|
922
|
+
* @returns {'rouverte' | 'deja-ouverte'}
|
|
923
|
+
*/
|
|
924
|
+
export const rouvrirLaMachine = ({ env = process.env } = {}) =>
|
|
925
|
+
commandeDeLaFermeture('rouvrir', env);
|
|
926
|
+
|
|
856
927
|
/**
|
|
857
928
|
* The machine a trial fixes under <env> (GRILLHOUSE_MESURE_D_ESSAI, JSON `{ coeurs, charge,
|
|
858
929
|
* memoireLibre, memoireTotale }`), or null without the variable.
|
|
@@ -891,7 +962,7 @@ function mesureDEssai(env) {
|
|
|
891
962
|
}
|
|
892
963
|
|
|
893
964
|
/**
|
|
894
|
-
* The places as the board shows them:
|
|
965
|
+
* The places as the board shows them: the places of circuits held (`prises`, `tenues`) and the ceiling, the load over one minute and the cores,
|
|
895
966
|
* the free memory and the total memory in whole GB, and the waits (ticket, since when) in the order of arrival: those
|
|
896
967
|
* of a place for a session or a pass, then the tickets that wait for a place of a circuit, not
|
|
897
968
|
* started (`circuits` of the server, which the queue of each project reserves). The
|
|
@@ -904,6 +975,7 @@ function mesureDEssai(env) {
|
|
|
904
975
|
* }} [o] `lues`, the places as the server holds them (`lirePlaces` by default); `tenues` of the
|
|
905
976
|
* result gives each place taken, its ticket and the root of its project (null without one)
|
|
906
977
|
* @returns {{ prises: number, tenues: { ticket: string | null, racine: string | null }[],
|
|
978
|
+
* fermeture: { auteur: 'superviseur', depuis: number, phase: string } | null,
|
|
907
979
|
* plafond: number, faute: string | null, charge: number, coeurs: number, memoireGo: number,
|
|
908
980
|
* memoireTotaleGo: number, attentes: { ticket: string, depuis: number, disque?: string | null }[] }}
|
|
909
981
|
* @throws {Error} naming GRILLHOUSE_MESURE_D_ESSAI when its value is faulty
|
|
@@ -913,16 +985,20 @@ export function etatDesPlaces({ env = process.env, mesurer = mesureDeLaMachine,
|
|
|
913
985
|
const {
|
|
914
986
|
plafond,
|
|
915
987
|
faute = null,
|
|
916
|
-
prises,
|
|
917
988
|
attentes,
|
|
918
989
|
circuits = [],
|
|
919
|
-
|
|
990
|
+
fermeture = null,
|
|
920
991
|
} = lues ?? lirePlaces({ env });
|
|
921
992
|
const m = fixee ?? mesurer();
|
|
993
|
+
// The places the board counts are the circuits': a circuit holds its place from its start to its
|
|
994
|
+
// end, its stops included, and the ceiling bounds them.
|
|
995
|
+
const tenues = circuits
|
|
996
|
+
.filter(c => c.accordee)
|
|
997
|
+
.map(c => ({ ticket: c.ticket ?? null, racine: c.racine ?? null }));
|
|
922
998
|
return {
|
|
923
|
-
prises:
|
|
924
|
-
tenues
|
|
925
|
-
|
|
999
|
+
prises: tenues.length,
|
|
1000
|
+
tenues,
|
|
1001
|
+
fermeture,
|
|
926
1002
|
plafond,
|
|
927
1003
|
faute,
|
|
928
1004
|
charge: Math.round(m.charge * 10) / 10,
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
// node places-du-serveur.mjs rendre <id>
|
|
9
9
|
// node places-du-serveur.mjs rattacher <id> <pid> <depart>
|
|
10
10
|
// node places-du-serveur.mjs lire
|
|
11
|
+
// node places-du-serveur.mjs fermer
|
|
12
|
+
// node places-du-serveur.mjs rouvrir
|
|
11
13
|
//
|
|
12
14
|
// - Each mode first starts the workflow of the machine when none runs (`demarrerLesPlaces`, on the
|
|
13
15
|
// task queue of the worker of the machine), its spacing GRILLHOUSE_ESPACEMENT_MS
|
|
@@ -19,7 +21,9 @@
|
|
|
19
21
|
// given, `{ id, rang }`. At the bound <borneMs>, the request is withdrawn, its line said, exit 75.
|
|
20
22
|
// - `rendre` gives the place <id> back (or withdraws its request), `rattacher` names the process
|
|
21
23
|
// that holds it; `lire` writes the places as the board reads them (`{ plafond, faute, prises,
|
|
22
|
-
// attentes }`)
|
|
24
|
+
// attentes }`); `fermer` and `rouvrir` close and reopen the machine (the supervisor's
|
|
25
|
+
// reservation), and write their issue (`fermee`, `deja-fermee`; `rouverte`,
|
|
26
|
+
// `deja-ouverte`).
|
|
23
27
|
// - Each call waits DELAI_MS for the server, and is played again ESSAIS times when it fails
|
|
24
28
|
// transiently. Still failing, its port open: the server is busy, said on the error stream, exit
|
|
25
29
|
// 75. A port refused (no server), another failure, or a client not built: said on the error
|
|
@@ -30,7 +34,10 @@ import net from 'node:net';
|
|
|
30
34
|
import path from 'node:path';
|
|
31
35
|
import { pathToFileURL } from 'node:url';
|
|
32
36
|
import { A_REPASSER } from './codes-de-sortie.mjs';
|
|
33
|
-
import { duree } from './regles-des-places.mjs';
|
|
37
|
+
import { duree, RAISON_FERMEE } from './regles-des-places.mjs';
|
|
38
|
+
|
|
39
|
+
// The start of the reason of a wait under the supervisor's closure.
|
|
40
|
+
const RAISON_FERMEE_DEBUT = RAISON_FERMEE.split(' : ')[0];
|
|
34
41
|
|
|
35
42
|
const DIST = path.join(import.meta.dirname, '..', 'dist', 'temporal');
|
|
36
43
|
// How long a call waits for the server to answer, each attempt.
|
|
@@ -110,12 +117,19 @@ const entreeDe = async env => {
|
|
|
110
117
|
return { espacementMs: espacementDe(env), veilleMs: 1_000 };
|
|
111
118
|
};
|
|
112
119
|
|
|
113
|
-
const MODES = { rang: 0, prendre: 1, rendre: 1, rattacher: 3, lire: 0 };
|
|
120
|
+
const MODES = { rang: 0, prendre: 1, rendre: 1, rattacher: 3, lire: 0, fermer: 0, rouvrir: 0 };
|
|
114
121
|
const ecrire = o => process.stdout.write(`${JSON.stringify(o)}\n`);
|
|
115
122
|
|
|
116
123
|
// The wait of the request <id> for its place, under the handle <h> of the workflow of the
|
|
117
|
-
// machine, its lines said: 0 once given, 75 at the bound <borneMs>, the request withdrawn.
|
|
118
|
-
|
|
124
|
+
// machine, its lines said: 0 once given, 75 at the bound <borneMs>, the request withdrawn. Under the
|
|
125
|
+
// supervisor's closure the bound does not apply: the wait lasts until the reopening, where the
|
|
126
|
+
// request is judged again (as `drain` waits, and a node cordoned keeps its pods). Exported for its
|
|
127
|
+
// test.
|
|
128
|
+
export async function attendreLaPlace(
|
|
129
|
+
c,
|
|
130
|
+
places,
|
|
131
|
+
{ h, id, rang, borneMs, rappelMs, sous, LA_DEMANDE }
|
|
132
|
+
) {
|
|
119
133
|
const debut = Date.now();
|
|
120
134
|
let dit = null;
|
|
121
135
|
for (;;) {
|
|
@@ -131,7 +145,8 @@ async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous
|
|
|
131
145
|
throw new Error(`la demande de place ${id} n'est plus : retirée, ou son processus a disparu`);
|
|
132
146
|
}
|
|
133
147
|
const t = Date.now();
|
|
134
|
-
|
|
148
|
+
const fermee = e.raison?.startsWith(RAISON_FERMEE_DEBUT) ?? false;
|
|
149
|
+
if (!fermee && t - debut >= borneMs) {
|
|
135
150
|
await sous(() => places.rendreLaPlace(c.client, id));
|
|
136
151
|
ecrire({
|
|
137
152
|
dire: `⏱ attente de place bornée à ${duree(borneMs)} (GRILLHOUSE_ATTENTE_MACHINE_MS) : ${e.raison} ; à repasser (code ${A_REPASSER}).`,
|
|
@@ -139,7 +154,9 @@ async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous
|
|
|
139
154
|
return A_REPASSER;
|
|
140
155
|
}
|
|
141
156
|
if (dit === null) {
|
|
142
|
-
ecrire({
|
|
157
|
+
ecrire({
|
|
158
|
+
dire: `⏳ attente d'une place : ${e.raison} ; ${fermee ? 'sans borne jusqu’à la réouverture' : `${duree(borneMs)} au plus`}.`,
|
|
159
|
+
});
|
|
143
160
|
dit = t;
|
|
144
161
|
} else if (t - dit >= rappelMs) {
|
|
145
162
|
ecrire({ dire: `⏳ attente d'une place depuis ${duree(t - debut)} : ${e.raison}.` });
|
|
@@ -153,7 +170,7 @@ async function attendreLaPlace(c, places, { h, id, rang, borneMs, rappelMs, sous
|
|
|
153
170
|
async function principal(mode, args) {
|
|
154
171
|
if (!Object.hasOwn(MODES, mode ?? '') || args.length !== MODES[mode]) {
|
|
155
172
|
process.stderr.write(
|
|
156
|
-
'usage : places-du-serveur.mjs rang | prendre <demande> | rendre <id> | rattacher <id> <pid> <depart> | lire\n'
|
|
173
|
+
'usage : places-du-serveur.mjs rang | prendre <demande> | rendre <id> | rattacher <id> <pid> <depart> | lire | fermer | rouvrir\n'
|
|
157
174
|
);
|
|
158
175
|
return 2;
|
|
159
176
|
}
|
|
@@ -197,6 +214,10 @@ async function principal(mode, args) {
|
|
|
197
214
|
);
|
|
198
215
|
} else if (mode === 'lire') {
|
|
199
216
|
ecrire(await sous(() => places.lireLesPlaces(c.client)));
|
|
217
|
+
} else if (mode === 'fermer') {
|
|
218
|
+
ecrire(await sous(() => places.fermerLaMachine(c.client)));
|
|
219
|
+
} else if (mode === 'rouvrir') {
|
|
220
|
+
ecrire(await sous(() => places.rouvrirLaMachine(c.client)));
|
|
200
221
|
} else {
|
|
201
222
|
const { borneMs, rappelMs, ...demande } = JSON.parse(args[0]);
|
|
202
223
|
const h = c.client.workflow.getHandle(ID_DES_PLACES);
|
|
@@ -14,8 +14,10 @@ export const PLAFOND_PAR_DEFAUT: 3;
|
|
|
14
14
|
export const RESERVE_COEURS_PAR_DEFAUT: 4;
|
|
15
15
|
/** The memory the reserve of the user keeps when nothing names another, in GB. */
|
|
16
16
|
export const RESERVE_MEMOIRE_GO_PAR_DEFAUT: 4;
|
|
17
|
-
/** The cores
|
|
18
|
-
export const
|
|
17
|
+
/** The cores the reservation of an ordinary pass holds when its project declares none. */
|
|
18
|
+
export const COEURS_PAR_DEFAUT: 3;
|
|
19
|
+
/** The cores the reservation of a direct pass holds, fixed. */
|
|
20
|
+
export const COEURS_DU_DIRECT: 2;
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* The ceiling of the places under <env>: GRILLHOUSE_PLACES of the environment, else of the file of
|
|
@@ -41,21 +43,13 @@ export function budgetDe(
|
|
|
41
43
|
reserve: PartDeLaPasse
|
|
42
44
|
): PartDeLaPasse;
|
|
43
45
|
|
|
44
|
-
/** The
|
|
45
|
-
*
|
|
46
|
-
* the budget (the floor alone without a measure). */
|
|
47
|
-
export function partParDefautDe(
|
|
48
|
-
budget: PartDeLaPasse,
|
|
49
|
-
places: number,
|
|
50
|
-
pic: number | undefined
|
|
51
|
-
): PartDeLaPasse;
|
|
52
|
-
|
|
53
|
-
/** The part of a pass: the declared one, its missing values from the default, within the budget. */
|
|
46
|
+
/** The reservation of a pass: the declared cores, else 3, within the budget (a direct pass: 2,
|
|
47
|
+
* fixed); its memory the declared one, else the default memory, within the budget. */
|
|
54
48
|
export function partDe(o: {
|
|
55
49
|
declaree: { coeurs?: number; memoire?: number } | null;
|
|
56
50
|
budget: PartDeLaPasse;
|
|
57
|
-
places: number;
|
|
58
51
|
pic: number | undefined;
|
|
52
|
+
direct?: boolean;
|
|
59
53
|
}): PartDeLaPasse;
|
|
60
54
|
|
|
61
55
|
/** The part a project declares in `grillhouse.part` of its package.json, or the fault naming it. */
|
|
@@ -46,8 +46,12 @@ export const PLAFOND_PAR_DEFAUT = 3;
|
|
|
46
46
|
export const RESERVE_COEURS_PAR_DEFAUT = 4;
|
|
47
47
|
/** The memory the reserve of the user keeps when nothing names another, in GB. */
|
|
48
48
|
export const RESERVE_MEMOIRE_GO_PAR_DEFAUT = 4;
|
|
49
|
-
/** The cores
|
|
50
|
-
export const
|
|
49
|
+
/** The cores the reservation of an ordinary pass holds when its project declares none. */
|
|
50
|
+
export const COEURS_PAR_DEFAUT = 3;
|
|
51
|
+
/** The cores the reservation of a direct pass holds, fixed. */
|
|
52
|
+
export const COEURS_DU_DIRECT = 2;
|
|
53
|
+
// The cores the reserve of the user leaves the passes at least; the floor of the memory.
|
|
54
|
+
const COEURS_LAISSES_AUX_PASSES = 4;
|
|
51
55
|
|
|
52
56
|
/**
|
|
53
57
|
* The ceiling of the places under <env>: GRILLHOUSE_PLACES of the environment, else of the file
|
|
@@ -121,7 +125,7 @@ export function reserveDe(env = process.env, o = {}) {
|
|
|
121
125
|
const coeursDeLaMachine = o.coeurs ?? cpus().length;
|
|
122
126
|
const parDefaut = Math.min(
|
|
123
127
|
RESERVE_COEURS_PAR_DEFAUT,
|
|
124
|
-
Math.max(0, coeursDeLaMachine -
|
|
128
|
+
Math.max(0, coeursDeLaMachine - COEURS_LAISSES_AUX_PASSES)
|
|
125
129
|
);
|
|
126
130
|
return {
|
|
127
131
|
coeurs: entierDuPoste(env, VARIABLE_RESERVE_COEURS, parDefaut, o.lire),
|
|
@@ -155,54 +159,34 @@ export function budgetDe({ coeurs, memoireTotale }, reserve) {
|
|
|
155
159
|
/** The margin over the largest measured peak of memory: a quarter. */
|
|
156
160
|
const MARGE_DE_LA_MEMOIRE = 1.25;
|
|
157
161
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
* in memory the largest measured peak <pic> plus a quarter (the hard ceiling of the group kills a
|
|
162
|
-
* pass above it, so a percentile would not do), within the budget and never under its floor, the
|
|
163
|
-
* proportion of the cores of a part before the division (a third of the budget): the peak raises
|
|
164
|
-
* the memory, it does not lower it; the floor alone when <pic> is absent.
|
|
165
|
-
* @param {{ coeurs: number, memoire: number }} budget
|
|
166
|
-
* @param {number} places
|
|
167
|
-
* @param {number | undefined} pic the largest peak of memory of the day passes, absent unmeasured
|
|
168
|
-
* @returns {{ coeurs: number, memoire: number }}
|
|
169
|
-
*/
|
|
170
|
-
export function partParDefautDe(budget, places, pic) {
|
|
171
|
-
const coeurs = Math.max(
|
|
172
|
-
1,
|
|
173
|
-
Math.min(budget.coeurs, Math.max(2, Math.floor(budget.coeurs / places)))
|
|
174
|
-
);
|
|
175
|
-
return { coeurs, memoire: memoireParDefautDe(budget, pic) };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// The default memory, independent of the division by the places: its floor, the proportion of the
|
|
179
|
-
// cores a part had before the division (MIN_COEURS_DE_LA_PART, or a third of the budget rounded up
|
|
180
|
-
// when that is more), raised to the peak plus a quarter when the register measured more. A
|
|
162
|
+
// The default memory: its floor, the proportion of the budget a part of 4 cores held (or a third
|
|
163
|
+
// of the budget rounded up when that is more), raised to the largest measured peak <pic> plus a
|
|
164
|
+
// quarter (the hard ceiling of the group kills a pass above it) when the register measured more. A
|
|
181
165
|
// register that holds light passes alone (the guards, a pass of 50 ms: a peak of 16 Mo) would
|
|
182
166
|
// else give the next pass a ceiling its kernel kills it under, as the Vertical Pod Autoscaler
|
|
183
167
|
// bounds its recommendation by a minimum (`minAllowed`).
|
|
184
168
|
function memoireParDefautDe(budget, pic) {
|
|
185
169
|
const coeursDAvant = Math.max(
|
|
186
170
|
1,
|
|
187
|
-
Math.min(budget.coeurs, Math.max(
|
|
171
|
+
Math.min(budget.coeurs, Math.max(COEURS_LAISSES_AUX_PASSES, Math.ceil(budget.coeurs / 3)))
|
|
188
172
|
);
|
|
189
173
|
const plancher = Math.floor((budget.memoire * coeursDAvant) / budget.coeurs);
|
|
190
174
|
return Math.min(budget.memoire, Math.max(plancher, Math.floor((pic ?? 0) * MARGE_DE_LA_MEMOIRE)));
|
|
191
175
|
}
|
|
192
176
|
|
|
193
177
|
/**
|
|
194
|
-
* The
|
|
195
|
-
*
|
|
178
|
+
* The reservation of a pass: the cores its project declares (`partDeclareeDe`), else 3, within the
|
|
179
|
+
* budget and one core at least; a direct pass reserves 2 cores, fixed. Its memory is the declared
|
|
180
|
+
* one, else the default memory, within the budget.
|
|
196
181
|
* @param {{ declaree: { coeurs?: number, memoire?: number } | null,
|
|
197
|
-
* budget: { coeurs: number, memoire: number },
|
|
182
|
+
* budget: { coeurs: number, memoire: number }, pic: number | undefined, direct?: boolean }} o
|
|
198
183
|
* @returns {{ coeurs: number, memoire: number }}
|
|
199
184
|
*/
|
|
200
|
-
export function partDe({ declaree, budget,
|
|
201
|
-
const
|
|
202
|
-
const coeurs = Math.max(1, Math.min(budget.coeurs, declaree?.coeurs ?? defaut.coeurs));
|
|
185
|
+
export function partDe({ declaree, budget, pic, direct = false }) {
|
|
186
|
+
const voulus = direct ? COEURS_DU_DIRECT : (declaree?.coeurs ?? COEURS_PAR_DEFAUT);
|
|
203
187
|
return {
|
|
204
|
-
coeurs,
|
|
205
|
-
memoire: Math.min(budget.memoire, declaree?.memoire ??
|
|
188
|
+
coeurs: Math.max(1, Math.min(budget.coeurs, voulus)),
|
|
189
|
+
memoire: Math.min(budget.memoire, declaree?.memoire ?? memoireParDefautDe(budget, pic)),
|
|
206
190
|
};
|
|
207
191
|
}
|
|
208
192
|
|