pub struct ResourceLimits {
pub memory_mb: u32,
pub cpu_millis: u32,
pub memory_request_mb: Option<u32>,
pub cpu_limit_millis: Option<u32>,
pub pids_max: Option<u32>,
pub scratch_floor_mb: Option<u32>,
}Expand description
Hard resource caps enforced by containerd/cgroups at runtime.
Fields§
§memory_mb: u32Maximum RAM the container may allocate, in MiB. The container is OOM- killed if it exceeds this.
A ceiling, not a request: setting it generously is the safe
direction here and the unschedulable direction for placement, so
schedulers must read WorkloadSpec::memory_request_mb instead of
this field. (cpu_millis below is the opposite — a request by
definition — which is why the two are not symmetric.)
cpu_millis: u32CPU request in millicores (k8s convention): 1000 = one full core,
250 = .25 CPU. Unlike a Docker relative weight this is an
allocatable quantity a bin-packer can subtract from a node’s budget.
0 means “no declared request” — the workload gets the node’s default
share. Backends that speak a relative weight derive it via
ResourceLimits::cpu_shares.
It is not a ceiling. A request answers “what share of a contended
node is mine”; nothing here says “stop at this much”. A workload
declaring 250m must still be able to burst to the whole box when the
box is idle. The hard ceiling is optional and rides
Self::cpu_limit_millis — R885-B5 / W344 Finding 5, filed after this
field was rendered into a cgroup cpu.max and throttled four live
workloads to a quarter core apiece.
memory_request_mb: Option<u32>Memory request in MiB — what a scheduler must find free on a node,
separate from the Self::memory_mb ceiling. Read via
WorkloadSpec::memory_request_mb, which falls back to the ceiling.
cpu_limit_millis: Option<u32>Optional hard CPU ceiling in millicores — the mirror image of
memory_request_mb: Self::cpu_millis is the request, this is the
limit. Read via WorkloadSpec::cpu_limit_millis; 0 means none.
pids_max: Option<u32>Hard process-count ceiling — cgroup v2 pids.max. Read via
WorkloadSpec::pids_limit, which falls back to DEFAULT_PIDS_MAX
rather than to “unbounded”.
scratch_floor_mb: Option<u32>A floor on the microVM scratch disk in MiB — the smallest workspace
this workload is willing to be given. Note the direction: the other
limits here are ceilings a backend enforces downward, this is a floor a
backend raises up to, and floor is in the name for exactly that
reason (R885-T6 deleted ephemeral_storage_mb because it was documented
as a cap and read as a floor). Read via WorkloadSpec::scratch_floor_mb.
Implementations§
Source§impl ResourceLimits
impl ResourceLimits
The Docker/OCI relative CPU weight (cpu.shares, where 1024 ≈ one
core) equivalent to this millicore request. The containerd and docker
backends express CPU as a weight rather than a millicore request, so
they derive it here instead of storing shares: 1000m ⇒ 1024.
Trait Implementations§
Source§impl Clone for ResourceLimits
impl Clone for ResourceLimits
Source§impl Debug for ResourceLimits
impl Debug for ResourceLimits
Source§impl<'de> Deserialize<'de> for ResourceLimits
impl<'de> Deserialize<'de> for ResourceLimits
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ResourceLimits
Source§impl PartialEq for ResourceLimits
impl PartialEq for ResourceLimits
Source§impl Serialize for ResourceLimits
impl Serialize for ResourceLimits
impl StructuralPartialEq for ResourceLimits
Source§impl TS for ResourceLimits
impl TS for ResourceLimits
Source§type WithoutGenerics = ResourceLimits
type WithoutGenerics = ResourceLimits
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or (). The only requirement for these dummy types is that
EXPORT_TO must be None. Read moreSource§type OptionInnerType = ResourceLimits
type OptionInnerType = ResourceLimits
std::option::Option<T>, then this associated type is set to T.
All other implementations of TS should set this type to Self instead.Source§fn docs() -> Option<String>
fn docs() -> Option<String>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§fn decl_concrete(cfg: &Config) -> String
fn decl_concrete(cfg: &Config) -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl(cfg: &Config) -> String
fn decl(cfg: &Config) -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline(cfg: &Config) -> String
fn inline(cfg: &Config) -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened(cfg: &Config) -> String
fn inline_flattened(cfg: &Config) -> String
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<PathBuf>
fn output_path() -> Option<PathBuf>
T should be exported, relative to the output directory.
The returned path does not include any base directory. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
fn dependencies(cfg: &Config) -> Vec<Dependency>where
Self: 'static,
Source§fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export_all. Read moreSource§fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
fn export_all(cfg: &Config) -> Result<(), ExportError>where
Self: 'static,
TS::export. Read moreSource§fn export_to_string(cfg: &Config) -> Result<String, ExportError>where
Self: 'static,
fn export_to_string(cfg: &Config) -> Result<String, ExportError>where
Self: 'static,
Auto Trait Implementations§
impl Freeze for ResourceLimits
impl RefUnwindSafe for ResourceLimits
impl Send for ResourceLimits
impl Sync for ResourceLimits
impl Unpin for ResourceLimits
impl UnsafeUnpin for ResourceLimits
impl UnwindSafe for ResourceLimits
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.