@roomi-fields/grillhouse 0.54.1 → 0.55.2
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 +73 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +4 -2
- package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -42
- package/cadre/templates/projet/CONTRIBUTING.md +0 -5
- package/cadre/templates/projet/README.md +0 -126
- package/cadre/templates/projet/_npmignore +1 -6
- package/cadre/templates/projet/package.json +5 -32
- package/cadre/templates/projet/tsconfig.json +4 -4
- package/cadre/templates/projet/vitest.config.cjs +3 -2
- package/charte/tests.md +14 -0
- package/dist/machine/part-par-sorte.d.ts +9 -9
- package/dist/machine/part-par-sorte.js +20 -24
- package/dist/machine/part-par-sorte.js.map +1 -1
- package/dist/machine/table-des-consommations.d.ts +65 -0
- package/dist/machine/table-des-consommations.js +94 -0
- package/dist/machine/table-des-consommations.js.map +1 -0
- package/dist/temporal/circuit/activites.d.ts +2 -0
- package/dist/temporal/circuit/activites.js +87 -3
- package/dist/temporal/circuit/activites.js.map +1 -1
- package/dist/temporal/circuit/client.js +9 -4
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +32 -4
- package/dist/temporal/circuit/deroule.js +54 -4
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/circuit/versions.d.ts +12 -0
- package/dist/temporal/circuit/versions.js +22 -0
- package/dist/temporal/circuit/versions.js.map +1 -0
- package/dist/temporal/consommation/activites.d.ts +2 -0
- package/dist/temporal/consommation/activites.js +9 -0
- package/dist/temporal/consommation/activites.js.map +1 -0
- package/dist/temporal/consommation/actualisation.d.ts +2 -0
- package/dist/temporal/consommation/actualisation.js +71 -0
- package/dist/temporal/consommation/actualisation.js.map +1 -0
- package/dist/temporal/consommation/client.d.ts +12 -0
- package/dist/temporal/consommation/client.js +28 -0
- package/dist/temporal/consommation/client.js.map +1 -0
- package/dist/temporal/consommation/commande.d.ts +5 -0
- package/dist/temporal/consommation/commande.js +32 -0
- package/dist/temporal/consommation/commande.js.map +1 -0
- package/dist/temporal/consommation/contrat.d.ts +15 -0
- package/dist/temporal/consommation/contrat.js +13 -0
- package/dist/temporal/consommation/contrat.js.map +1 -0
- package/dist/temporal/consommation/deroule.d.ts +2 -0
- package/dist/temporal/consommation/deroule.js +14 -0
- package/dist/temporal/consommation/deroule.js.map +1 -0
- package/dist/temporal/deroules.d.ts +2 -1
- package/dist/temporal/deroules.js +3 -2
- package/dist/temporal/deroules.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +2 -0
- package/dist/temporal/file/deroule.js +14 -4
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +6 -0
- package/dist/temporal/installation.js +15 -0
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/activites.d.ts +2 -1
- package/dist/temporal/nuits/activites.js +127 -3
- package/dist/temporal/nuits/activites.js.map +1 -1
- package/dist/temporal/nuits/client.d.ts +19 -5
- package/dist/temporal/nuits/client.js +33 -23
- package/dist/temporal/nuits/client.js.map +1 -1
- package/dist/temporal/nuits/commande.js +16 -11
- package/dist/temporal/nuits/commande.js.map +1 -1
- package/dist/temporal/nuits/contrat.d.ts +29 -0
- package/dist/temporal/nuits/contrat.js +10 -0
- package/dist/temporal/nuits/contrat.js.map +1 -1
- package/dist/temporal/nuits/deroule.d.ts +5 -0
- package/dist/temporal/nuits/deroule.js +18 -1
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/nuits/pc2.d.ts +72 -0
- package/dist/temporal/nuits/pc2.js +206 -0
- package/dist/temporal/nuits/pc2.js.map +1 -0
- package/dist/temporal/places/activites.d.ts +23 -1
- package/dist/temporal/places/activites.js +38 -2
- package/dist/temporal/places/activites.js.map +1 -1
- package/dist/temporal/places/client.d.ts +18 -2
- package/dist/temporal/places/client.js +28 -3
- package/dist/temporal/places/client.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +79 -14
- package/dist/temporal/places/contrat.js +7 -0
- package/dist/temporal/places/contrat.js.map +1 -1
- package/dist/temporal/places/deroule.js +159 -23
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/places/reservation.d.ts +54 -0
- package/dist/temporal/places/reservation.js +69 -0
- package/dist/temporal/places/reservation.js.map +1 -0
- package/dist/temporal/planification.d.ts +6 -0
- package/dist/temporal/planification.js +26 -0
- package/dist/temporal/planification.js.map +1 -0
- package/dist/temporal/tickets/activites.d.ts +0 -2
- package/dist/temporal/tickets/activites.js +2 -52
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +7 -26
- package/dist/temporal/tickets/deroule.js +35 -23
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/dist/temporal/travailleur.js +2 -0
- package/dist/temporal/travailleur.js.map +1 -1
- package/docs/ARCHITECTURE.md +2 -2
- package/docs/CADRE.md +1 -1
- package/docs/INTERFACE.md +16 -11
- package/docs/architecture/circuit.md +62 -58
- package/docs/architecture/entree.md +87 -63
- package/docs/architecture/greffon.md +24 -21
- package/docs/architecture/installation.md +35 -30
- package/docs/architecture/machine.md +48 -40
- package/docs/architecture/tests.md +37 -33
- package/docs/lexique.md +4 -3
- package/package.json +1 -1
- package/scripts/activites.mjs +351 -180
- package/scripts/aiguillage.mjs +1 -0
- package/scripts/attente-de-la-machine.mjs +3 -22
- package/scripts/avancement.mjs +21 -30
- package/scripts/bilan.mjs +22 -2
- package/scripts/branche-de-nuit.mjs +1 -1
- package/scripts/circuit.mjs +75 -39
- package/scripts/codes-de-sortie.mjs +0 -6
- package/scripts/coeurs-dedies.mjs +19 -2
- package/scripts/consommation-des-passes.mjs +67 -35
- package/scripts/consommation.mjs +152 -24
- package/scripts/copies-finies.mjs +15 -35
- package/scripts/dernier-vert.mjs +4 -5
- package/scripts/dette.mjs +5 -3
- package/scripts/droits.mjs +2 -2
- package/scripts/echantillonneur-de-la-passe.mjs +7 -31
- package/scripts/engendres.mjs +5 -61
- package/scripts/enveloppe/enveloppe.mjs +30 -34
- package/scripts/enveloppe/travail-de-la-copie.mjs +5 -0
- package/scripts/etapes.mjs +21 -7
- package/scripts/etat-du-depot.mjs +61 -0
- package/scripts/faits-du-circuit.mjs +7 -4
- package/scripts/fermeture-de-la-machine.d.mts +6 -4
- package/scripts/fermeture-de-la-machine.mjs +12 -16
- package/scripts/fichier-du-poste.d.mts +9 -0
- package/scripts/file-des-tickets.d.mts +0 -18
- package/scripts/file-des-tickets.mjs +0 -42
- package/scripts/fusion-du-changelog.mjs +1 -1
- package/scripts/grillhouse-maj.mjs +1 -1
- package/scripts/index-des-rouges.d.mts +40 -0
- package/scripts/index-des-rouges.mjs +104 -0
- package/scripts/integration/file.mjs +13 -63
- package/scripts/integration/integrer.mjs +157 -424
- package/scripts/integration/jugement.mjs +109 -0
- package/scripts/integration/rejeu.mjs +94 -71
- package/scripts/jointure.d.ts +34 -27
- package/scripts/journal-des-etats.d.mts +1 -1
- package/scripts/langages/c/commandes.mjs +27 -12
- package/scripts/langages/cargo/commandes.mjs +148 -94
- package/scripts/langages/cargo/index.mjs +2 -1
- package/scripts/langages/cargo/lectures-des-tests.mjs +132 -0
- package/scripts/langages/cargo/migrations/lectures-des-tests.mjs +31 -0
- package/scripts/langages/python/commandes.mjs +31 -15
- package/scripts/langages/python/index.mjs +2 -1
- package/scripts/langages/python/lectures-des-tests.mjs +148 -0
- package/scripts/langages/python/migrations/lectures-des-tests.mjs +31 -0
- package/scripts/langages/typescript/consommateurs-arbitres.mjs +2 -2
- package/scripts/langages/typescript/index.mjs +4 -0
- package/scripts/langages/typescript/lectures-des-tests.mjs +95 -0
- package/scripts/langages/typescript/migrations/lectures-des-tests.mjs +31 -0
- package/scripts/langages/typescript/tests-de-nuit.mjs +9 -15
- package/scripts/langages/typescript/tests.mjs +11 -37
- package/scripts/langages/typescript/titres-de-tests.mjs +5 -4
- package/scripts/langages/typescript/verifier.mjs +74 -44
- package/scripts/langages/typescript/vitest-config/base.mjs +3 -3
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -25
- package/scripts/lectures-communes.mjs +234 -0
- package/scripts/machine.mjs +11 -18
- package/scripts/mesure/base-de-passe.mjs +1 -2
- package/scripts/mesure-de-la-machine.d.mts +43 -3
- package/scripts/mesure-de-la-machine.mjs +209 -11
- package/scripts/migrations/0.33.0-ci-du-cadre.mjs +3 -3
- package/scripts/migrations/nuit-yml-retire.mjs +25 -0
- package/scripts/migrations/part-retiree.mjs +31 -0
- package/scripts/migrations/table-des-consommations.mjs +36 -0
- package/scripts/migrations.mjs +6 -0
- package/scripts/montee.mjs +9 -0
- package/scripts/nuit-de-pc2.mjs +628 -0
- package/scripts/nuit.sh +8 -131
- package/scripts/paquets.mjs +1 -1
- package/scripts/passe-de-la-machine.mjs +365 -105
- package/scripts/place-du-circuit.d.mts +15 -0
- package/scripts/place-du-circuit.mjs +32 -0
- package/scripts/places-de-la-machine.mjs +148 -627
- package/scripts/places-du-serveur.mjs +43 -16
- package/scripts/plafond-de-la-machine.d.mts +8 -13
- package/scripts/plafond-de-la-machine.mjs +37 -69
- package/scripts/registre-des-entrees.mjs +57 -0
- package/scripts/regles-des-places.d.mts +84 -50
- package/scripts/regles-des-places.mjs +200 -156
- package/scripts/retirer-copie.sh +2 -2
- package/scripts/seances.mjs +181 -63
- package/scripts/secours.mjs +95 -0
- package/scripts/services-du-noyau.mjs +11 -19
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/sous-modules.sh +1 -1
- package/scripts/superviseur.mjs +16 -7
- package/scripts/table-des-consommations.d.mts +9 -0
- package/scripts/table-des-consommations.mjs +35 -0
- package/scripts/tableau.mjs +33 -19
- package/scripts/taches-du-graphe.mjs +124 -2
- package/scripts/transitions.d.mts +27 -5
- package/scripts/transitions.mjs +125 -104
- package/scripts/verdict-de-la-nuit.d.mts +13 -0
- package/scripts/verdict-de-la-nuit.mjs +34 -7
- package/scripts/verrou-de-fichier.mjs +1 -2
- package/scripts/workflows-du-cadre.mjs +2 -2
- package/skills/developpeur/SKILL.md +8 -2
- package/skills/direct/SKILL.md +5 -0
- package/skills/explorateur/SKILL.md +10 -1
- package/skills/grill/SKILL.md +2 -4
- package/skills/pitmaster/SKILL.md +7 -5
- package/skills/pitmaster/references/consigne-agent.md +1 -1
- package/skills/relecteur/SKILL.md +4 -1
- package/skills/testwriter/SKILL.md +15 -2
- package/cadre/templates/projet/.env.example +0 -57
- package/cadre/templates/projet/.github/workflows/nuit.yml +0 -139
- package/cadre/templates/projet/deployment/README.md +0 -98
- package/cadre/templates/projet/deployment/docs/01-INSTALL.md +0 -145
- package/cadre/templates/projet/deployment/docs/02-CONFIGURATION.md +0 -117
- package/cadre/templates/projet/deployment/docs/03-API.md +0 -264
- package/cadre/templates/projet/deployment/docs/04-TROUBLESHOOTING.md +0 -262
- package/cadre/templates/projet/deployment/scripts/install.ps1 +0 -100
- package/cadre/templates/projet/deployment/scripts/start.ps1 +0 -61
- package/cadre/templates/projet/deployment/scripts/stop.ps1 +0 -37
- package/cadre/templates/projet/deployment/scripts/test.ps1 +0 -118
- package/cadre/templates/projet/ecosystem.config.cjs +0 -73
- package/cadre/templates/projet/src/config.ts +0 -68
- package/cadre/templates/projet/src/errors.ts +0 -102
- package/cadre/templates/projet/src/index.ts +0 -46
- package/cadre/templates/projet/src/services/.gitkeep +0 -8
- package/cadre/templates/projet/src/types/index.ts +0 -24
- package/cadre/templates/projet/src/utils/logger.ts +0 -106
- package/cadre/templates/projet/tests/unit/config.spec.ts +0 -68
- package/cadre/templates/projet/tests/unit/errors.spec.ts +0 -132
- package/cadre/templates/projet/tests/unit/types.spec.ts +0 -73
- package/cadre/templates/projet/tsconfig.build.json +0 -14
- package/scripts/flux-de-la-nuit.mjs +0 -39
- package/scripts/garde-de-la-memoire.mjs +0 -231
- package/scripts/repli-de-la-nuit.mjs +0 -184
|
@@ -1,90 +1,54 @@
|
|
|
1
|
-
// The places and the
|
|
2
|
-
//
|
|
3
|
-
// (§3.1, §5.1, §5.2, §5.4).
|
|
1
|
+
// The places of the machine and the reservations of the passes, taken by a synchronous caller: a
|
|
2
|
+
// place is held by a circuit or a pass, a reservation is what the arbiter grants it. Architecture:
|
|
3
|
+
// docs/architecture/machine.md (§3.1, §5.1, §5.2, §5.4).
|
|
4
4
|
//
|
|
5
|
-
// - The
|
|
6
|
-
// (src/temporal/places/deroule.ts)
|
|
7
|
-
// and frees the
|
|
8
|
-
// ./places-du-serveur.mjs, in a process of
|
|
9
|
-
//
|
|
5
|
+
// - The arbiter is the workflow of the machine on the Temporal server
|
|
6
|
+
// (src/temporal/places/deroule.ts): it grants each request, in its order of arrival, by the rule
|
|
7
|
+
// of ./regles-des-places.mjs (`refusDeLaReservation`), and frees the reservation of a process
|
|
8
|
+
// gone; this module reads and takes the reservations by ./places-du-serveur.mjs, in a process of
|
|
9
|
+
// its own: the bridge `prendre` / `laDemande` / `rendre` of a process out of a circuit. The
|
|
10
|
+
// session of an agent a circuit launches takes none: the workflow of its circuit reserves its
|
|
11
|
+
// step (src/temporal/circuit/deroule.ts) and the environment of the session carries the
|
|
12
|
+
// reservation (VARIABLE_RESERVATION_D_ETAPE).
|
|
13
|
+
// - A pass asks the arbiter its reservation like a step (./passe-de-la-machine.mjs `avecLaPasse`):
|
|
14
|
+
// the cores and the memory the table of the consumptions gives its phase (`reservationDeLaPasse`),
|
|
15
|
+
// with its project, its ticket and its sort, which the board reads in the view of the arbiter
|
|
16
|
+
// (`lirePlaces`), the only state of the machine.
|
|
10
17
|
// - The server is required on the workstation: one that does not answer stops the taking, named.
|
|
11
|
-
// In the CI (CI set)
|
|
12
|
-
//
|
|
13
|
-
// - A
|
|
14
|
-
//
|
|
15
|
-
//
|
|
18
|
+
// In the CI (CI set) nothing is asked. A trial machine (GRILLHOUSE_MESURE_D_ESSAI) asks the
|
|
19
|
+
// server GRILLHOUSE_PLACES_D_ESSAI names, and none without it.
|
|
20
|
+
// - A reservation held carries its mark to its children (GRILLHOUSE_PLACE_TENUE). In the envelope
|
|
21
|
+
// of an agent (GRILLHOUSE_ENVELOPPE set, ./enveloppe/paquets-du-plan.mjs) nothing is asked: the
|
|
22
|
+
// envelope passes on the mark of the session's reservation.
|
|
16
23
|
// - The ceiling of the places is `plafondDe` of ./plafond-de-la-machine.mjs (3 without a
|
|
17
|
-
// setting), read again at each judgement
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// request withdrawn. It keeps the rank of its arrival (`prendreUnRang`), kept from one session
|
|
22
|
-
// to the next.
|
|
24
|
+
// setting), read again at each judgement.
|
|
25
|
+
// - A wait says its reason (place, rank, load or memory) when it begins and every 30 s, and is
|
|
26
|
+
// bounded by GRILLHOUSE_ATTENTE_MACHINE_MS: at the bound, « à repasser » (75), the request
|
|
27
|
+
// withdrawn. It keeps the rank of its arrival (`prendreUnRang`), the order of arrival alone.
|
|
23
28
|
// - The workers of the tests of a session are `travailleursDe`: max(1, cores ÷ places), passed
|
|
24
29
|
// to the tool of each language (GRILLHOUSE_TRAVAILLEURS).
|
|
25
|
-
// - A part is the share of the budget (./plafond-de-la-machine.mjs) that every pass takes: the
|
|
26
|
-
// heavy pass of a circuit, `npm run verifier`, a targeted `npm test`, the CI on a machine of
|
|
27
|
-
// ours, the night. A pass starts when its part fits in what the parts held leave of the budget
|
|
28
|
-
// and the machine admits it (`admissionDePart` of ./regles-des-places.mjs); else it waits, says
|
|
29
|
-
// what for when it begins and every 30 s, keeps its rank (the measure of the frame before a
|
|
30
|
-
// project's, then the order of arrival) and stops at « à repasser » (75) at the bound.
|
|
31
|
-
// - The memory of a part is that of its sort (`partDeLaPasse`): at 20 peaks or more of the sort in
|
|
32
|
-
// the register, a reservation the admission counts and a limit where its group is cut.
|
|
33
|
-
// - The parts are one file per pass in `${XDG_STATE_HOME:-~/.local/state}/grillhouse/parts`
|
|
34
|
-
// (GRILLHOUSE_PARTS_DE_LA_MACHINE names another): the part held or waited for, its project,
|
|
35
|
-
// ticket, kind, rank and progress directory, which the board reads (`lireLesParts`). A pass
|
|
36
|
-
// whose process is gone frees its part.
|
|
37
|
-
// - A part holds precise threads (`fils` of its file), chosen on the topology by
|
|
38
|
-
// ./coeurs-dedies.mjs `choisirLesCoeurs`, none held by another. A measure of time (`mesure`)
|
|
39
|
-
// takes physical cores whole, the number its project declares (`grillhouse.mesure`) or the
|
|
40
|
-
// default part of the budget; it waits for its cores, then for the load of the others to be
|
|
41
|
-
// under 10 %, within the bound of the wait.
|
|
42
|
-
// - A pass that holds a part carries its mark to its children (GRILLHOUSE_PART_TENUE): a pass
|
|
43
|
-
// they play takes no second part, and the workers of its tools are the cores of its part
|
|
44
|
-
// (GRILLHOUSE_TRAVAILLEURS).
|
|
45
|
-
import { randomUUID } from 'node:crypto';
|
|
46
30
|
import { spawnSync } from 'node:child_process';
|
|
47
|
-
import {
|
|
48
|
-
import { createRequire } from 'node:module';
|
|
49
|
-
import { availableParallelism, homedir } from 'node:os';
|
|
31
|
+
import { readFileSync } from 'node:fs';
|
|
50
32
|
import path from 'node:path';
|
|
51
33
|
import { departDe } from './mesure/base-de-passe.mjs';
|
|
52
|
-
import {
|
|
53
|
-
import { ecrireAtomique } from './mesure/avancement.mjs';
|
|
34
|
+
import { coeursDeLaMesureDe, mesureDeclareeDe } from './coeurs-dedies.mjs';
|
|
54
35
|
import { A_REPASSER } from './codes-de-sortie.mjs';
|
|
55
|
-
import {
|
|
56
|
-
AttenteDeLaMachine,
|
|
57
|
-
attendreDeLaPlace,
|
|
58
|
-
borneDe,
|
|
59
|
-
racineDeLaCopie,
|
|
60
|
-
racineDuDepot,
|
|
61
|
-
rangDeLaMesure,
|
|
62
|
-
} from './attente-de-la-machine.mjs';
|
|
63
|
-
import {
|
|
64
|
-
budgetEnFils,
|
|
65
|
-
chargeDesCoeursDuSysteme,
|
|
66
|
-
choisirLesCoeurs,
|
|
67
|
-
coeursDeLaMesureDe,
|
|
68
|
-
filsDeLaMesure,
|
|
69
|
-
lireLaTopologie,
|
|
70
|
-
mesureDeclareeDe,
|
|
71
|
-
SEUIL_DE_CHARGE,
|
|
72
|
-
} from './coeurs-dedies.mjs';
|
|
36
|
+
import { AttenteDeLaMachine, borneDe, racineDuDepot } from './attente-de-la-machine.mjs';
|
|
73
37
|
import { paquetsDeLEnveloppe } from './enveloppe/paquets-du-plan.mjs';
|
|
74
38
|
import { ecrireLaTrace, traceDesPlaces } from './journal-des-etats.mjs';
|
|
75
|
-
import {
|
|
39
|
+
import { coeursDeLaMachine, mesureDeLaMachine } from './mesure-de-la-machine.mjs';
|
|
76
40
|
import {
|
|
77
41
|
budgetDe,
|
|
78
42
|
partDe,
|
|
79
|
-
partDeclareeDe,
|
|
80
43
|
plafondDe,
|
|
44
|
+
plafondDeDepart,
|
|
81
45
|
reserveDe,
|
|
82
46
|
} from './plafond-de-la-machine.mjs';
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
47
|
+
import { SORTE_DE_LA_MONTEE } from './regles-des-places.mjs';
|
|
48
|
+
import { lireLaTable } from './table-des-consommations.mjs';
|
|
49
|
+
|
|
50
|
+
export { SORTE_DE_LA_MONTEE };
|
|
85
51
|
|
|
86
|
-
// The spacing is a rule (./regles-des-places.mjs), published here too.
|
|
87
|
-
export { ESPACEMENT_MS, espacementDe, VARIABLE_ESPACEMENT } from './regles-des-places.mjs';
|
|
88
52
|
export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
|
|
89
53
|
|
|
90
54
|
/**
|
|
@@ -96,17 +60,54 @@ export const VARIABLE_TRAVAILLEURS = 'GRILLHOUSE_TRAVAILLEURS';
|
|
|
96
60
|
export function sousNiceEtIonice(commande) {
|
|
97
61
|
return ['nice', '-n', '10', 'ionice', '-c', '2', '-n', '7', ...commande];
|
|
98
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The reservation of the step a session plays (`{ id, coeurs, memoire, limite, limiteCoeurs }` in JSON), which the circuit
|
|
65
|
+
* gives the envelope of the session: the arbiter granted it to the step (src/temporal/places/).
|
|
66
|
+
*/
|
|
67
|
+
export const VARIABLE_RESERVATION_D_ETAPE = 'GRILLHOUSE_RESERVATION_D_ETAPE';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The reservation of the step a session plays, as its environment <env> gives it, null without
|
|
71
|
+
* one.
|
|
72
|
+
* @param {Record<string, string | undefined>} [env]
|
|
73
|
+
* @returns {{ id?: string, coeurs: number, memoire: number, limite?: number,
|
|
74
|
+
* limiteCoeurs?: number } | null} `id`, the id of the reservation, which names the group of the
|
|
75
|
+
* step; `limite` and `limiteCoeurs`, the ceiling of its phase
|
|
76
|
+
* @throws {Error} naming the variable when its value is not a reservation
|
|
77
|
+
*/
|
|
78
|
+
export function reservationDeLEtape(env = process.env) {
|
|
79
|
+
const v = env[VARIABLE_RESERVATION_D_ETAPE];
|
|
80
|
+
if (v === undefined || v === '') {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const { id, coeurs, memoire, limite, limiteCoeurs } = JSON.parse(v);
|
|
85
|
+
if (Number.isInteger(coeurs) && coeurs >= 1 && typeof memoire === 'number' && memoire >= 0) {
|
|
86
|
+
return {
|
|
87
|
+
...(typeof id === 'string' ? { id } : {}),
|
|
88
|
+
coeurs,
|
|
89
|
+
memoire,
|
|
90
|
+
...(typeof limite === 'number' ? { limite } : {}),
|
|
91
|
+
...(Number.isInteger(limiteCoeurs) && limiteCoeurs >= 1 ? { limiteCoeurs } : {}),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
// named below
|
|
96
|
+
}
|
|
97
|
+
throw new Error(
|
|
98
|
+
`${VARIABLE_RESERVATION_D_ETAPE} vaut « ${v} » : { "coeurs": <entier ≥ 1>, "memoire": <octets> } est attendu.`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
99
102
|
/** The mark of a place held, which the children of its holder inherit. */
|
|
100
103
|
export const VARIABLE_TENUE = 'GRILLHOUSE_PLACE_TENUE';
|
|
101
104
|
|
|
102
|
-
/** The sort of the verification of the update (scripts/grillhouse-maj.mjs), a gesture of the maintenance. */
|
|
103
|
-
export const SORTE_DE_LA_MONTEE = 'Montée';
|
|
104
105
|
/** The measure of the machine a trial fixes, in JSON `{ coeurs, charge, memoireLibre, memoireTotale }`. */
|
|
105
106
|
export const VARIABLE_MESURE_D_ESSAI = 'GRILLHOUSE_MESURE_D_ESSAI';
|
|
106
|
-
/** The
|
|
107
|
-
export const
|
|
108
|
-
/** The
|
|
109
|
-
export const
|
|
107
|
+
/** The phase of the register a caller gives the verification it launches (the queue's). */
|
|
108
|
+
export const VARIABLE_PHASE_DE_VERIFICATION = 'GRILLHOUSE_VERIFICATION_PHASE';
|
|
109
|
+
/** The phase of the register of the session of an agent, which the circuit names to it. */
|
|
110
|
+
export const VARIABLE_PHASE_DE_SEANCE = 'GRILLHOUSE_PHASE_DE_SEANCE';
|
|
110
111
|
// The server of the places of a trial machine.
|
|
111
112
|
const VARIABLE_ESSAI = 'GRILLHOUSE_PLACES_D_ESSAI';
|
|
112
113
|
|
|
@@ -120,7 +121,7 @@ const PONT = path.join(import.meta.dirname, 'places-du-serveur.mjs');
|
|
|
120
121
|
* @returns {number}
|
|
121
122
|
*/
|
|
122
123
|
export function travailleursDe({
|
|
123
|
-
coeurs =
|
|
124
|
+
coeurs = coeursDeLaMachine(),
|
|
124
125
|
places,
|
|
125
126
|
env = process.env,
|
|
126
127
|
} = {}) {
|
|
@@ -158,7 +159,7 @@ export function surLeServeur(env) {
|
|
|
158
159
|
if (env.CI || paquetsDeLEnveloppe(env)) {
|
|
159
160
|
return null;
|
|
160
161
|
}
|
|
161
|
-
if (env[
|
|
162
|
+
if (env[VARIABLE_MESURE_D_ESSAI]) {
|
|
162
163
|
return env[VARIABLE_ESSAI] ? { ...env, TEMPORAL_ADDRESS: env[VARIABLE_ESSAI] } : null;
|
|
163
164
|
}
|
|
164
165
|
return env;
|
|
@@ -208,16 +209,19 @@ export function prendreUnRang({ env = process.env } = {}) {
|
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
/**
|
|
211
|
-
* The request of a
|
|
212
|
-
*
|
|
212
|
+
* The request of a reservation for the process <pid>: its start, its ticket, the root of its
|
|
213
|
+
* project, the rank of its circuit, what it reserves (<reservation>) and its sort (a pass's).
|
|
213
214
|
* @param {{ pid: number, depart?: string | null,
|
|
214
|
-
* ticket?: string | null, racine?: string, rang?: number | null
|
|
215
|
+
* ticket?: string | null, racine?: string, rang?: number | null,
|
|
216
|
+
* reservation?: { coeurs: number, memoire: number }, sorte?: string }} o
|
|
215
217
|
* @returns {{ pid: number, depart: string | null, ticket: string | null, racine?: string | null,
|
|
216
|
-
* rang?: number }}
|
|
218
|
+
* rang?: number, coeurs?: number, memoire?: number, sorte?: string }}
|
|
217
219
|
*/
|
|
218
|
-
export function demandeDePlace({ pid, depart, ticket = null, racine, rang }) {
|
|
220
|
+
export function demandeDePlace({ pid, depart, ticket = null, racine, rang, reservation, sorte }) {
|
|
219
221
|
return {
|
|
220
222
|
pid,
|
|
223
|
+
...(reservation ? { coeurs: reservation.coeurs, memoire: reservation.memoire } : {}),
|
|
224
|
+
...(sorte ? { sorte } : {}),
|
|
221
225
|
depart: depart === undefined ? departDe(pid) : depart,
|
|
222
226
|
ticket,
|
|
223
227
|
...(racine === undefined ? {} : { racine: racineDuDepot(racine) }),
|
|
@@ -228,10 +232,10 @@ export function demandeDePlace({ pid, depart, ticket = null, racine, rang }) {
|
|
|
228
232
|
/**
|
|
229
233
|
* Takes a place of the machine, waiting for one, saying why it waits (`dire`), and returns the
|
|
230
234
|
* place. Where no place is taken, or under a place already held (GRILLHOUSE_PLACE_TENUE), the
|
|
231
|
-
* place returned holds nothing.
|
|
235
|
+
* place returned holds nothing. A pass gives its <sorte>, which the board reads.
|
|
232
236
|
* @param {{ env?: Record<string, string | undefined>, ticket?: string | null, rang?: number,
|
|
233
237
|
* pid?: number, depart?: string | null, borneMs?: number, rappelMs?: number,
|
|
234
|
-
* dire?: (l: string) => void }} [o] `pid` and `depart` name the process of the session (the
|
|
238
|
+
* reservation?: { coeurs: number, memoire: number }, dire?: (l: string) => void }} [o] `pid` and `depart` name the process of the session (the
|
|
235
239
|
* taking process by default); `rang` the rank of the arrival of the circuit (drawn by the server
|
|
236
240
|
* when absent)
|
|
237
241
|
* @returns {{ id: string | null, rang: number | null, env: Record<string, string | undefined>,
|
|
@@ -250,13 +254,15 @@ export function prendreUnePlace({
|
|
|
250
254
|
rappelMs = RAPPEL_MS,
|
|
251
255
|
dire = l => process.stdout.write(`${l}\n`),
|
|
252
256
|
racine = process.cwd(),
|
|
257
|
+
reservation,
|
|
258
|
+
sorte,
|
|
253
259
|
} = {}) {
|
|
254
260
|
const e = env[VARIABLE_TENUE] ? null : surLeServeur(env);
|
|
255
261
|
if (!e) {
|
|
256
262
|
return { id: null, rang: rang ?? null, env, rendre: () => {}, rattacher: () => {} };
|
|
257
263
|
}
|
|
258
264
|
const demande = {
|
|
259
|
-
...demandeDePlace({ pid, depart, ticket, racine, rang }),
|
|
265
|
+
...demandeDePlace({ pid, depart, ticket, racine, rang, reservation, sorte }),
|
|
260
266
|
borneMs,
|
|
261
267
|
rappelMs,
|
|
262
268
|
};
|
|
@@ -274,7 +280,18 @@ export function prendreUnePlace({
|
|
|
274
280
|
throw new AttenteDeLaMachine(lignes.at(-1)?.dire ?? 'attente de place bornée', A_REPASSER);
|
|
275
281
|
}
|
|
276
282
|
const place = lignes.find(l => l.id);
|
|
277
|
-
|
|
283
|
+
// The reservation of a pass (cores, memory, who) is written at its taking and its return, so
|
|
284
|
+
// that the reservations held at an instant are read back from the journal alone.
|
|
285
|
+
const tracee = reservation
|
|
286
|
+
? {
|
|
287
|
+
reservation: {
|
|
288
|
+
coeurs: reservation.coeurs,
|
|
289
|
+
memoireGo: Math.round((reservation.memoire / 2 ** 30) * 100) / 100,
|
|
290
|
+
qui: [ticket, sorte].filter(Boolean).join(' ') || 'passe',
|
|
291
|
+
},
|
|
292
|
+
}
|
|
293
|
+
: {};
|
|
294
|
+
ecrireLaTrace(racine, traceDesPlaces({ evenement: 'prise', ticket, place: place.id, ...tracee }));
|
|
278
295
|
return {
|
|
279
296
|
id: place.id,
|
|
280
297
|
rang: place.rang,
|
|
@@ -284,7 +301,10 @@ export function prendreUnePlace({
|
|
|
284
301
|
rendre: () => {
|
|
285
302
|
try {
|
|
286
303
|
auServeur(e, ['rendre', place.id]);
|
|
287
|
-
ecrireLaTrace(
|
|
304
|
+
ecrireLaTrace(
|
|
305
|
+
racine,
|
|
306
|
+
traceDesPlaces({ evenement: 'rendue', ticket, place: place.id, ...tracee })
|
|
307
|
+
);
|
|
288
308
|
} catch (x) {
|
|
289
309
|
if (!(x instanceof AttenteDeLaMachine)) {
|
|
290
310
|
throw x;
|
|
@@ -334,99 +354,12 @@ export function avecUnePlace(seance, options) {
|
|
|
334
354
|
return r;
|
|
335
355
|
}
|
|
336
356
|
|
|
337
|
-
/**
|
|
338
|
-
* The directory of the state of the parts under <env>: GRILLHOUSE_PARTS_DE_LA_MACHINE, else
|
|
339
|
-
* `grillhouse/parts` under the state directory of the user (`XDG_STATE_HOME`, else
|
|
340
|
-
* `~/.local/state`), common to every project of the machine.
|
|
341
|
-
* @param {Record<string, string | undefined>} [env]
|
|
342
|
-
* @returns {string}
|
|
343
|
-
*/
|
|
344
|
-
export function dossierDesParts(env = process.env) {
|
|
345
|
-
if (env[VARIABLE_PARTS]) {
|
|
346
|
-
return env[VARIABLE_PARTS];
|
|
347
|
-
}
|
|
348
|
-
const etat = env.XDG_STATE_HOME || path.join(env.HOME || homedir(), '.local', 'state');
|
|
349
|
-
return path.join(etat, 'grillhouse', 'parts');
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* The state of a pass in its file of the parts: `etat` « tient » (its part is held) or « attend »
|
|
354
|
-
* (`raison`: what it waits for), and what the board reads besides (`depot`, `copie`, `depuis`,
|
|
355
|
-
* `dossier` its progress directory, `depasse` what it consumes beyond its part).
|
|
356
|
-
* @typedef {{ id: string, pid: number, depart: any, projet: string, ticket: string | null,
|
|
357
|
-
* sorte: string, rang: number, coeurs: number, memoire: number, etat: string, raison?: string,
|
|
358
|
-
* depot?: string, copie?: string, depuis?: number, dossier?: string | null,
|
|
359
|
-
* depasse?: string | null }} PartDUnePasse
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Writes the state of the pass <passe> in its file of <dossier>, whole or not at all. The file of a
|
|
364
|
-
* pass is one: a new state replaces it.
|
|
365
|
-
* @param {string} dossier
|
|
366
|
-
* @param {{ id: string } & Record<string, unknown>} passe
|
|
367
|
-
*/
|
|
368
|
-
export function poserLaPart(dossier, passe) {
|
|
369
|
-
ecrireAtomique(path.join(dossier, `${passe.id}.json`), passe);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Gives back the part of the pass <id>: its file goes, and the directory when it is empty. A part
|
|
374
|
-
* that is not there changes nothing.
|
|
375
|
-
* @param {string} dossier
|
|
376
|
-
* @param {string} id
|
|
377
|
-
*/
|
|
378
|
-
export function rendreLaPart(dossier, id) {
|
|
379
|
-
rmSync(path.join(dossier, `${id}.json`), { force: true });
|
|
380
|
-
try {
|
|
381
|
-
rmdirSync(dossier);
|
|
382
|
-
} catch {
|
|
383
|
-
// other parts stand there, or the directory is gone
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* The parts of <dossier> as the machine holds them: `prises` (the passes that hold their part)
|
|
389
|
-
* and `attentes` (those that wait, in the order of their rank). A pass whose process is gone
|
|
390
|
-
* (`vivant`, `processusVivant` by default: its pid and its start) frees its part, its file
|
|
391
|
-
* removed. A directory that is not there holds none.
|
|
392
|
-
* @param {string} dossier
|
|
393
|
-
* @param {{ vivant?: (p: PartDUnePasse) => boolean }} [o]
|
|
394
|
-
* @returns {{ prises: PartDUnePasse[], attentes: PartDUnePasse[] }}
|
|
395
|
-
*/
|
|
396
|
-
export function lireLesParts(dossier, { vivant = processusVivant } = {}) {
|
|
397
|
-
let noms;
|
|
398
|
-
try {
|
|
399
|
-
noms = readdirSync(dossier).filter(n => n.endsWith('.json'));
|
|
400
|
-
} catch {
|
|
401
|
-
return { prises: [], attentes: [] };
|
|
402
|
-
}
|
|
403
|
-
const prises = [];
|
|
404
|
-
const attentes = [];
|
|
405
|
-
for (const nom of noms) {
|
|
406
|
-
let p;
|
|
407
|
-
try {
|
|
408
|
-
p = JSON.parse(readFileSync(path.join(dossier, nom), 'utf8'));
|
|
409
|
-
} catch {
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
if (!p || typeof p.id !== 'string') {
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
if (!vivant(p)) {
|
|
416
|
-
rmSync(path.join(dossier, nom), { force: true });
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
(p.etat === 'attend' ? attentes : prises).push(p);
|
|
420
|
-
}
|
|
421
|
-
return { prises, attentes: attentes.sort((a, b) => a.rang - b.rang) };
|
|
422
|
-
}
|
|
423
|
-
|
|
424
357
|
/**
|
|
425
358
|
* The machine a pass is judged on under <env>: the one a trial fixes (GRILLHOUSE_MESURE_D_ESSAI),
|
|
426
359
|
* else the real one.
|
|
427
360
|
* @param {Record<string, string | undefined>} env
|
|
428
361
|
*/
|
|
429
|
-
const machineDe = env => mesureDEssai(env) ?? mesureDeLaMachine();
|
|
362
|
+
export const machineDe = env => mesureDEssai(env) ?? mesureDeLaMachine();
|
|
430
363
|
|
|
431
364
|
/**
|
|
432
365
|
* The budget of the machine under <env>: its hardware (the one a trial fixes, else the real one)
|
|
@@ -437,87 +370,52 @@ const machineDe = env => mesureDEssai(env) ?? mesureDeLaMachine();
|
|
|
437
370
|
*/
|
|
438
371
|
export function budgetDeLaPasse(env = process.env) {
|
|
439
372
|
const m = machineDe(env);
|
|
440
|
-
return budgetDe(
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
// tree not built (a fresh clone before its build), where the part of the project stands.
|
|
445
|
-
function calculParSorte() {
|
|
446
|
-
try {
|
|
447
|
-
return createRequire(import.meta.url)('../dist/machine/part-par-sorte.js');
|
|
448
|
-
} catch (e) {
|
|
449
|
-
if (e?.code === 'MODULE_NOT_FOUND') {
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
throw e;
|
|
453
|
-
}
|
|
373
|
+
return budgetDe(
|
|
374
|
+
{ coeurs: m.coeurs, memoireTotale: m.memoireTotale },
|
|
375
|
+
reserveDe(env, { coeurs: m.coeurs })
|
|
376
|
+
);
|
|
454
377
|
}
|
|
455
378
|
|
|
456
379
|
/**
|
|
457
|
-
* The
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
* `
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
* @param {{ racine: string, env?: Record<string, string | undefined>,
|
|
464
|
-
*
|
|
465
|
-
* @
|
|
466
|
-
* @throws {AttenteDeLaMachine} naming the key (code 1) when its value is faulty, before any work
|
|
380
|
+
* The reservation of a pass of the phase <phase> of the project at <racine> under <env>: the cores
|
|
381
|
+
* and the memory the table of the consumptions of the project gives that phase, else the default
|
|
382
|
+
* reservation of the budget (`partDe`: 3 cores, the budget divided by the places); and its ceiling (`limite` in bytes,
|
|
383
|
+
* `limiteCoeurs`: where the group of the step is cut), that of the line of its phase, else its
|
|
384
|
+
* reservation plus a quarter; all within the budget of the machine. No key of the `package.json`
|
|
385
|
+
* of the project enters it.
|
|
386
|
+
* @param {{ racine: string, env?: Record<string, string | undefined>, phase: string }} o
|
|
387
|
+
* @returns {{ coeurs: number, memoire: number, limite: number, limiteCoeurs: number }}
|
|
388
|
+
* @throws {Error} naming the variable of the reserve when it is faulty or leaves nothing
|
|
467
389
|
*/
|
|
468
|
-
export function
|
|
469
|
-
const { declaree, faute } = partDeclareeDe(packageDuDepot(racine));
|
|
470
|
-
if (faute) {
|
|
471
|
-
throw new AttenteDeLaMachine(`✗ ${faute}`, 1);
|
|
472
|
-
}
|
|
390
|
+
export function reservationDeLaPasse({ racine, env = process.env, phase }) {
|
|
473
391
|
const budget = budgetDeLaPasse(env);
|
|
474
|
-
const
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
* @param {Record<string, any>[]} lignes
|
|
498
|
-
* @returns {number | undefined}
|
|
499
|
-
*/
|
|
500
|
-
function plusGrandPicDeJour(lignes) {
|
|
501
|
-
let pic;
|
|
502
|
-
for (const l of lignes) {
|
|
503
|
-
const p = l.memoirePic;
|
|
504
|
-
if (
|
|
505
|
-
SORTES_HORS_JOUR.has(l.sorte) ||
|
|
506
|
-
l.sorte.startsWith('mesure') ||
|
|
507
|
-
l.sorte.startsWith('seance') ||
|
|
508
|
-
typeof p !== 'number' ||
|
|
509
|
-
!Number.isFinite(p) ||
|
|
510
|
-
p <= 0
|
|
511
|
-
) {
|
|
512
|
-
continue;
|
|
513
|
-
}
|
|
514
|
-
pic = Math.max(pic ?? 0, p);
|
|
515
|
-
}
|
|
516
|
-
return pic;
|
|
392
|
+
const voulue = lireLaTable(racine)?.phases?.[phase];
|
|
393
|
+
const { coeurs, memoire } = voulue
|
|
394
|
+
? {
|
|
395
|
+
coeurs: Math.max(1, Math.min(budget.coeurs, voulue.coeurs)),
|
|
396
|
+
memoire: Math.min(budget.memoire, voulue.memoire),
|
|
397
|
+
}
|
|
398
|
+
: partDe({ budget, places: plafondDe(env) });
|
|
399
|
+
const depart = plafondDeDepart({ coeurs, memoire }, budget);
|
|
400
|
+
return {
|
|
401
|
+
coeurs,
|
|
402
|
+
memoire,
|
|
403
|
+
limite: Math.min(
|
|
404
|
+
budget.memoire,
|
|
405
|
+
typeof voulue?.limite === 'number' ? voulue.limite : depart.limite
|
|
406
|
+
),
|
|
407
|
+
limiteCoeurs: Math.max(
|
|
408
|
+
1,
|
|
409
|
+
Math.min(
|
|
410
|
+
budget.coeurs,
|
|
411
|
+
typeof voulue?.limiteCoeurs === 'number' ? voulue.limiteCoeurs : depart.limiteCoeurs
|
|
412
|
+
)
|
|
413
|
+
),
|
|
414
|
+
};
|
|
517
415
|
}
|
|
518
416
|
|
|
519
417
|
// The `package.json` of the main tree of the repository at <racine>; empty without one (a
|
|
520
|
-
// repository without a package.json declares
|
|
418
|
+
// repository without a package.json declares no measure).
|
|
521
419
|
function packageDuDepot(racine) {
|
|
522
420
|
try {
|
|
523
421
|
return JSON.parse(readFileSync(path.join(racineDuDepot(racine), 'package.json'), 'utf8'));
|
|
@@ -528,12 +426,12 @@ function packageDuDepot(racine) {
|
|
|
528
426
|
|
|
529
427
|
/**
|
|
530
428
|
* The cores a measure of time of the project at <racine> asks for, in threads: the key
|
|
531
|
-
* `grillhouse.mesure` of its main tree's `package.json`, else the default
|
|
429
|
+
* `grillhouse.mesure` of its main tree's `package.json`, else the default reservation of the budget.
|
|
532
430
|
* @param {{ racine: string, budget: { coeurs: number } }} o
|
|
533
431
|
* @returns {number}
|
|
534
432
|
* @throws {AttenteDeLaMachine} naming the key (code 1) when its value is faulty, before any work
|
|
535
433
|
*/
|
|
536
|
-
function coeursDeLaMesure({ racine, budget }) {
|
|
434
|
+
export function coeursDeLaMesure({ racine, budget }) {
|
|
537
435
|
const { declaree, faute } = mesureDeclareeDe(packageDuDepot(racine));
|
|
538
436
|
if (faute) {
|
|
539
437
|
throw new AttenteDeLaMachine(`✗ ${faute}`, 1);
|
|
@@ -541,383 +439,6 @@ function coeursDeLaMesure({ racine, budget }) {
|
|
|
541
439
|
return coeursDeLaMesureDe({ declaree, budget });
|
|
542
440
|
}
|
|
543
441
|
|
|
544
|
-
// What a part asks of the memory, as the waiting line says it: « 4,3 Go réservés, limite 7,5 Go ».
|
|
545
|
-
const memoireDite = ({ memoire, limite }) => {
|
|
546
|
-
const go = o => String(Math.round((o / 1024 ** 3) * 10) / 10).replace('.', ',');
|
|
547
|
-
return `${go(memoire)} Go réservés, ${limite === null ? 'sans limite' : `limite ${go(limite)} Go`}`;
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
const RANGS = { 1: 'mesure du cadre', 2: "mesure d'un projet" };
|
|
551
|
-
// The rank of a pass among the parts: the kind of its measure first (the frame's before a
|
|
552
|
-
// project's), then its time of arrival, so that a smaller rank passes first.
|
|
553
|
-
const ECHELLE_DES_RANGS = 1e14;
|
|
554
|
-
|
|
555
|
-
// Plays <f> holding the short lock of the admission of <dossier>, so that two passes never judge
|
|
556
|
-
// the same free budget at once. The directory is made again when it goes between its making and
|
|
557
|
-
// the lock: another pass that gives its part back removes it while it is empty (`rendreLaPart`).
|
|
558
|
-
// Once the lock lies in it, it stays.
|
|
559
|
-
function sousLAdmission(dossier, f) {
|
|
560
|
-
const verrou = path.join(dossier, '.admission');
|
|
561
|
-
for (;;) {
|
|
562
|
-
mkdirSync(dossier, { recursive: true });
|
|
563
|
-
try {
|
|
564
|
-
prendreVerrou(verrou, { attendre: true });
|
|
565
|
-
break;
|
|
566
|
-
} catch (e) {
|
|
567
|
-
if (e?.code !== 'ENOENT') {
|
|
568
|
-
throw e;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
try {
|
|
573
|
-
return f();
|
|
574
|
-
} finally {
|
|
575
|
-
lacherVerrou(verrou);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* How a measure reads the load of the threads it was given under <env>: on the machine a trial
|
|
581
|
-
* fixes (GRILLHOUSE_MESURE_D_ESSAI) they are at rest, no trial reading the load of the user's
|
|
582
|
-
* machine; else the load the system gives (<systeme>).
|
|
583
|
-
* @param {Record<string, string | undefined>} [env]
|
|
584
|
-
* @param {(fils: number[]) => number | null} [systeme]
|
|
585
|
-
* @returns {(fils: number[]) => number | null}
|
|
586
|
-
*/
|
|
587
|
-
export function lecteurDeLaCharge(env = process.env, systeme = chargeDesCoeursDuSysteme) {
|
|
588
|
-
return env[VARIABLE_MESURE_D_ESSAI] ? () => 0 : systeme;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Takes the part of a pass of the project at <racine>, waiting for it, saying what it waits for
|
|
593
|
-
* (`dire`) when it begins and every <rappelMs>, and returns it. Room first on the disks the pass
|
|
594
|
-
* writes on (`attendreDeLaPlace`), then the part: it is taken once it fits in what the parts held
|
|
595
|
-
* leave of the budget and the load and the memory of the machine admit it, the waits of a smaller
|
|
596
|
-
* rank passing first. Its state is one file of the parts (`poserLaPart`), « attend » then
|
|
597
|
-
* « tient ». The night of a project is a pass like another, of the sort « Nuit »: it takes the part of
|
|
598
|
-
* its project. A <mesure> of time takes dedicated cores (`fils`, whole physical
|
|
599
|
-
* cores), waits for them and for their rest (<chargeDesCoeurs>: the load of the threads it gives,
|
|
600
|
-
* null without a reading, by default `lecteurDeLaCharge`; <topologie>, the topology of the system, for a trial).
|
|
601
|
-
* The reservation of the machine (<lireLaReservation>, the places of the server by default) is read at each
|
|
602
|
-
* turn of the wait, before the admission lock: under the supervisor's closure the pass waits without bound
|
|
603
|
-
* (« 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
|
|
604
|
-
* held: GRILLHOUSE_PART_TENUE) the part returned holds nothing. <bornee> false (a session of an
|
|
605
|
-
* agent) reserves the memory without a limit.
|
|
606
|
-
* @param {{ env?: Record<string, string | undefined>, racine?: string, ticket?: string | null,
|
|
607
|
-
* sorte?: string, mesure?: boolean, bornee?: boolean,
|
|
608
|
-
* borneMs?: number, rappelMs?: number,
|
|
609
|
-
* dire?: (l: string) => void, maintenant?: () => number, dormir?: (ms: number) => void,
|
|
610
|
-
* libre?: (d: string) => number, occupe?: (d: string) => string,
|
|
611
|
-
* occupeLaCopie?: (r: string) => string }} [o]
|
|
612
|
-
* @returns {{ id: string | null,
|
|
613
|
-
* part: { coeurs: number, memoire: number, limite?: number | null } | null,
|
|
614
|
-
* env: Record<string, string | undefined>, rendre: () => void, raison: string | null }}
|
|
615
|
-
* `env`, the environment of its holder's children, with the mark of the part and the workers of
|
|
616
|
-
* its tools; `raison`, why no part is held, null when one is
|
|
617
|
-
* @throws {AttenteDeLaMachine} at the bound of the wait (code 75), or on a faulty key or reserve
|
|
618
|
-
* (code 1), its reason named
|
|
619
|
-
*/
|
|
620
|
-
export function prendreUnePart({
|
|
621
|
-
env = process.env,
|
|
622
|
-
racine = process.cwd(),
|
|
623
|
-
ticket,
|
|
624
|
-
sorte,
|
|
625
|
-
mesure = false,
|
|
626
|
-
bornee = true,
|
|
627
|
-
topologie,
|
|
628
|
-
chargeDesCoeurs = lecteurDeLaCharge(env),
|
|
629
|
-
borneMs = borneDe(env),
|
|
630
|
-
rappelMs = RAPPEL_MS,
|
|
631
|
-
dire = l => process.stdout.write(`${l}\n`),
|
|
632
|
-
maintenant = Date.now,
|
|
633
|
-
dormir = attendreUnPeu,
|
|
634
|
-
lireLaReservation = () => lirePlaces({ env }).reservation ?? null,
|
|
635
|
-
...disques
|
|
636
|
-
} = {}) {
|
|
637
|
-
const sans = raison => ({ id: null, part: null, fils: null, env, rendre: () => {}, raison });
|
|
638
|
-
if (paquetsDeLEnveloppe(env)) {
|
|
639
|
-
return sans("dans l'enveloppe d'un agent");
|
|
640
|
-
}
|
|
641
|
-
if (env[VARIABLE_PART_TENUE]) {
|
|
642
|
-
return sans('sous la part de son parent');
|
|
643
|
-
}
|
|
644
|
-
// The caller names who the pass is, else its environment does (GRILLHOUSE_VERIFICATION_TICKET,
|
|
645
|
-
// GRILLHOUSE_VERIFICATION_SORTE, empty as absent), else « Vérification » and no ticket.
|
|
646
|
-
ticket = ticket ?? (env.GRILLHOUSE_VERIFICATION_TICKET || null);
|
|
647
|
-
sorte = sorte ?? (env.GRILLHOUSE_VERIFICATION_SORTE || 'Vérification');
|
|
648
|
-
const dossier = dossierDesParts(env);
|
|
649
|
-
let budget;
|
|
650
|
-
let part;
|
|
651
|
-
// The precise threads of the budget and the topology they are chosen on.
|
|
652
|
-
let budgetFils;
|
|
653
|
-
let topo;
|
|
654
|
-
try {
|
|
655
|
-
budget = budgetDeLaPasse(env);
|
|
656
|
-
topo = topologie ?? lireLaTopologie({ nombreDeFils: machineDe(env).coeurs });
|
|
657
|
-
budgetFils = budgetEnFils({ topologie: topo, budget: budget.coeurs });
|
|
658
|
-
if (mesure) {
|
|
659
|
-
const demande = coeursDeLaMesure({ racine, budget });
|
|
660
|
-
let fils = filsDeLaMesure({ budget: budgetFils, topologie: topo, demande });
|
|
661
|
-
if (fils === null || !topo.lisible) {
|
|
662
|
-
// No whole core in the budget, or a topology that does not read: each thread is a core.
|
|
663
|
-
topo = { lisible: false, coeurs: topo.coeurs.flatMap(c => c.fils.map(f => ({ fils: [f], noeud: c.noeud }))) };
|
|
664
|
-
fils = filsDeLaMesure({ budget: budgetFils, topologie: topo, demande });
|
|
665
|
-
dire('la topologie des cœurs ne se lit pas : chaque fil compte pour un cœur.');
|
|
666
|
-
}
|
|
667
|
-
part = { coeurs: fils, memoire: Math.floor((budget.memoire * fils) / budget.coeurs) };
|
|
668
|
-
} else {
|
|
669
|
-
part = partDeLaPasse({ racine, env, sorte });
|
|
670
|
-
}
|
|
671
|
-
} catch (e) {
|
|
672
|
-
throw e instanceof AttenteDeLaMachine ? e : new AttenteDeLaMachine(`✗ ${e.message}`, 1);
|
|
673
|
-
}
|
|
674
|
-
const depot = racineDuDepot(racine);
|
|
675
|
-
const rangDeLaPasse = rangDeLaMesure(racine);
|
|
676
|
-
const moi = {
|
|
677
|
-
id: randomUUID(),
|
|
678
|
-
pid: process.pid,
|
|
679
|
-
depart: departDe(process.pid),
|
|
680
|
-
projet: path.basename(depot),
|
|
681
|
-
depot,
|
|
682
|
-
copie: racineDeLaCopie(racine),
|
|
683
|
-
ticket,
|
|
684
|
-
sorte,
|
|
685
|
-
rang: rangDeLaPasse * ECHELLE_DES_RANGS + maintenant(),
|
|
686
|
-
coeurs: part.coeurs,
|
|
687
|
-
memoire: part.memoire,
|
|
688
|
-
// Where the group of the pass is cut; null, a session, whose group has no memory bound.
|
|
689
|
-
limite: bornee ? (part.limite ?? part.memoire) : null,
|
|
690
|
-
dediee: mesure,
|
|
691
|
-
depuis: maintenant(),
|
|
692
|
-
};
|
|
693
|
-
let tenus = null;
|
|
694
|
-
try {
|
|
695
|
-
attendreDeLaPlace({
|
|
696
|
-
env,
|
|
697
|
-
dire,
|
|
698
|
-
borneMs,
|
|
699
|
-
rappelMs,
|
|
700
|
-
racine,
|
|
701
|
-
maintenant,
|
|
702
|
-
dormir,
|
|
703
|
-
...disques,
|
|
704
|
-
inscrire: raison => {
|
|
705
|
-
poserLaPart(dossier, { ...moi, etat: 'attend', raison });
|
|
706
|
-
return () => {};
|
|
707
|
-
},
|
|
708
|
-
});
|
|
709
|
-
let debut = maintenant();
|
|
710
|
-
let dit = null;
|
|
711
|
-
for (;;) {
|
|
712
|
-
// The reservation of the machine is read each turn, before the admission lock, bounded by
|
|
713
|
-
// the delay of a call to the server; a reading that fails stands for « no reservation ».
|
|
714
|
-
// A pass already admitted (a place held: GRILLHOUSE_PLACE_TENUE) or of the update (sort
|
|
715
|
-
// « Montée ») is no new work: the closure does not refuse it, as a drain keeps the pods of
|
|
716
|
-
// the system.
|
|
717
|
-
let reservation = null;
|
|
718
|
-
if (!env[VARIABLE_TENUE] && sorte !== SORTE_DE_LA_MONTEE) {
|
|
719
|
-
try {
|
|
720
|
-
reservation = lireLaReservation() ?? null;
|
|
721
|
-
} catch {
|
|
722
|
-
reservation = null;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
const fermee = reservation?.auteur === 'superviseur';
|
|
726
|
-
const refus = sousLAdmission(dossier, () => {
|
|
727
|
-
const { prises, attentes } = lireLesParts(dossier);
|
|
728
|
-
let r = refusDePart(
|
|
729
|
-
{ prises, attentes },
|
|
730
|
-
{
|
|
731
|
-
id: moi.id,
|
|
732
|
-
rang: moi.rang,
|
|
733
|
-
part,
|
|
734
|
-
budget,
|
|
735
|
-
mesurer: () => machineDe(env),
|
|
736
|
-
dediee: mesure,
|
|
737
|
-
reservation,
|
|
738
|
-
}
|
|
739
|
-
);
|
|
740
|
-
let fils = null;
|
|
741
|
-
if (r === null) {
|
|
742
|
-
// The count fits: the precise threads, none held by another pass (a measure's whole
|
|
743
|
-
// cores, a free core cut by an ordinary pass's threads does not give one).
|
|
744
|
-
fils = choisirLesCoeurs({
|
|
745
|
-
budget: budgetFils,
|
|
746
|
-
topologie: topo,
|
|
747
|
-
tenus: prises.filter(p => p.id !== moi.id).flatMap(p => p.fils ?? []),
|
|
748
|
-
demande: part.coeurs,
|
|
749
|
-
dedies: mesure,
|
|
750
|
-
});
|
|
751
|
-
if (fils === null) {
|
|
752
|
-
r = mesure
|
|
753
|
-
? `cœurs dédiés : ${part.coeurs} demandés, aucun cœur entier libre`
|
|
754
|
-
: `cœurs : ${part.coeurs} demandés, pas assez de fils libres`;
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
poserLaPart(
|
|
758
|
-
dossier,
|
|
759
|
-
r === null ? { ...moi, fils, etat: 'tient' } : { ...moi, etat: 'attend', raison: r }
|
|
760
|
-
);
|
|
761
|
-
tenus = r === null ? fils : null;
|
|
762
|
-
return r;
|
|
763
|
-
});
|
|
764
|
-
if (refus === null) {
|
|
765
|
-
break;
|
|
766
|
-
}
|
|
767
|
-
const t = maintenant();
|
|
768
|
-
if (fermee) {
|
|
769
|
-
// The supervisor's order lasts until its contrary: no bound, the wait counts from the reopening.
|
|
770
|
-
debut = t;
|
|
771
|
-
}
|
|
772
|
-
if (t - debut >= borneMs) {
|
|
773
|
-
throw new AttenteDeLaMachine(
|
|
774
|
-
`⏱ attente de la part bornée à ${duree(borneMs)} (GRILLHOUSE_ATTENTE_MACHINE_MS), ${RANGS[rangDeLaPasse]} : ${refus} ; à repasser (code ${A_REPASSER}).`,
|
|
775
|
-
A_REPASSER
|
|
776
|
-
);
|
|
777
|
-
}
|
|
778
|
-
if (dit === null) {
|
|
779
|
-
dire(
|
|
780
|
-
`⏳ ${RANGS[rangDeLaPasse]}, la passe attend sa part (${part.coeurs} cœurs, ${memoireDite(moi)}) : ${refus}${fermee ? ' ; sans borne, jusqu’à la réouverture.' : ` ; ${duree(borneMs)} au plus.`}`
|
|
781
|
-
);
|
|
782
|
-
} else if (t - dit >= rappelMs) {
|
|
783
|
-
dire(
|
|
784
|
-
`⏳ la passe attend sa part (${memoireDite(moi)}) depuis ${duree(t - debut)} : ${refus}.`
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
if (dit === null || t - dit >= rappelMs) {
|
|
788
|
-
dit = t;
|
|
789
|
-
}
|
|
790
|
-
dormir(Math.max(1, Math.min(200, borneMs - (maintenant() - debut))));
|
|
791
|
-
}
|
|
792
|
-
// The rest of the dedicated cores: a measure goes once their load, out of it, is under the
|
|
793
|
-
// threshold, within the bound of the wait; without a reading it does not judge that load.
|
|
794
|
-
if (mesure) {
|
|
795
|
-
let ditCharge = null;
|
|
796
|
-
for (;;) {
|
|
797
|
-
const charge = chargeDesCoeurs(tenus);
|
|
798
|
-
if (charge === null) {
|
|
799
|
-
dire('la charge des cœurs dédiés ne se lit pas : la mesure ne la juge pas.');
|
|
800
|
-
break;
|
|
801
|
-
}
|
|
802
|
-
if (charge < SEUIL_DE_CHARGE) {
|
|
803
|
-
break;
|
|
804
|
-
}
|
|
805
|
-
const t = maintenant();
|
|
806
|
-
const pct = `${Math.round(charge * 100)} %`;
|
|
807
|
-
if (t - debut >= borneMs) {
|
|
808
|
-
throw new AttenteDeLaMachine(
|
|
809
|
-
`⏱ attente du repos des cœurs dédiés bornée à ${duree(borneMs)} (GRILLHOUSE_ATTENTE_MACHINE_MS), ${RANGS[rangDeLaPasse]} : charge de ${pct} des cœurs dédiés hors la mesure, ${Math.round(SEUIL_DE_CHARGE * 100)} % au plus ; à repasser (code ${A_REPASSER}).`,
|
|
810
|
-
A_REPASSER
|
|
811
|
-
);
|
|
812
|
-
}
|
|
813
|
-
if (ditCharge === null || t - ditCharge >= rappelMs) {
|
|
814
|
-
dire(`⏳ les cœurs dédiés ne sont pas au repos : charge de ${pct} hors la mesure, ${Math.round(SEUIL_DE_CHARGE * 100)} % au plus.`);
|
|
815
|
-
ditCharge = t;
|
|
816
|
-
}
|
|
817
|
-
dormir(Math.max(1, Math.min(200, borneMs - (maintenant() - debut))));
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
if (dit !== null) {
|
|
821
|
-
dire(`✓ part prise après ${duree(maintenant() - debut)}.`);
|
|
822
|
-
}
|
|
823
|
-
} catch (e) {
|
|
824
|
-
rendreLaPart(dossier, moi.id);
|
|
825
|
-
throw e;
|
|
826
|
-
}
|
|
827
|
-
const {
|
|
828
|
-
GRILLHOUSE_VERIFICATION_SORTE: _sorte,
|
|
829
|
-
GRILLHOUSE_VERIFICATION_TICKET: _ticket,
|
|
830
|
-
...enfant
|
|
831
|
-
} = env;
|
|
832
|
-
// The reservation of the part (cores, memory, who), written at its taking and its return, so
|
|
833
|
-
// that the parts held at an instant are read back from the journal alone.
|
|
834
|
-
const reservation = {
|
|
835
|
-
coeurs: part.coeurs,
|
|
836
|
-
memoireGo: Math.round((part.memoire / 2 ** 30) * 100) / 100,
|
|
837
|
-
qui: [ticket, sorte].filter(Boolean).join(' ') || 'passe',
|
|
838
|
-
};
|
|
839
|
-
const tracer = evenement =>
|
|
840
|
-
ecrireLaTrace(
|
|
841
|
-
racine,
|
|
842
|
-
traceDesPlaces({ evenement, ticket: ticket ?? null, place: moi.id, reservation })
|
|
843
|
-
);
|
|
844
|
-
tracer('prise');
|
|
845
|
-
return {
|
|
846
|
-
id: moi.id,
|
|
847
|
-
part: bornee ? part : { ...part, limite: null },
|
|
848
|
-
fils: tenus,
|
|
849
|
-
dediee: mesure,
|
|
850
|
-
budgetFils,
|
|
851
|
-
topologie: topo,
|
|
852
|
-
env: {
|
|
853
|
-
...enfant,
|
|
854
|
-
[VARIABLE_PART_TENUE]: moi.id,
|
|
855
|
-
[VARIABLE_TRAVAILLEURS]: String(part.coeurs),
|
|
856
|
-
},
|
|
857
|
-
rendre: () => {
|
|
858
|
-
rendreLaPart(dossier, moi.id);
|
|
859
|
-
tracer('rendue');
|
|
860
|
-
},
|
|
861
|
-
raison: null,
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* Names the progress directory <dossier> of the pass that holds the part its environment
|
|
867
|
-
* <env> marks (GRILLHOUSE_PART_TENUE), in its file of the parts, where the board reads it; a
|
|
868
|
-
* function that takes it out. Nothing without a part held (the envelope of an agent).
|
|
869
|
-
* @param {{ env?: Record<string, string | undefined>, dossier: string }} o
|
|
870
|
-
* @returns {() => void}
|
|
871
|
-
*/
|
|
872
|
-
export function nommerLAvancement({ env = process.env, dossier }) {
|
|
873
|
-
const id = env[VARIABLE_PART_TENUE];
|
|
874
|
-
if (!id) {
|
|
875
|
-
return () => {};
|
|
876
|
-
}
|
|
877
|
-
const f = path.join(dossierDesParts(env), `${id}.json`);
|
|
878
|
-
const ecrire = d => {
|
|
879
|
-
try {
|
|
880
|
-
const p = JSON.parse(readFileSync(f, 'utf8'));
|
|
881
|
-
ecrireAtomique(f, { ...p, dossier: d });
|
|
882
|
-
return true;
|
|
883
|
-
} catch {
|
|
884
|
-
return false;
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
return ecrire(dossier) ? () => void ecrire(null) : () => {};
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
/**
|
|
891
|
-
* Plays <passe> holding a part of the machine, given back at its end, whether it returns or
|
|
892
|
-
* throws: its exit code, or, a wait that stops (its bound, 75; a faulty key, 1), its reason said
|
|
893
|
-
* and its code. <passe> receives the environment of its children and the part (null where none is
|
|
894
|
-
* held); the pass is a command a person runs (`npm test`) and the process itself.
|
|
895
|
-
* @param {(env: Record<string, string | undefined>, part: { coeurs: number, memoire: number } | null) => number} passe
|
|
896
|
-
* @param {{ env?: Record<string, string | undefined>, racine?: string,
|
|
897
|
-
* dire?: (l: string) => void }} [o]
|
|
898
|
-
* @returns {number}
|
|
899
|
-
*/
|
|
900
|
-
export function surUnePart(
|
|
901
|
-
passe,
|
|
902
|
-
{ env = process.env, racine = process.cwd(), dire = l => process.stderr.write(`${l}\n`) } = {}
|
|
903
|
-
) {
|
|
904
|
-
let prise;
|
|
905
|
-
try {
|
|
906
|
-
prise = prendreUnePart({ env, racine, dire, sorte: 'Tests' });
|
|
907
|
-
} catch (e) {
|
|
908
|
-
if (!(e instanceof AttenteDeLaMachine)) {
|
|
909
|
-
throw e;
|
|
910
|
-
}
|
|
911
|
-
dire(e.message);
|
|
912
|
-
return e.code;
|
|
913
|
-
}
|
|
914
|
-
try {
|
|
915
|
-
return passe(prise.env, prise.part);
|
|
916
|
-
} finally {
|
|
917
|
-
prise.rendre();
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
|
|
921
442
|
/**
|
|
922
443
|
* The places taken and the waits of the machine under <env>, as the server holds them: `{ plafond,
|
|
923
444
|
* faute, prises, attentes, circuits }` (`faute`, a value of the ceiling the poste names and the
|