@@ -282,10 +282,11 @@ python runqueue_stats () {
if not system_stats and isinstance(e, (bb.runqueue.sceneQueueTaskStarted, bb.runqueue.runQueueTaskStarted)):
system_stats = buildstats.SystemStats(d)
d.setVar('_buildstats_system_stats', system_stats)
- if system_stats:
+ if system_stats and isinstance(e, (bb.event.HeartbeatEvent, bb.event.BuildCompleted)):
# Ensure that we sample at important events.
done = isinstance(e, bb.event.BuildCompleted)
system_stats.sample(e, force=done)
+ d.setVar('_buildstats_system_stats', system_stats)
if done:
system_stats.close()
d.delVar('_buildstats_system_stats')
@@ -55,7 +55,12 @@ class SystemStats:
# becames relevant when we get called very often while many
# short tasks get started. Sampling during quiet periods
# depends on the heartbeat event, which fires less often.
- self.min_seconds = 1
+ # The Heartbeat events occur roughly once every second but the actual time
+ # between these events deviates by a few milliseconds, in most cases. Hence
+ # pick a somewhat arbitary threshold such that we sample a large majority
+ # of the Heartbeat events. This ignores rare events that fall outside the minimum
+ # but allows for fairly consistent intervals between samples.
+ self.min_seconds = 0.990
self.meminfo_regex = re.compile(rb'^(MemTotal|MemFree|Buffers|Cached|SwapTotal|SwapFree):\s*(\d+)')
self.diskstats_regex = re.compile(rb'^([hsv]d.|mtdblock\d|mmcblk\d|cciss/c\d+d\d+.*)$')