You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 86365bb
Browse filesBrowse the repository at this point in the historyBrowse files
ruby: Measure worker slack and let a sample of workers exit idle
A worker that has drained the queue does not exit. `exhausted?` is
`queue_initialized? && size == 0`, and `size` counts pending plus running
across the whole build, so every worker stays online until the slowest one
finishes. That is deliberate, so a test that times out or gets requeued still
has somewhere to run.
It is not free. On a Figma permissions build of 20 workers over 141 files, two
workers ran 105 and 34 tests and stopped 62 milliseconds apart. Wall-time
profiles put roughly 22% of main thread time in the poll backoff.
Two changes.
Measurement. The worker records when its last test finished and exposes
`slack_duration`, the gap between that and leaving the queue. The minitest
adapter emits it as `minitests.queue.worker.slack`, tagged with whether the
worker held requeue duty. Emitted from the adapter, not the queue, because
ci/queue stays framework agnostic and Statsd lives under minitest/.
Control. At init each worker draws a number and compares it to
CI_QUEUE_IDLE_EXIT_PROBABILITY. Workers above the threshold keep today's
behaviour. The rest leave once they have been idle for
CI_QUEUE_IDLE_EXIT_GRACE, after the existing sleep and backoff. Defaults are
0.0 and 30, so nothing changes until the knob is set.
The draw uses Random.new rather than Kernel#rand. The global RNG is seeded from
--seed, which is identical across workers, so every worker would otherwise draw
the same number.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments