ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Admission.Brake

Description

The memory budget's feedback: how one sample of the collector and the heap moves the budget.

After each major collection the brake measures the live data outside the charges, so the budget may grow until charges and that measured remainder reach the live ceiling. The ceiling also leaves room under the heap's overflow point for the largest request seen lately, which may run past the budget. The brake halves the budget when the collector takes too much of the CPU or the heap nears overflow, and grows it back in small steps while the collector stays calm. Ecluse.Rts.Sampler feeds it.

Synopsis

The marks

data BrakeMarks Source #

The brake's thresholds. Shares are thousandths of the process's CPU time over the sampler's window.

Constructors

BrakeMarks 

Fields

Instances

Instances details
Show BrakeMarks Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Brake

Eq BrakeMarks Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Brake

defaultBrakeMarks :: BrakeMarks Source #

Above half the CPU the collector is thrashing, the point where Go's memory limit stops helping. A loaded proxy with no memory pressure spends 20 to 34% of its CPU in the collector.

One step

data BrakeState Source #

The brake's memory between samples.

Constructors

BrakeState 

Fields

Instances

Instances details
Show BrakeState Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Brake

Eq BrakeState Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Brake

initialBrakeState :: BrakeBounds -> BrakeState Source #

Start at the boot budget, with nothing measured yet.

data GcSample Source #

One sample's readings. A missing reading leaves its rule out of this step.

Constructors

GcSample 

Fields

Instances

Instances details
Show GcSample Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Brake

Eq GcSample Source # 
Instance details

Defined in Ecluse.Core.Server.Admission.Brake

brakeStep :: BrakeMarks -> BrakeBounds -> BrakeState -> GcSample -> BrakeState Source #

Move the budget by one sample: pressure halves it at most once per cooldown, a lower ceiling cuts it at once, and only a calm stretch grows it. It stays between the floor and the ceiling.

Reading the collector

data CollectorReading Source #

The collector's cumulative counters at one sample.

Constructors

CollectorReading 

Fields

gcSharePermille :: CollectorReading -> CollectorReading -> Maybe Int Source #

The collector's share of the CPU between two readings, or Nothing when no CPU passed.

data SampleWindow Source #

The recent readings the GC share spans, newest first, and the capacity of that span.

newSampleWindow :: Int -> SampleWindow Source #

An empty window that spans the given number of sampling periods.

windowSample :: SampleWindow -> Maybe CollectorReading -> Int -> Int -> Maybe Int -> (GcSample, SampleWindow) Source #

Fold one reading into the window and form the brake's sample. Live data counts only after a major collection since an earlier reading, and a missing reading (no -T) leaves the collector's rules out.