Answer principles round 1: 0 🔴, 4 🟡 (0 misread); exempt only a bare docker under run-heavy with no PATH of its own, drop the stale item citation, unit-test the slot share in MiB, place the limits by the subcommand's index; also a named Option, exit 126, clearer names and the launcher's import order
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""How much of the machine's memory is available, as /proc/meminfo's MemAvailable and MemTotal state it, whether at least ROOM_SHARE of it is available, which leaves room for a worker, and each heavy slot's share of the rest."""
|
||||
"""How much of the machine's memory is available, as /proc/meminfo's MemAvailable and MemTotal state it. A worker starts while at least ROOM_SHARE of it is available. The rest is split across the heavy slots, as the memory limit run-heavy gives each container."""
|
||||
import dataclasses
|
||||
import pathlib
|
||||
import re
|
||||
@@ -17,9 +17,9 @@ class Memory:
|
||||
def has_room(self) -> bool:
|
||||
return self.available >= ROOM_SHARE * self.total
|
||||
|
||||
def slot_share(self, slots: int) -> str:
|
||||
"""The memory each heavy slot's containers may take, as docker writes a size: what ROOM_SHARE leaves, split evenly across the slots."""
|
||||
return f"{int(self.total * (1 - ROOM_SHARE)) // slots // 1024}m"
|
||||
def slot_share(self, slots: int) -> int:
|
||||
"""The memory limit, in MiB, that run-heavy gives each container a slot's command makes: what ROOM_SHARE leaves, split evenly across the slots."""
|
||||
return int(self.total * (1 - ROOM_SHARE)) // slots // 1024
|
||||
|
||||
|
||||
def parsed(meminfo: str) -> Memory | None:
|
||||
|
||||
Reference in New Issue
Block a user