pub enum SizeClass {
Mib512,
Mib1024,
Mib2048,
Mib4096,
Mib8192,
}Expand description
One of the five documented size classes.
Closed, so an off-table memory figure is not a value that exists — the Python
client’s S2 runtime check (sizing.py:95 size_class_for) becomes S1 for every
caller who has a SizeClass in hand. SizeClass::from_baseline_mib is the one
boundary where a bare integer still has to be judged, which is where TRAP-10
lives.
The variants are named for their baseline because that is the number the caller
writes into minimumMemoryInMiB; the peak is deliberately not in any name, since
naming both would suggest a caller gets to pick them independently.
Variants§
Implementations§
Source§impl SizeClass
impl SizeClass
Sourcepub const DEFAULT: SizeClass = SizeClass::Mib2048
pub const DEFAULT: SizeClass = SizeClass::Mib2048
The platform’s own default, and ours.
Deliberately not the smallest class, and the reason is the CEILING: picking
512 gives the guest a hard 2 GiB total — provisioned from the start, fixed
for the whole run, nothing resizes past it — and a real test suite breaches
it. Guest swap is absent (SwapTotal: 0 kB), so there is no paging phase to
absorb the mistake — pressure goes straight to the OOM killer. The default’s
job is a ceiling that survives a real test suite, and 8 GiB does.
Sourcepub const ALL: [SizeClass; 5]
pub const ALL: [SizeClass; 5]
Every class, smallest first, in SIZE_CLASSES order.
Sourcepub fn from_baseline_mib(mib: u32) -> Result<SizeClass, Error>
pub fn from_baseline_mib(mib: u32) -> Result<SizeClass, Error>
The class minimumMemoryInMiB = mib selects (TRAP-10).
Rejects anything not in the table rather than snapping to a neighbour: an off-table request has two plausible readings that differ in both memory and rate, and we have measured neither. This is the boundary a figure from a CLI flag or a config file crosses.
Sourcepub fn from_request(
cpus: Option<f64>,
memory_mib: Option<u32>,
) -> Result<SizeClass, Error>
pub fn from_request( cpus: Option<f64>, memory_mib: Option<u32>, ) -> Result<SizeClass, Error>
The smallest class whose baseline covers a resource request (BIND-14).
A harness is handed CPUs and memory as requests (Harbor’s cpus and memory_mb). The
baseline is the covering figure because it is what is billed and always present; the
peak above it is provisioned too, but choosing by peak would hand a 2-vCPU task the
0.5-vCPU class. None or zero on an axis is no requirement on it; with no requirement on
either the answer is SizeClass::DEFAULT, not the smallest class, for the reason
DEFAULT gives. A request no class covers is an invalid-argument refusal naming the
largest class, and so is a CPU figure that is not a finite non-negative number.
Sourcepub fn row(self) -> &'static SizeRow
pub fn row(self) -> &'static SizeRow
This class’s row of the documented table.
The one reader of SIZE_CLASSES for a known class, which is what keeps
every accessor below reading data rather than deriving it.
Sourcepub fn baseline_mib(self) -> u32
pub fn baseline_mib(self) -> u32
The value to send as minimumMemoryInMiB. Billed per running second.
Sourcepub fn peak_mib(self) -> u32
pub fn peak_mib(self) -> u32
What the guest reports as MemTotal: the provisioned ceiling, present from
the start of the run.
Read from the table. Never baseline_mib() * 4 — see the module docs.
Sourcepub fn headroom_mib(self) -> u32
pub fn headroom_mib(self) -> u32
The static headroom above the baseline: peak minus baseline, both read from this class’s table row.
Fixed at provision time — the headroom is always present, never granted by a
scaling event — and usage inside it is billed by consumption. Computed as a
difference of two table values, never as baseline * 3: the 4x regularity
is AWS’s, not ours, and a row that breaks it must be reported as written
(TRAP-13, same discipline as SizeClass::peak_mib).
Sourcepub fn baseline_vcpu(self) -> f64
pub fn baseline_vcpu(self) -> f64
Billed per running second, alongside SizeClass::baseline_mib.
Sourcepub fn peak_vcpu(self) -> f64
pub fn peak_vcpu(self) -> f64
The provisioned vCPU ceiling, present from the start. Read from the table.
Sourcepub fn baseline_gb(self) -> f64
pub fn baseline_gb(self) -> f64
The figure a GB-second rate multiplies. Always the baseline, never the peak (COST-5).
Trait Implementations§
impl Copy for SizeClass
Source§impl Display for SizeClass
One line naming both numbers, for an error message or a CLI.
impl Display for SizeClass
One line naming both numbers, for an error message or a CLI.
Both numbers or neither: naming only the peak invites someone to budget for memory they will not be billed for, and naming only the baseline invites a memory-pressure test written against a ceiling four times lower than the one the guest enforces.
impl Eq for SizeClass
impl StructuralPartialEq for SizeClass
Auto Trait Implementations§
impl Freeze for SizeClass
impl RefUnwindSafe for SizeClass
impl Send for SizeClass
impl Sync for SizeClass
impl Unpin for SizeClass
impl UnsafeUnpin for SizeClass
impl UnwindSafe for SizeClass
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more