Expand description
Budget shares and the one shared accounting pool — ADR 0073 §2 made executable.
The budget resolved at boot (memory_budget, ADR 0073 §1) is divided into
named shares by a single allocation policy. The big memory consumers
pre-size their structures from those shares and report live usage into
one shared accounting pool.
Per-subsystem caps without shared accounting are explicitly rejected by the ADR: each subsystem stays individually “within limits” while the sum kills the process (OOM by summation). One pool, one total.
The invariant that makes the pool meaningful is
Σ(shares) ≤ budget
It holds by construction: every share is (budget / 10_000) * basis_points
and the policy’s basis points sum to at most 10_000. Boot asserts both
halves of that statement rather than trusting the arithmetic.
What this module is not: it does not enforce admission. A pool over its
share is visible in red.stats and nothing more — enforcement is the next
slice (ADR 0073 §4). Reporting is therefore free of policy: a plain relaxed
atomic per pool, no allocation, no lock.
Structs§
- Budget
Share Policy - The single allocation policy: named fractions per pool, profile-adjustable.
- Budget
Shares - The resolved per-pool shares of one process budget.
- Memory
Accounting - The one shared accounting pool: fixed shares, live usage.
- Memory
Enforcement Snapshot - Process-level enforcement counters surfaced by
red.stats. - Pool
Usage - One pool’s row in the shared accounting.
Enums§
- Memory
Pool - The big memory consumers that receive a slice of the budget.
Constants§
- BASIS_
POINTS_ PER_ WHOLE - Denominator of the policy fractions. Shares are expressed in basis points (parts per ten thousand) so the whole policy is integer arithmetic — no float rounding standing between the budget and the invariant.
- MEMORY_
POOLS - Every pool, in the order
red.statsreports them. - MEMORY_
POOL_ COUNT - Number of pools. Arrays are indexed by
MemoryPool::index. - PAGE_
CACHE_ PAGE_ SIZE_ BYTES - Fixed page size the page-cache share is divided by to obtain a slot count. Pages are fixed size → slots are fixed size → the arena is preallocated.