From 1125adc33b3696ffd351ffec9445f0c09b178fde Mon Sep 17 00:00:00 2001 From: Aryaman Gupta Date: Wed, 22 Jun 2022 15:21:05 -0400 Subject: buildstats.bbclass: correct sampling of system stats The last time of sampling would be updated within the SystemStats class but not re-recorded into the datastore, leading to multiple samples being collected in the same second in the sample function of buildstats.py. Fix this to collect and store only one sample per second within a certain tolerance to deal with variation in the arrival time. This fix elimates the spikiness of sampled data, in cases where the difference between the current and the last sample is taken. Previously, since many samples per second were recorded, certain types of data would result in a very small elapsed time and hence a small numerical difference. For example, the CPU usage from /proc/stat is a running total of usage and taking the difference between data collected 0.1 seconds apart would result in usage appearing lower than it actually was. (From OE-Core rev: 0e2df45ab066bb4ad2c4f8622ee9c1a8ecdea9cb) Signed-off-by: Aryaman Gupta Signed-off-by: Randy MacLeod Signed-off-by: Luca Ceresoli Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- meta/classes/buildstats.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'meta/classes') diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass index 0de605200a..132ecaa98b 100644 --- a/meta/classes/buildstats.bbclass +++ b/meta/classes/buildstats.bbclass @@ -285,7 +285,8 @@ python runqueue_stats () { if system_stats: # Ensure that we sample at important events. done = isinstance(e, bb.event.BuildCompleted) - system_stats.sample(e, force=done) + if system_stats.sample(e, force=done): + d.setVar('_buildstats_system_stats', system_stats) if done: system_stats.close() d.delVar('_buildstats_system_stats') -- cgit v1.2.3-54-g00ecf