From 083365143e844827599d9b0a78204b3a05df460c Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 29 Nov 2016 17:47:42 +0100 Subject: bitbake: cooker process: fire heartbeat event at regular time intervals The intended usage is for recording current system statistics from /proc in buildstats.bbclass during a build and for improving the BB_DISKMON_DIRS implementation. All other existing hooks are less suitable because they trigger at unpredictable rates: too often can be handled by doing rate-limiting in the event handler, but not often enough (for example, when there is only one long-running task) cannot because the handler does not get called at all. The implementation of the new heartbeat event hooks into the cooker process event queue. The process already wakes up every 0.1s, which is often enough for the intentionally coarse 1s delay between heartbeats. That value was chosen to keep the overhead low while still being frequent enough for the intended usage. If necessary, BB_HEARTBEAT_EVENT can be set to a float specifying the delay in seconds between these heartbeat events. (Bitbake rev: 7cf22ea057d28c54bd98dc1ab7a43402a29ff1f5) Signed-off-by: Patrick Ohly Signed-off-by: Richard Purdie --- bitbake/lib/bb/event.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'bitbake/lib/bb/event.py') diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index 6f1cb101fc..cacbac8f56 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py @@ -48,6 +48,16 @@ class Event(object): def __init__(self): self.pid = worker_pid + +class HeartbeatEvent(Event): + """Triggered at regular time intervals of 10 seconds. Other events can fire much more often + (runQueueTaskStarted when there are many short tasks) or not at all for long periods + of time (again runQueueTaskStarted, when there is just one long-running task), so this + event is more suitable for doing some task-independent work occassionally.""" + def __init__(self, time): + Event.__init__(self) + self.time = time + Registered = 10 AlreadyRegistered = 14 -- cgit v1.2.3-54-g00ecf