Expand description
Memory budgets: the mechanism in the core, the policy in the batch engine.
A budget is shared by many inputs (a batch’s admission pool, its
dependency pool). The core never asks it directly: every charge an
input’s crate::limits::Meter grants is also booked here, as a
Permit that rides inside the charge, so the budget sees everything
every input holds, and gets it back when the last owner drops it. The
request never blocks: blocking inside a rayon pool can deadlock, so a
batch engine does any waiting of its own before it hands work to the
pool (plan section 4.1 lists what the core guarantees it).
A decoder writes through a DecodeBuf, which charges the input’s meter
before every growth, so no decoded byte exists unpaid, a refused growth
allocates nothing, and a dropped buffer (a failed decode) returns its
charge.
Owner: the scaffold (implemented); package C maintains it.
Structs§
- Alloc
Error - A host allocator refusal, kept by value without a heap-owned source.
- Budget
Exceeded - A refused reservation.
- Counting
- A non-blocking budget with a fixed limit, counting what is alive.
- Decode
Buf - A decoder’s output buffer that pays before it grows.
- Permit
- Bytes reserved from a budget, returned when the permit drops.
- Unbounded
- A budget that never refuses: UnityPy’s behaviour, and the default.
Enums§
- Reservation
- Which kind of load a charge belongs to, so a refusal says which pool refused (plan section 4.1).
Constants§
- OWNER_
COST - What wrapping a buffer in
Bytesallocates besides the buffer: the shared owner recordBytes::from_ownerboxes (the buffer, its charge and a reference count), with room to spare.
Traits§
- Memory
Budget - A source of permits.
- Permit
Home - Where a permit returns its bytes. The same contract as
MemoryBudget: called under core locks, so it must not block or call the core.
Functions§
- charged_
bytes bufasBytesthat carrycharge, which must already coverbuf’s allocation: the owner record is charged first (OWNER_COST), and the whole charge returns when the last slice drops, whoever holds it.