@runeditrun/rer 0.2.51 → 0.2.52
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/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.52
|
|
4
|
+
|
|
5
|
+
- **Shared job queues use one slot limit.** Every client sharing a queue directory admits against the same limit, so an older shell requesting three slots no longer holds up a five-slot queue. A live `config.json` slot limit is authoritative; otherwise the largest live client request sets the limit. Clients requesting a different limit see the queue's effective limit and configuration path. FIFO ordering, load admission and available-memory admission stay in place (#244).
|
|
6
|
+
|
|
3
7
|
## 0.2.51
|
|
4
8
|
|
|
5
9
|
- **The Run page keeps commands clear of Copy.** Command blocks wrap beside the button while there is room and below it at narrower widths. The dev sign-in hand-off page now shows the seed’s own logo, or its product name when it declares no logo (#236).
|
|
@@ -36,7 +36,7 @@ threshold when one is set, and available memory is strictly above the floor. Def
|
|
|
36
36
|
|
|
37
37
|
| Setting in config.json | Default | Environment override |
|
|
38
38
|
| --- | --- | --- |
|
|
39
|
-
| slots | max(1, min(3, floor(CPUs / 4), floor(RAM / 8 GiB))) | RER_JOBS_SLOTS |
|
|
39
|
+
| slots | max(1, min(3, floor(CPUs / 4), floor(RAM / 8 GiB))) | RER_JOBS_SLOTS (request; shared policy below) |
|
|
40
40
|
| loadThreshold | none: a fleet sets one in its own environment | RER_JOBS_LOAD_THRESHOLD |
|
|
41
41
|
| minFreeMemoryBytes | 2 GiB | RER_JOBS_MIN_FREE_MEMORY_BYTES |
|
|
42
42
|
| pollMs | 3000 | RER_JOBS_POLL_MS |
|
|
@@ -44,9 +44,20 @@ threshold when one is set, and available memory is strictly above the floor. Def
|
|
|
44
44
|
| killGraceMs | 1000 | RER_JOBS_KILL_GRACE_MS |
|
|
45
45
|
|
|
46
46
|
Put numeric settings in `$RER_JOBS_DIR/config.json` (or `~/.rer/jobs/config.json`).
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
For slots, `config.json` is authoritative and is read under the queue lock on
|
|
48
|
+
every operation, including admission: its `slots` overrides environment and
|
|
49
|
+
library requests from every client. Without a configured `slots`, the shared
|
|
50
|
+
limit is the largest slot request among live queue clients (environment, library
|
|
51
|
+
override, or hardware default). The limit and live membership are recorded in
|
|
52
|
+
`state.json` under the same lock as admission. Closing or reclaiming a dead client
|
|
53
|
+
removes its request; lowering the limit never interrupts running jobs. A client
|
|
54
|
+
whose request differs prints one line per differing effective limit, naming
|
|
55
|
+
the queue's limit and `config.json` as the way to change it. Thus an older shell
|
|
56
|
+
requesting 3 cannot block a head waiter when another live client requests 5.
|
|
57
|
+
Restart clients using older queue code before sharing this policy.
|
|
58
|
+
|
|
59
|
+
Environment overrides still take precedence for the other settings. Resource settings are
|
|
60
|
+
read when a client is created. `status` prints the shared slot limit, current load,
|
|
50
61
|
available and raw free memory, running labels/repositories/elapsed times, ordered
|
|
51
62
|
waiting jobs, and the head's admission reason. Available memory is what the OS
|
|
52
63
|
can reclaim: on macOS the free, inactive, speculative and purgeable pages from
|
|
@@ -35,7 +35,7 @@ export function ordered(jobs) {
|
|
|
35
35
|
|
|
36
36
|
// Each reason says what is running, what the limit is and how to change it.
|
|
37
37
|
export function admissionDetails(running, config, sample) {
|
|
38
|
-
if (running >= config.slots) return { code: 'slots', reason: `all job slots are in use (${running} of ${config.slots}; change
|
|
38
|
+
if (running >= config.slots) return { code: 'slots', reason: `all job slots are in use (${running} of ${config.slots}; change slots in ${config.directory}/config.json)` };
|
|
39
39
|
if (!Number.isFinite(sample.load) || !Number.isFinite(sample.availableMemoryBytes))
|
|
40
40
|
return { code: 'resources_unavailable', reason: 'this computer\'s load or available memory could not be read' };
|
|
41
41
|
if (sample.load > config.loadThreshold) return { code: 'load',
|
|
@@ -8,17 +8,29 @@ import { transaction } from './storage.mjs';
|
|
|
8
8
|
import { sampleResources } from './resources.mjs';
|
|
9
9
|
import { execute, signalExit } from './command.mjs';
|
|
10
10
|
import { stopGroup } from './processes.mjs';
|
|
11
|
+
import { sharedSlots } from './slots.mjs';
|
|
11
12
|
|
|
12
13
|
const WAIT_REPORT_INTERVAL_MS = 15_000;
|
|
13
14
|
|
|
14
15
|
export async function createQueue(options = {}) {
|
|
15
16
|
const config = await configuration(options), lifetime = await identity();
|
|
16
17
|
const sampler = options.sampler ?? sampleResources;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const member = { owner: lifetime.info, slots: config.slots, directory: config.directory };
|
|
19
|
+
let active = 0, closed = false, lastSlotNotice;
|
|
20
|
+
const mutate = async action => {
|
|
19
21
|
if (closed) throw Error('Job queue is closed');
|
|
20
|
-
|
|
22
|
+
const result = await transaction(config.directory, lifetime.info, async state => {
|
|
23
|
+
config.slots = await sharedSlots(state, member);
|
|
24
|
+
return action(state);
|
|
25
|
+
});
|
|
26
|
+
if (config.slots !== member.slots && config.slots !== lastSlotNotice) {
|
|
27
|
+
console.error(`Job queue uses ${config.slots} slots (this client requested ${member.slots}); set "slots" in ${config.directory}/config.json to change the shared limit.`);
|
|
28
|
+
lastSlotNotice = config.slots;
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
21
31
|
};
|
|
32
|
+
try { await mutate(() => {}); }
|
|
33
|
+
catch (error) { await lifetime.close(); throw error; }
|
|
22
34
|
async function reclaim(state) {
|
|
23
35
|
for (const key of ['queued', 'running']) {
|
|
24
36
|
const kept = [];
|
|
@@ -38,7 +50,7 @@ export async function createQueue(options = {}) {
|
|
|
38
50
|
const resources = await sampler();
|
|
39
51
|
const describe = ({ command, membership, owner: { token, socket, ...owner }, ...job }) => ({ ...job, owner,
|
|
40
52
|
elapsedSeconds: Math.floor((Date.now() - (job.startedAt ?? job.enqueuedAt)) / 1000) });
|
|
41
|
-
return { running: state.running.map(describe), queued: ordered(state.queued).map(describe), resources, config,
|
|
53
|
+
return { running: state.running.map(describe), queued: ordered(state.queued).map(describe), resources, config: { ...config },
|
|
42
54
|
admissionReason: state.queued.length ? admissionDetails(state.running.length, config, resources)?.reason ?? 'ready' : 'queue empty' };
|
|
43
55
|
});
|
|
44
56
|
}
|
|
@@ -128,6 +140,9 @@ export async function createQueue(options = {}) {
|
|
|
128
140
|
}
|
|
129
141
|
return { config, run, status, drain, async close() {
|
|
130
142
|
if (active) throw Error('Cannot close a queue with active jobs');
|
|
131
|
-
|
|
143
|
+
if (closed) return;
|
|
144
|
+
closed = true;
|
|
145
|
+
try { await transaction(config.directory, lifetime.info, state => sharedSlots(state, member, false)); }
|
|
146
|
+
finally { await lifetime.close(); }
|
|
132
147
|
} };
|
|
133
148
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { alive } from './identity.mjs';
|
|
3
|
+
import { readJson } from './storage.mjs';
|
|
4
|
+
|
|
5
|
+
// Called only under the queue's transaction lock. Config is authoritative;
|
|
6
|
+
// without it every client uses the largest request from the same live members.
|
|
7
|
+
export async function sharedSlots(state, member, register = true) {
|
|
8
|
+
const members = [];
|
|
9
|
+
for (const item of state.slotMembers ?? []) {
|
|
10
|
+
if (item.owner.token !== member.owner.token && await alive(item.owner)) members.push(item);
|
|
11
|
+
}
|
|
12
|
+
if (register) members.push(member);
|
|
13
|
+
const disk = await readJson(join(member.directory, 'config.json'), {});
|
|
14
|
+
if (disk.slots !== undefined && (!Number.isInteger(disk.slots) || disk.slots < 1))
|
|
15
|
+
throw Error('Invalid job queue slots in config.json');
|
|
16
|
+
state.slotMembers = members;
|
|
17
|
+
state.slots = disk.slots ?? Math.max(1, ...members.map(item => item.slots));
|
|
18
|
+
return state.slots;
|
|
19
|
+
}
|