Skip to content

Latest commit

 

History

History
298 lines (195 loc) · 7.93 KB

internals.md

File metadata and controls

298 lines (195 loc) · 7.93 KB

Runq Flagman

Overall

runq flagman is a long-living, supervised process which only monitors the system runq and ensures actions are taken when conditions are met.

By design, the process runs as high priority and avoids communicating with other processes.

runq flagman can also take its own scheduling roundtrip time into a factor (F5) to speed up the detection of system overload. This is done by taking timestamps when it is off and on the scheduler to check if there is a time leap. If the gap is large enough that is a sign that VM has very limited resources on scheduling.

Terminology

Term Definition
Runq The length of beam system run_queue, checked periodly, see T1 and T2.
Scheduler Number of Online schedulers.
Credits Gain credits when runq is under limit, lose credits when runq is over limit.
Priority Group Process could join/leave prioriy groups. Load contol takes different actions when conditions are meet.
Overloaded State when credits runs out. System is overloaded and action must be taken.
Warm State when system is losing/gaining credits, a middle state preventing system is shifting between cold and overloaded
Cold State when system is full of credits
Flag Regisered process name when system is overloaded
Actions Actions to take to cool down the system. Action is taken by either flagman or API caller

Actions to take:

Control the flag

  • ensure the flag is rasied when system is .
  • ensure the flag is cleared when system is cold

Brutal kill processes in low (<= F3) priority group in either of any conditions listed below

  1. flag is rasied
  2. credits left percentage blow F4

Caller get scheduled out for a limited amount of time if the system is overloaded

see load_ctl:maydelay

Caller is back on scheduler when flag is cleared.

TODO Caller could be scheduled out when the system is warm as well?

config parameters

parm name type default comments
F0 boolean() true Set it to false to disable the load control function. To reenable, you should call load_ctl:restart_runq_flagman/0.
F1 integer() 8 scheduler multipler, runq is overlimit when runq > scheduler * F1
F2 float() 0.8 scheduler utilization limit for increasing credits
F3 integer() 2 Priority threshold for killing processes in priority group forcefully.
F4 integer() < 100 50 credits left percentage.
F5 integer() 0 Scheduler turnaround time threshold (in ms) for extra credits loss. 0 is off
T1 integer() 3000 (ms) Regular runq check interval, see also T2
T2 integer() 1000 (ms) runq check interval when it is overlimit. See F1
C2 integer() 3 Cooldown credits.

state machine

img

Memory Flagman

Similar to Runq Flagman, Memory Flagman monitors the system memory usage every T1 from

  • /proc/meminfo
  • sys/fs/cgroup

Once it is over threshold F1, it rasies the flag and alarm.

config parameters

parm name type default comments
F0 boolean() true Set it to false to disable the flagman. To reenable, you should call load_ctl:restart_mem_flagman/0.
F1 float() 0.75 memory threshold when flag should be raised
T1 integer() 1000 Check interval in ms

KILL [Dropped Idea] runq monitor

The main reason I drop this idea is that there seems no any benefit to make it a gen_statm because it should not handle any calls from other processes to minimize any undesired workload and let it be standalone.

API

active check system is overloaded

fun is_overload()-> boolean()

passive check

state machine

img