Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

slothqueue: a job queue that waits until your machine can afford it

Описание и применение

slothqueue – это очередь задач, которая откладывает выполнение, пока средняя загрузка машины не опустится ниже заданного порога, тем самым защищая общую производительность на совместно используемом сервере.

Задача

Background jobs on a shared machine can degrade overall performance by consuming CPU resources, causing other users’ builds to slow down.

Результат

slothqueue successfully prevents background jobs from running when the machine is overloaded, ensuring that jobs start only when the load average is below the set ceiling. It demonstrates at‑least‑once delivery with lease reclamation, per‑job runtime limits, and visible waiting logs.

Рабочий процесс

  • Add a job to the queue with a command, priority, and optional max runtime
  • Run the queue runner with a load‑ceiling and cooldown interval
  • Runner selects highest‑priority pending job
  • Runner checks os.getloadavg()[0]; if above ceiling, sleeps and rechecks, printing the measurement
  • When load is below ceiling, runner claims the job in a transaction, records a lease, and starts it in its own process group
  • Runner enforces per‑job runtime limit by killing the entire process group if exceeded
  • Runner records exit code, updates job state, sleeps the cooldown, and repeats

Доказательства

slothqueue runs shell jobs one at a time, in priority order, and before each job it samples the machine's load average — if the machine is busy, it waits, then checks again.

Источник

The runner loop is deliberately boring: Pick the highest‑priority pending job. Read os.getloadavg()[0]. If it is at or above the ceiling, sleep one interval and go back to step 1 — printing the measurement each time so the wait is never silent.

Источник

Three jobs, one genuinely successful, one killed for running too long, one that failed on its own exit code — and none of them started until the load average came back under the ceiling.

Источник

  • Дата записи: 2026-10-22T22:11:36.911Z