ecluse
Safe HaskellNone
LanguageGHC2021

Ecluse.Rts

Description

Resolve and apply capabilities, allocation area and heap ceiling from runtime observations. Applying allocation or heap flags re-executes the process once because GHC exposes no setter.

Synopsis

Applying the resolved posture at boot

applyRuntimePosture :: (Text -> IO ()) -> (Text -> IO ()) -> RuntimeOverrides -> IO EffectiveRuntimePlan Source #

Resolve and apply the runtime plan at boot. It never aborts, and returns the plan the RTS runs with.

The pure resolution core

data RtsPosture Source #

The RTS posture the process is actually running with, read at boot by currentRtsPosture.

Constructors

RtsPosture 

Fields

Instances

Instances details
Show RtsPosture Source # 
Instance details

Defined in Ecluse.Rts

Eq RtsPosture Source # 
Instance details

Defined in Ecluse.Rts

data RuntimeOverrides Source #

The runtime keys the resolution reads. An unset field falls to the next rung, and roCoresCeiling caps the last.

Instances

Instances details
Show RuntimeOverrides Source # 
Instance details

Defined in Ecluse.Rts

Eq RuntimeOverrides Source # 
Instance details

Defined in Ecluse.Rts

data Provenance Source #

Where a resolved value came from, for the boot log's provenance clause.

Constructors

FromConfig

Explicit Écluse configuration (cores / maxHeapBytes).

FromCgroup

Derived from the cgroup CPU quota, or from memory.max on the heap axis.

FromCgroupMemory

Bounded by what the cgroup memory limit can feed, for want of a CPU quota.

FromCoresCeiling

Capped at coresCeiling, with no cgroup limit of either kind in force.

FromHeapCeiling

Fitted to a heap ceiling from config, or from GHCRTS with no cgroup memory limit in force.

FromRts

Left as the RTS resolved it (baked defaults plus any operator GHCRTS).

Instances

Instances details
Show Provenance Source # 
Instance details

Defined in Ecluse.Rts

Eq Provenance Source # 
Instance details

Defined in Ecluse.Rts

data RuntimePlan Source #

The resolved runtime posture, each axis with its provenance. A FromRts entry leaves the live posture alone.

Instances

Instances details
Show RuntimePlan Source # 
Instance details

Defined in Ecluse.Rts

Eq RuntimePlan Source # 
Instance details

Defined in Ecluse.Rts

provenanceClause :: Provenance -> Text Source #

The provenance as a bare clause, for consumers composing their own log lines.

resolveRuntimePlan :: RuntimeOverrides -> CgroupLimits -> RtsPosture -> RuntimePlan Source #

Resolve capabilities down the four-rung ladder, the heap ceiling from config, else the cgroup limit, else GHCRTS, and an area to fit.

deriveMaxHeapBytes :: Int -> Int -> Int Source #

The heap ceiling for a memory limit, floored at half of it. The nursery counts inside -M (GHC 9.6 and later).

deriveAllocAreaBytes :: Int -> Int -> Int Source #

The per-capability allocation area: an eighth of the memory limit across the capabilities, in whole MiB from 4 to 64.

requiredRtsFlags :: RtsPosture -> RuntimePlan -> [Text] Source #

The GHCRTS flags the plan needs beyond the live posture. A FromRts entry is the live posture, so it adds none.

The effective plan (desired reconciled with observed)

data EffectiveAxis a Source #

One axis after the boot applied the plan. An apply can fail, so sizing never reads the desired side alone.

Constructors

EffectiveAxis 

Fields

Instances

Instances details
Show a => Show (EffectiveAxis a) Source # 
Instance details

Defined in Ecluse.Rts

Eq a => Eq (EffectiveAxis a) Source # 
Instance details

Defined in Ecluse.Rts

data EffectiveRuntimePlan Source #

The runtime plan reconciled with the live RTS: desired/observed axes, plus observed-only datapoints for sizing.

Constructors

EffectiveRuntimePlan 

Fields

axEnforced :: Eq a => EffectiveAxis a -> Bool Source #

Whether the live RTS backs an axis (desired and observed agree).

reconcileRuntimePlan :: CgroupLimits -> RuntimePlan -> RtsPosture -> EffectiveRuntimePlan Source #

Pair the desired plan with the posture the RTS reports, axis by axis.

appliedRuntimePlan :: CgroupLimits -> RuntimePlan -> RtsPosture -> EffectiveRuntimePlan Source #

The effective plan a successful apply would produce, for check-config, which applies nothing.

effectiveCapabilities :: EffectiveRuntimePlan -> (Int, Provenance) Source #

The live capability count, which budgets must not exceed. An unenforced count reads as FromRts.

effectiveHeapCeiling :: EffectiveRuntimePlan -> (Maybe Int, Provenance) Source #

The sizing ceiling: the tighter of desired and observed, so an observed -M below the plan binds.

renderEffectivePosture :: EffectiveRuntimePlan -> [Text] Source #

The boot log's posture lines, one decision per line with its provenance.

renderPostureWarnings :: EffectiveRuntimePlan -> [Text] Source #

The boot log's posture warnings: an axis the RTS is not enforcing, and a count no entitlement backs.