Skip to content

Rework worker stats: configurable consumers, occupancy tracking - #377

Draft
neob91-close wants to merge 3 commits into
masterfrom
andrzej/p2/worker-duty-cycle-stats
Draft

Rework worker stats: configurable consumers, occupancy tracking#377
neob91-close wants to merge 3 commits into
masterfrom
andrzej/p2/worker-duty-cycle-stats

Conversation

@neob91-close

@neob91-close neob91-close commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

utilization counts only in-task time, so a worker saturated with many short tasks reads well below 100% — the between-task overhead is invisible. This broke our utilization-based autoscaling: workers scaled down under a large backlog.

The worker now also measures idle time (blocking waits for work) and reports busy + idle to a configurable STATS_CONSUMERS list, replacing the always-on stats thread. The bundled StatsThread consumer adds time_idle, time_overhead, and occupancy = 100 * busy / (busy + idle) — the busy share of attributable time; ~100 when saturated regardless of overhead, 0 when idle.

⚠️ Breaking:

  • STATS_INTERVAL removed; the periodic stats line no longer logs by default. Restore with STATS_CONSUMERS=[StatsThread(log, interval=60)].
  • StatsThread(tiger)StatsThread(log, interval); worker.StatsThread is gone, so monkey-patching it silently stops working — subclass stats.StatsConsumer and register via STATS_CONSUMERS.
  • Worker.stats_threadWorker.stats (list of consumers).

Commit 1 reworks the measurement; commit 2 redefines occupancy to exclude overhead.

@neob91-close
neob91-close force-pushed the andrzej/p2/worker-duty-cycle-stats branch from 55c6988 to f5f0b64 Compare August 4, 2026 12:46
@neob91-close neob91-close changed the title Track worker occupancy in stats Rework worker stats: configurable consumers, occupancy tracking Aug 4, 2026
@neob91-close
neob91-close force-pushed the andrzej/p2/worker-duty-cycle-stats branch from e942db4 to 3423df6 Compare August 5, 2026 15:45
@neob91-close
neob91-close force-pushed the andrzej/p2/worker-duty-cycle-stats branch from 3423df6 to 46136a7 Compare August 6, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant