load based sleep
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Markus Bergholz 63cc3ff133 init 11 months ago
Makefile init 11 months ago
README.md init 11 months ago
lbsleep.c init 11 months ago


load based sleep

Often you use sleep when you’re waiting for some other programm to be finished. But the time how long the other programm needs depends on the system load. When the system is heavy busy (avg load > 5 for example), your MariaDB Docker container needs more seconds to be finished.
lbsleep sleeps n seconds, where n depends on the avg load of now.

command load avg sleep time in sec
lbsleep 0.00 1
lbsleep 5 0.00 0.5
lbsleep 0.56 5.6
lbsleep 3.24 32.4
lbsleep 2 3.24 6.48
lbsleep 11.53 100

Basically it calculates two values and uses the lowest of both.

calculation operation
Maximal sleep time MAX_SLEEP_FACTOR * BASE
load base sleep time max(avg_loag, MIN_SLEEP_FACTOR) * BASE
real sleep time minimal value of the previous results
factor value variable
BASE 10 optional first input argument


lbsleep sleeps for

  • at least 1/10 of BASE value
  • no more than 10 times of BASE value