Skip to main content

SizeClass

Enum SizeClass 

Source
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§

§

Mib512

§

Mib1024

§

Mib2048

§

Mib4096

§

Mib8192

Implementations§

Source§

impl SizeClass

Source

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.

Source

pub const ALL: [SizeClass; 5]

Every class, smallest first, in SIZE_CLASSES order.

Source

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.

Source

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.

Source

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.

Source

pub fn baseline_mib(self) -> u32

The value to send as minimumMemoryInMiB. Billed per running second.

Source

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.

Source

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).

Source

pub fn baseline_vcpu(self) -> f64

Billed per running second, alongside SizeClass::baseline_mib.

Source

pub fn peak_vcpu(self) -> f64

The provisioned vCPU ceiling, present from the start. Read from the table.

Source

pub fn baseline_gb(self) -> f64

The figure a GB-second rate multiplies. Always the baseline, never the peak (COST-5).

Source

pub fn peak_gb(self) -> f64

The peak in GB, for a report that shows the caller what the guest will say.

Trait Implementations§

Source§

impl Clone for SizeClass

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SizeClass

Source§

impl Debug for SizeClass

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SizeClass

Source§

impl Hash for SizeClass

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SizeClass

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SizeClass

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.