agents: always write the memory cap, infinity for none
The cap file was removed for a cap of `infinity` or a RAM percentage, so the boot check warned on every start of such an agent, for a legitimate config. The file is now written on every start: - a size: its byte count, as before; - `infinity`: the literal `infinity`. The generators set no JSC heap ceiling and no subagent MemoryHigh=, and the boot check is quiet; - a percentage: resolved on the host the way systemd resolves MemoryMax=N% for the container@ unit. That is permyriad (at most two decimals, at most 100%) of sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE), rounded down to a page; - a value systemd ignores (zero, over 100%, more than two decimals, unparseable) leaves the unit uncapped, so it is `infinity`. The file is missing only when hive-c0re can't tell the cap: the limits file and the kept drop-in are both unreadable, or a percentage meets an unknown host memory size. The boot check now warns only for a missing file or a first line that is neither a byte count nor `infinity`. Part of #5081 (slice S0-2).
This commit is contained in:
parent
57955a6c53
commit
eaca3c4eb3
5 changed files with 253 additions and 67 deletions
|
|
@ -404,7 +404,7 @@ Contents:
|
|||
`lifecycle::write_dropins` generates the systemd drop-in, **not** injected
|
||||
into the container — these are host-side caps on the container, so
|
||||
the capped party never sets them. It sees only the resulting memory cap,
|
||||
as a byte count in its runtime dir (below). Fallback is per *field*:
|
||||
as a byte count or `infinity` in its runtime dir (below). Fallback is per *field*:
|
||||
an absent file, absent agent, or absent field falls back to the
|
||||
hive-wide `services.hyperhive.c0re.agentCpuQuota` / `agentMemoryMax`,
|
||||
so an agent can override only its memory and still track the hive
|
||||
|
|
@ -510,8 +510,9 @@ containers can't start.
|
|||
- `/run/hyperhive/agents/<name>/mcp.sock` — per-agent socket
|
||||
(bind-mounted into the container as `/run/hive/mcp.sock`).
|
||||
- `/run/hyperhive/agents/<name>/memory-max-bytes` — the agent's effective
|
||||
`MemoryMax=` in bytes, written by `lifecycle::write_dropins` before every
|
||||
start (absent when the cap is `infinity` or a RAM percentage). The
|
||||
`MemoryMax=` as a byte count (a percentage resolved against the host's
|
||||
physical memory) or `infinity`, written by `lifecycle::write_dropins`
|
||||
before every start. Absent only when hive-c0re can't tell the cap. The
|
||||
container reads it at boot as `/run/hive/memory-max-bytes`
|
||||
(`nix/agent-modules/memory-cap.nix`).
|
||||
|
||||
|
|
|
|||
|
|
@ -453,17 +453,21 @@ rebuild, so changes take effect on the next lifecycle op without
|
|||
requiring a host rebuild.
|
||||
|
||||
The container can't read its own cap, so `write_dropins` also writes the
|
||||
effective `MemoryMax=` in bytes into the agent's runtime dir
|
||||
(`/run/hive/memory-max-bytes` inside). At boot the container derives two
|
||||
values from it: `BUN_JSC_forceRAMSize` (75%, claude-code's heap ceiling)
|
||||
and `MemoryHigh=` on `hive-subagent-daemon` (two thirds). Neither is in the
|
||||
agent's build, so a changed cap reaches them at the next container start
|
||||
without a rebuild. A cap of `infinity` or a RAM percentage sets neither.
|
||||
When hive-c0re keeps the last drop-in because it can't read the overrides
|
||||
file, the file carries that drop-in's `MemoryMax=`. A missing or malformed
|
||||
file sets neither value, and `hyperhive-memory-cap-check.service` logs a
|
||||
warning naming the path in the container's journal at boot. The
|
||||
container's `MemoryMax=` still applies.
|
||||
effective `MemoryMax=` into the agent's runtime dir
|
||||
(`/run/hive/memory-max-bytes` inside) before every start: a byte count, or
|
||||
`infinity` for no cap. A percentage becomes bytes the way systemd resolves
|
||||
it, as that share of the host's physical memory rounded down to a page. A
|
||||
value systemd ignores (zero, over 100%) is `infinity`. When hive-c0re keeps
|
||||
the last drop-in because it can't read the overrides file, the file carries
|
||||
that drop-in's `MemoryMax=`.
|
||||
|
||||
At boot the container derives two values from a byte count:
|
||||
`BUN_JSC_forceRAMSize` (75%, claude-code's heap ceiling) and `MemoryHigh=` on
|
||||
`hive-subagent-daemon` (two thirds). Neither is in the agent's build, so a
|
||||
changed cap reaches them at the next container start without a rebuild.
|
||||
`infinity` sets neither. A missing or malformed file sets neither as well, and
|
||||
`hyperhive-memory-cap-check.service` logs a warning naming the path in the
|
||||
container's journal. The container's `MemoryMax=` still applies.
|
||||
|
||||
The same drop-in carries `CPUWeight=` / `IOWeight=` from
|
||||
`agentCpuWeight` / `agentIoWeight`. Those are a different kind of
|
||||
|
|
|
|||
Loading…
Reference in a new issue