From patchwork Wed Jun 22 19:21:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aryaman Gupta X-Patchwork-Id: 9516 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70BF5CCA47F for ; Wed, 22 Jun 2022 19:21:34 +0000 (UTC) Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by mx.groups.io with SMTP id smtpd.web08.11915.1655925687856432758 for ; Wed, 22 Jun 2022 12:21:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@windriver.com header.s=pps06212021 header.b=e2oK2kk5; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: windriver.com, ip: 205.220.178.238, mailfrom: prvs=3172a7b279=aryaman.gupta@windriver.com) Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25MCriDs023689 for ; Wed, 22 Jun 2022 19:21:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=SHqpb6CSW8CRPBLL2I8Ydj+EO+dRgwiD1oEXjo9eIzE=; b=e2oK2kk5P2aL+8enLNrraz4TeTAB2+/bfMiorDDbchBx1OB70XwKr9JvSBqGIcO9mkRt iPigWXlsLcaXFovMpoXQFzcCKiBihnAsgQMTtYnNykEDrGD83sDoKLTpeBBIdOv7vl0n WqDhi/5QVA4uiwNc68DV6fSdtisw+wJm8+dJZ9WcNNyz7ofjsNGhj4ZovK3FoQGjmfsI fZjoEJscDk57sK6DYQXC+EoXWJyJJbtUFrordPrSZdvPKI75CuUFSaXKjNEbrLS5a2LD kbt+nQdNfnfiUUx+Vstc3H+gleKW7RURv6SRDxrCegmorm4usghQpcGHEGf81CYyobgZ wQ== Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3gs3x1bgm3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Jun 2022 19:21:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ipL/xB6m0mbjNv/0928/0bauQa+/1FEw2AdC6sG8Il7DH9WvFMHImp1GlxeVSjdZZOfZn9Aegc6S5aAcFGJkfsb1A8kC+DwJV6xxlJHvZ67W3NWgMLHxEpOXl4YA6ONEjNyEKqdCRedl9NSF7vkyCXCZ70ZAnC8i+X2hFgwBA6oPcpImtb96ShFMo9SyGuf/VcD8UPKTauVnucOzqyP9Lemip58bD8+jupBkoQIjqr3JRieVeveBHwCo57SuptbzkTdUXA5k4BCOFK+p2k6qYSuUIYxawbONRod5Tp8W1lV8kRU2MGET+uV6/Sm02FVzkBKsWIBQBWODC8dVE0jk0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SHqpb6CSW8CRPBLL2I8Ydj+EO+dRgwiD1oEXjo9eIzE=; b=OJr3GOucqmyzLb3x5K34RoNcDJUREcSYiFZgNlMXyN1T7LQM0gG2Wh53VYA4HjisJ6+W3e3yukyvJuveI61XzgIoGZIbiJ5b01QpbpfubEYotPETOieflaUUjUSOZD5jfBu0LskrD133ufDl9dOlBWmEL7Ai+bFhmVhq5HlKqsLqx1g1uhtMYIYbdopFWhVz/nd0/vRQZbp5RqaReOTwzpH6AdejBvSSPNGOTyvQzwHW2j4YS4dIVjc7AAq7/MUgHSMJvpg9pcK3t0mN551IU+5eF/tTGt1gLrE1rCjiIz7okECEbWU/RtsMCt1mecpo9yR/p0GFK234gwZmAeDRgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from PH7PR11MB6030.namprd11.prod.outlook.com (2603:10b6:510:1d1::19) by BY5PR11MB4497.namprd11.prod.outlook.com (2603:10b6:a03:1cc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Wed, 22 Jun 2022 19:21:25 +0000 Received: from PH7PR11MB6030.namprd11.prod.outlook.com ([fe80::14a3:342b:5f14:eda6]) by PH7PR11MB6030.namprd11.prod.outlook.com ([fe80::14a3:342b:5f14:eda6%7]) with mapi id 15.20.5353.018; Wed, 22 Jun 2022 19:21:25 +0000 From: Aryaman Gupta To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/3] buildstats.py: enable collection of /proc/pressure data Date: Wed, 22 Jun 2022 15:21:03 -0400 Message-Id: <20220622192105.2177756-2-aryaman.gupta@windriver.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220622192105.2177756-1-aryaman.gupta@windriver.com> References: <20220622192105.2177756-1-aryaman.gupta@windriver.com> X-ClientProxiedBy: YQBPR0101CA0029.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00::42) To PH7PR11MB6030.namprd11.prod.outlook.com (2603:10b6:510:1d1::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4af491f-4c18-4c9d-527b-08da548465ff X-MS-TrafficTypeDiagnostic: BY5PR11MB4497:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +W2N30LVTORg8brL+FOIsuVJ7SWMFG9Mt5TcztElXiS0UCJx1IcSy+BP9z1/A0xblRcPcWzqK6a4SmHbQ5JNb3lhLBJcZwrFHXaCkaQdMrSLZ3nVQXHvQs1z2CDPgEgh4LBqKz4GW4DvgJW2AeNaxMOKvmM0FT2f1xVHy0GCluvvZ7vpWS4CtbeFf/Bd/3ugSbIS7XgkIUJoQbUxUzrlwYBgphSBU0+KNtaxSti4YgQAiuiJ2B6Um4mMuWTU0lIW2sDZCgswTfdfUba1GJQf3/Yt1sRBc9pt+vLJvqnnZEt0XdtzNQrM+3iAJjZ+K6NSyp0XoVPFvZiNKhf8BowuVqnRU1vUB+9fIlUHKGBdIEMtIIKX8rpmq9kMyDTnemtCCXwJjAjkejKKJjjxNGY974lKiZlH8vK8ozgbv5YYGI/sJZBYAVOgAtRDAiwnwrV3f0BKD7gqPw6E0tIdB6w/F8JnghOe4W+aJMi1oIbLlb+GWKP1IGTBHEapcHEgWTSH1dMrw4aNPG5dkIefpyotCIFNw2I74AgxeeP2AfzWMQzk0zlymISdOzdWc+YE7bILx5B0JomiKQl2i+U7esUFcyDDp5WqYOpJy+G11Yf0vzzwUoBG/5pKba6LjMWIKK19AmrmW7xkMiE3zanYasV8lksmq81+3f/Ddzf5iUlSh4dTRywYjzwm3IwrHXhzUFfqo/lxpXkWfozkP+hAHUXqwgshZ1+tzMdea6aN01GoqSQKUc/r9y3RMtGAY0ouqlvpWHaTg1NwSSpk7VGOEBnoukIekeQZhKBMCs6aXWH+YLg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB6030.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(396003)(376002)(39850400004)(366004)(346002)(83380400001)(186003)(6666004)(478600001)(1076003)(41300700001)(2616005)(38100700002)(38350700002)(86362001)(6916009)(5660300002)(2906002)(44832011)(8936002)(52116002)(6512007)(26005)(6506007)(316002)(8676002)(66946007)(66556008)(36756003)(966005)(66476007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pNZ7qZRGHRUOq9mQMbi81E3OjpP18I+sFplj/9KGsrgEcVbExY048tpBaLOAvqt9HVaEn0/qXO67G3te0XP0dINb0gUmtLSTU8i6hxogP9ckfP+wgKLJEK4mHvuApiuj2W7RaB/3Kl9E/KxslpsnLDqwQ3u3ochMRc5VbF+7o9HxJkfYZLVnIb8tnqzzGqhkKFlDYRbkud0FzyvmthfVusST/UoLuLbu2zUQewZUon17jEK6pa6h7b2LXukb4m3ixpUl9k072bhn3DTJgETtuu1ss+RHItpP4EeWaWI/TzMoaT+GycBnVtQJJH8H6cqWiGAq8hhNw8Wy/gcMEgtR16wwVCQmDHulRsGkU4tPIVMVFXqOEueINzU9f4vgjTCp1FokMAqSnTk+KrsWSVusZ6PpTf5V3y2T3/sDuXeL8Py/SApKkwH1JAQ2x3NwRiRxNtI3ewcz38x7NJoNLTvqAwEISNqk7LMV1YhXMpDgdzl3rxKesVNfT7ssM4T3FU4p+JLU17GwhJ6aVmlQV3Oq9v6oCsG/YYqFVvnp+5QzfCjBiCOPYXYymtt2/Z8vmeNJyXZvKEDU4Ej4QeWUp8X2/uQXyZx47xNcOpKcrV6kdPQkRp2Nx5FpsCaj2CrJvV3e3YvgsQpAIb+haxN+rgPYQEXgPK8ciRedpv2hkqBcnbiv+g1YL5LmiYVpZTeCbrKafqu6ct8mLR6rTu+bzEPq0GmIOjHVNcOz5J9B2UJQTT+TWaq3NHSQ7cptzcUHKA+RuSXEPRX/h6zDA72F0RodiZA+9C6S9YWHbxzJkWi9fkE6yoInRwl0gezGSjAMg5px15Bl+Qj5g3kRbqHagMOTZVcVAF/gDOmQwd8V1MPAU06sazy5UJLbdyqvPjlrf/LQq7g/0WdqbHKIRwnWcKOpJs2SnJI6OgK0nPQmsTs190PGmmyQ3bfNzNutgcalTWIPPuWa4DwiFxKdIJoDN2CqCjObnFQrf6SLTbJXrjQPfDUHIr3Pnp7/qpONXHMp4gIAOSfMIzdkbI8q5lrAyC+1hrFffELMiLY03VPlK97lF3ajyfvWGzeXw8y8Uzu7WtnZPsNJ//lrv2iHbBd0gzQkNoPqlk8ZPHSstUiVny9N5ZFO0yg1CJNLlAaB241ha31GMyWiZuk4OCCD7JqC8kkfl2BVqeghIE5idCc2SV/y024tohOA2dJ98uAdU6+fpNylk/XzQKBLSXy0tTsSArWF8pddE2mEbnA2SEyhD4dbhZck4uY8Sl+Hkby5xbF2SC+vw2IppbojM87FjhbiR0B2a7sH9oZGonabwR5a65h+FD6pDbEA67FKYInHELJHXUoD+aphZP3sR5LM0KO8Y8QvgFFS/u1l7sEn6Njl9pAjZYlwWi1k6iGymtWrQCmfvt1bSggA2+pXi+yCuueVwj8MOQU7wI0BVmc2MbC+fbAvcDmOQA6UPfZDmns9oiZakYABAAHsISuFzAAc/L2X3toymJrNnF7a4eOq5SVbCvn0Zrg3VtPAF3C3FJe1MV9VBef4gMp7BHt5yp+grUHtxjPlowmXlyG7kz/J/d01zEugLQscVGWXfQ6VBImwJoTACE0PKK8bDTMVGESPwFJznLEE+ekswnwmfipgVuhLve1uayx0qIe3zfUxpyaydBa49/ntNDYNrK6BFx5VUJjEc1tDvPZMNfaKSmAY1dM+2QZjrvE8hIxcDEeEnZpjGeOjMrz4MHH1/wa81R0q68nzlVGRydBwzsfoIn4NJiAxCXcPgSg= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4af491f-4c18-4c9d-527b-08da548465ff X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB6030.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2022 19:21:25.1400 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Kp7a2H26zdMEYWQo67VQEoCoLppTJKO9+1t49vj0Bj5AEvXAuCUd3rqPlg117oJyg5u18T7nszoilbAQiIs1a99SRTuVpP+OdY/R0zi8Lk0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4497 X-Proofpoint-GUID: UWAHXoF0a29Z3b8eJTwdplt_VkfdFskX X-Proofpoint-ORIG-GUID: UWAHXoF0a29Z3b8eJTwdplt_VkfdFskX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-22_06,2022-06-22_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=662 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 mlxscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206220091 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 22 Jun 2022 19:21:34 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/167253 The Linux pressure monitoring system helps determine when system resources are being overutilized by measuring how contended the CPU, IO and memory are. This information can be found under /proc/pressure/ which contains 3 files - cpu, memory and io. In each of the files, the format is as follows: some avg10=70.24 avg60=68.52 avg300=69.91 total=3559632828 full avg10=57.59 avg60=58.06 avg300=60.38 total=3300487258 The "some" state of a given resource represents when one or more tasks are delayed on that resource whereas the "full" state represents when all the tasks are delayed. Currently, we only collect data from the "some" state but the "full" data can simply be appended to the log files if neccessary. The "avg10", "avg60" and "avg300" fields represent the average percentage of time runnable tasks were delayed in the last 10, 60 or 300 seconds respectively. The "total" field represents the total time, in microseconds, that some runnable task was delayed on a resource. More information can be found at: https://www.kernel.org/doc/html/latest/accounting/psi.html and in the source code under kernel/sched/psi.c This commit adds functionality to collect and log the "some" CPU, memory and IO pressure. The "avg10", "avg60" and "avg300" fields are logged without change. In place of the "total" field, the difference between the current "total" and the previous sample's "total" is logged, allowing the measurement of pressure in between each polling interval, as was done for /proc/stat data. The log files are stored in: /tmp/buildstats//reduced_proc_pressure/{cpu,io,memory}.log mirroring the directory structure of /proc/pressure. If the /proc/pressure directory does not exist or the resource files can't be read/opened, the reduced_proc_pressure directory is not created. Signed-off-by: Aryaman Gupta Signed-off-by: Randy MacLeod --- meta/lib/buildstats.py | 57 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/meta/lib/buildstats.py b/meta/lib/buildstats.py index c52b6c3b72..64ad3ef40e 100644 --- a/meta/lib/buildstats.py +++ b/meta/lib/buildstats.py @@ -14,13 +14,27 @@ class SystemStats: bn = d.getVar('BUILDNAME') bsdir = os.path.join(d.getVar('BUILDSTATS_BASE'), bn) bb.utils.mkdirhier(bsdir) + file_handlers = [('diskstats', self._reduce_diskstats), + ('meminfo', self._reduce_meminfo), + ('stat', self._reduce_stat)] + + # Some hosts like openSUSE have readable /proc/pressure files + # but throw errors when these files are opened. Catch these error + # and ensure that the reduce_proc_pressure directory is not created. + if os.path.exists("/proc/pressure"): + try: + source = open('/proc/pressure/cpu', 'rb') + source.read() + pressuredir = os.path.join(bsdir, 'reduced_proc_pressure') + bb.utils.mkdirhier(pressuredir) + file_handlers.extend([('pressure/cpu', self._reduce_pressure), + ('pressure/io', self._reduce_pressure), + ('pressure/memory', self._reduce_pressure)]) + except Exception: + pass self.proc_files = [] - for filename, handler in ( - ('diskstats', self._reduce_diskstats), - ('meminfo', self._reduce_meminfo), - ('stat', self._reduce_stat), - ): + for filename, handler in (file_handlers): # The corresponding /proc files might not exist on the host. # For example, /proc/diskstats is not available in virtualized # environments like Linux-VServer. Silently skip collecting @@ -48,13 +62,15 @@ class SystemStats: self.diskstats_ltime = None self.diskstats_data = None self.stat_ltimes = None + # Last time we sampled /proc/pressure. All resources stored in a single dict with the key as filename + self.last_pressure = {"pressure/cpu": None, "pressure/io": None, "pressure/memory": None} def close(self): self.monitor_disk.close() for _, output, _ in self.proc_files: output.close() - def _reduce_meminfo(self, time, data): + def _reduce_meminfo(self, time, data, filename): """ Extracts 'MemTotal', 'MemFree', 'Buffers', 'Cached', 'SwapTotal', 'SwapFree' and writes their values into a single line, in that order. @@ -75,7 +91,7 @@ class SystemStats: disk = linetokens[2] return self.diskstats_regex.match(disk) - def _reduce_diskstats(self, time, data): + def _reduce_diskstats(self, time, data, filename): relevant_tokens = filter(self._diskstats_is_relevant_line, map(lambda x: x.split(), data.split(b'\n'))) diskdata = [0] * 3 reduced = None @@ -104,10 +120,10 @@ class SystemStats: return reduced - def _reduce_nop(self, time, data): + def _reduce_nop(self, time, data, filename): return (time, data) - def _reduce_stat(self, time, data): + def _reduce_stat(self, time, data, filename): if not data: return None # CPU times {user, nice, system, idle, io_wait, irq, softirq} from first line @@ -126,6 +142,27 @@ class SystemStats: self.stat_ltimes = times return reduced + def _reduce_pressure(self, time, data, filename): + """ + Return reduced pressure: {avg10, avg60, avg300} and delta total compared to the previous sample + for the cpu, io and memory resources. A common function is used for all 3 resources since the + format of the /proc/pressure file is the same in each case. + """ + if not data: + return None + tokens = data.split(b'\n', 1)[0].split() + avg10 = float(tokens[1].split(b'=')[1]) + avg60 = float(tokens[2].split(b'=')[1]) + avg300 = float(tokens[3].split(b'=')[1]) + total = int(tokens[4].split(b'=')[1]) + + reduced = None + if self.last_pressure[filename]: + delta = total - self.last_pressure[filename] + reduced = (time, (avg10, avg60, avg300, delta)) + self.last_pressure[filename] = total + return reduced + def sample(self, event, force): now = time.time() if (now - self.last_proc > self.min_seconds) or force: @@ -133,7 +170,7 @@ class SystemStats: with open(os.path.join('/proc', filename), 'rb') as input: data = input.read() if handler: - reduced = handler(now, data) + reduced = handler(now, data, filename) else: reduced = (now, data) if reduced: From patchwork Wed Jun 22 19:21:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aryaman Gupta X-Patchwork-Id: 9514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A6B5C43334 for ; Wed, 22 Jun 2022 19:21:34 +0000 (UTC) Received: from mx0a-0064b401.pphosted.com (mx0a-0064b401.pphosted.com [205.220.166.238]) by mx.groups.io with SMTP id smtpd.web12.11840.1655925690336042840 for ; Wed, 22 Jun 2022 12:21:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@windriver.com header.s=pps06212021 header.b=HuA4+LpM; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: windriver.com, ip: 205.220.166.238, mailfrom: prvs=3172a7b279=aryaman.gupta@windriver.com) Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25MHKJlE004781 for ; Wed, 22 Jun 2022 12:21:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=6uQAcDNP1cNXHStFkD39KncmypH7YPv13wFYpbauEok=; b=HuA4+LpMvFTplPJPy/S4UQmr1nHEEPeJ8y0JtsXBBDdOJOQf1yb2OJn4TGaWS4hYpVg6 cQqsl2nn/Opzm7G1Wbe04l+Mq+Q3wV4dHgrcfNGWU9iAwD8B82lUx7JGmsSFmM9jndV6 32O9kUekQhm3eAUTAzugjTjvFCU70twndHHbAO85FiZkBDv5iYNRcuyPdjCMCcCw3XrG dzYZFiBbOpYVBjnFIUmoI+hdt/AqiUIsAFQgd0oGT22IcxvB2Wad+Qefv3p/gFplivIR OdgOWmADs83hcDOGR97eM6arQBP+7of5WXT1TSvbLeVHot62ydfj2J3xEPz7eIQiZjL2 fA== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3gse7ku84w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Jun 2022 12:21:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TVtBc7yurutN5ktPbB3ZJB6wLHema0ISR1GY/K/bHE6eyFbUkCPJQFnvWdR5isS/CRJTBCJzp8iqK0mil/tY5lEMVp+pkW7T35fRI6jngdIgrnjSVdB4yi+EFF8vhP1wi8fjOKDbKDiPiLNAPHNrZXD3qWNZ6bxhLxqsiPF+TeacCXuR81MSszpmacoRINdjpPZfHaHpmX3NvWg874h4eDtWfuQkkzvDoLhcW3yfMtFbbKAGXWCiVjamJqimVzBOtQRT15+28/3SwVWr05AMIpklTVtkmMAhQD/M4Re8jWJejFYhCsog79cSfqynuHOjQ6fopb3F7qX1DjjCxvrp2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6uQAcDNP1cNXHStFkD39KncmypH7YPv13wFYpbauEok=; b=nh+Wa6h3PVLt/0eSo47MmlUQeH9Do2e7H1kx37Z8LHHnhua8tk9rOOXWNGRuJI15U6hX22w0LYFaZmXy/uGM8exxceS7saDIbzcXk4rFAHrpRM6v2pgYFu1GRWeMmXEHODckZb27NRecoLM/gw+sXQtr27q0LVAJ9uhW2BlfZihfLaAi3tyD4YzhBdHrBPqE4DIr4vJhb7A8pyAiUn0ptIshct1/oTEfDEnd9b/iUaO+84U4ochwRkbIOqyOluTK2W75aEl2nE0+s+DP7bV5u3PqqKoa5qAVXJjIGBrM6PwdSPO0N2FNUn5wQc0HkIG2oy8HdGsNiadKbLp4TG5m/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from PH7PR11MB6030.namprd11.prod.outlook.com (2603:10b6:510:1d1::19) by BL0PR11MB3011.namprd11.prod.outlook.com (2603:10b6:208:7d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Wed, 22 Jun 2022 19:21:26 +0000 Received: from PH7PR11MB6030.namprd11.prod.outlook.com ([fe80::14a3:342b:5f14:eda6]) by PH7PR11MB6030.namprd11.prod.outlook.com ([fe80::14a3:342b:5f14:eda6%7]) with mapi id 15.20.5353.018; Wed, 22 Jun 2022 19:21:26 +0000 From: Aryaman Gupta To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/3] pybootchartgui: render cpu and io pressure Date: Wed, 22 Jun 2022 15:21:04 -0400 Message-Id: <20220622192105.2177756-3-aryaman.gupta@windriver.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220622192105.2177756-1-aryaman.gupta@windriver.com> References: <20220622192105.2177756-1-aryaman.gupta@windriver.com> X-ClientProxiedBy: YQBPR0101CA0029.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00::42) To PH7PR11MB6030.namprd11.prod.outlook.com (2603:10b6:510:1d1::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 023a9367-806d-4d26-c0c0-08da54846652 X-MS-TrafficTypeDiagnostic: BL0PR11MB3011:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DSCMdeylPcczXp578E8hXBXCAVsMB58GTBNbwNbTpWGHBiu+WxRprg8F35AkW4E47zu59ompqo+T/2Ja7P/37EvWzOLpU6XrioEe/UgAjYGdJt0SmCyo3DW0pKb+hVJvp42EyxPgiQmC57mS9kcpmca3Qzw/qE/jEExmQtI/aXh5jGAshOlWtmrvSrAflosA3xER+vII6eva/2VAEJVm7Kgbcas8vSe/hWLuNQX0fjW+FgDwFtAWmNyCB72UgxSKBUUzh9i31KfopjK/mPUzclfkyS979co0AJbKHtZTE8xzFWjH9JYS+AjE0wsoTfGAeXLoFRfcebQ2s3bjGrODZby3N90PKfwYhSHicR1wbQr8+/jALcFpGfMF5t4/S5yswCbv3V7q4/ddRCz1oG6+YGUjT1tF7p5NAqUhLpC3xk4Diygn0zlLopupVy4GCIHuR4kbZBI+vWSW7JV+bW1DOxIuyK+Gd4jGo8SfiUpiGjKO2l5rc8WSuMJkv3h839XMeCIjuhu8/8NSnlrbo88cm8MIjSblX106qBBhOU/relKV5BaVho/dUTloqgVUwzB3loaYNP9vbQs9DwKtHl6OQFinZn2KRnO0cVzU9C+F6PgMYC4xE1QJ1u276ji5BgE1skvmURFyg9K1TDHeDuSI4GnpV99V2bioeMC+5gZNJOOw3Tgl/KWP8HUrBYme9fMK22IsfGE0Lbp8aEipSMKW9epbEUruYz0unhQMf4EikktjZNW/Eg5r+SlNN9ISDMG4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB6030.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(39850400004)(366004)(396003)(136003)(376002)(1076003)(186003)(83380400001)(86362001)(66556008)(66476007)(66946007)(8676002)(6916009)(316002)(36756003)(2906002)(6506007)(52116002)(5660300002)(2616005)(6486002)(41300700001)(478600001)(8936002)(6666004)(38350700002)(38100700002)(6512007)(44832011)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rUMggCW6sgh617v+yJ/RFLNgIMdT6twucJXgJFHvkvB2nGoPj4FvL9+TM7Uip8dYtiQgSpXIe0bJAaZUqRJp6IEi37nLcSpeB4/HWyFuwivWMTmeBJAsW9TgGApZPSTSmKd1l2Q3nolZ8mVvA71Yx82C3UBuKLD/ytHIPAFfgL0qYZT38lGQ/VxoVUiCZ1iQ0mc2HSWGfzzHPsGqUpScofW7IS44Tz6cc806gE2atom4VN6J87qJrzNCkJKk/N6uRoG2j+/NIxfK7bMVMKQ7gQH7ieX3uMbkwEROH9WdwRTjxP9f2RcLBz/IHD9aXmvNSXQdlbCalPdV4Ib0rA+JSCMdZY24vtqSru41/8bFVSCUEXAnruRzjiVNlyvb/2EbJX0YuDsM9xEIVyOfhkkKiYzx8pcyyB/ASWi8zPu/2MVam7MjUCd2BJXwoB8Vb/qRd7/fc0Ul/21GFufPEcPmelIPZiLU4cwYVWBI6S4o7mSbz6FeMoZNcv7C4qmM0fKTfwFFu5iZA46hPJ8k91IdkfH9ANohPIgBQ/2RJ/RCHD33S403qH4Ee5U9bmikwhCC883aXKemBjPtJUbYRwuX2GHliYQrGtvn7yVIFNprVw/0bL+4001jPrRiuA2VftaqbVFOGmb+20X4qdAqayIRBieuG7ZFrDGDz/ZvHMT20R8NCq/B/jkfKIl50hV6TnpjL+s9yk4qyxhviDjU9f2sHfDTvf4h5PSaIo3CJTJyHhfyCVA9Xzx6Dp8UJNPf9iZDzCQ18Mx8ojYjSrBVvvIFOzRM0GOBREgGk6mN9IA0fd4C0UkRGsXW/tKQ06VXGyI36plOWaZyQCb2lA5E30uuX8RWv8ogQfDCoPfHsQqjAkNgwnmYL48c1EtJrgj6jW0dKujIAq/KDrwM7K2qxp/FrKZzakv+7DuCtwUIpO0nAxd78wKsgPnux+qNFL6ByyIB4SHwMFnLUHsMq9qG85KeAU5F3hl7w1dRlH78uU8YJOKuV9vU5RIYadyy/dRMtZDkNWVKfiYLxl9N+bl9CNstxMsPaWt5I9s3mPYwE5+tvYCciwllGLUkWBh3DAcGS8W17+8sgxLF7kZcJr485yOjtsKeU7TqYBpVtg6NB2vb0bVIvbwNmu6cfvgpW7m2LgcIkKdpRIPEvywIA8u6DUHZ2coRyCHoWNiQsdKknY/zsjxqGpAWIbtJ3bJTdNbJbRLKpOKwefFc+LMHAN9q6+WYc5RlZyDuLe3se/L+Mj1nzUEzXZ+qBhLeMdrzGBUqRw7ezaM1bGFTafCsgSlh/y95Jp4SKYjH+dC4fNsUVYt5XfAijpzS79EP8getqMiGakygSAmudKaAGQ00Cap+jQgngAi6kONmh0c0kiIWTwuOF8+JufPYMN9MvMu+BcNIKG76dWjfDn423PYCVXA+bYrmTMiBar3+e/hEWn4LFpJ2h5KAz3g/jASj93geh4kUy5iVmwbmz9GoTCf0vTyS49ui0tp4wF534whOFMJLXhsby/DcLz09XNil9jDrk6Y7/vf/nNvMOMusCZ9GGebR6p7Cj46VPQgG20I4zmWbEI8+Lv194SMWyfq3BimaiMtK5SbbrQsBlMcocslqfqsR/VkfyqHqIlQmcf53XC5sxpi1ZbxLnawJ+PZp8BCiyP8THyRjHtOR+u0jK2MFlOWgRzg6OBjkl1Ao5aI/z6npQYbKQOKNtRQtAgCgeBNVDlawEpspmtW7Bl3gKHd6VU63lck7yPp3HDrMe4dTFKvyFN6wvT4= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 023a9367-806d-4d26-c0c0-08da54846652 X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB6030.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2022 19:21:25.7336 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mPNzux6qB2VhSPqNUPeBkrLl9ktBqjpXJRpeLfcuX9tn4ssQdXr39/bxbHnZzk7pqRYdVztGb6ZgUKwQNee4ec+fbHnVqJqNCcPMI9sBjEs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR11MB3011 X-Proofpoint-GUID: RO13-vyJiRKh5-lkbwwkRtMdI1kmFrPj X-Proofpoint-ORIG-GUID: RO13-vyJiRKh5-lkbwwkRtMdI1kmFrPj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-22_06,2022-06-22_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 clxscore=1015 spamscore=0 adultscore=0 impostorscore=0 mlxlogscore=799 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206220091 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 22 Jun 2022 19:21:34 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/167255 Add two new, separate charts showing the avg10 and delta total pressure over time for the CPU and IO resources. The height of the avg10 data in each chart represents the percentage of time "some" task was delayed over the specific resource during the last 10 seconds of the build. The height of the delta total data in each chart represents the total time "some" task was delayed since the last sample was collected. If the reduced_proc_pressure data is not present in the buildstats log, then the new charts are not shown at all rather than being present but unpopulated. Note that the delta total graphs may appear "spikey", oscillating from high values to low. This behaviour is fixed in a subsequent commit. Signed-off-by: Aryaman Gupta Signed-off-by: Randy MacLeod --- scripts/pybootchartgui/pybootchartgui/draw.py | 77 +++++++++++++++++++ .../pybootchartgui/pybootchartgui/parsing.py | 28 +++++++ .../pybootchartgui/pybootchartgui/samples.py | 17 ++++ 3 files changed, 122 insertions(+) diff --git a/scripts/pybootchartgui/pybootchartgui/draw.py b/scripts/pybootchartgui/pybootchartgui/draw.py index fc708b55c3..a13df3a3fa 100644 --- a/scripts/pybootchartgui/pybootchartgui/draw.py +++ b/scripts/pybootchartgui/pybootchartgui/draw.py @@ -80,6 +80,18 @@ MEM_BUFFERS_COLOR = (0.4, 0.4, 0.4, 0.3) # Swap color MEM_SWAP_COLOR = DISK_TPUT_COLOR +# avg10 CPU pressure color +CPU_PRESSURE_AVG10_COLOR = (0.0, 0.0, 0.0, 1.0) +# delta total CPU pressure color +CPU_PRESSURE_TOTAL_COLOR = CPU_COLOR +# avg10 IO pressure color +IO_PRESSURE_AVG10_COLOR = (0.0, 0.0, 0.0, 1.0) +# delta total IO pressure color +IO_PRESSURE_TOTAL_COLOR = IO_COLOR + + + + # Process border color. PROC_BORDER_COLOR = (0.71, 0.71, 0.71, 1.0) # Waiting process color. @@ -415,6 +427,71 @@ def render_charts(ctx, options, clip, trace, curr_y, w, h, sec_w): curr_y = curr_y + 30 + bar_h + # render CPU pressure chart + if trace.cpu_pressure: + draw_legend_line(ctx, "avg10 CPU Pressure", CPU_PRESSURE_AVG10_COLOR, off_x, curr_y+20, leg_s) + draw_legend_box(ctx, "delta total CPU Pressure", CPU_PRESSURE_TOTAL_COLOR, off_x + 140, curr_y+20, leg_s) + + # render delta total cpu + chart_rect = (off_x, curr_y+30, w, bar_h) + if clip_visible (clip, chart_rect): + draw_box_ticks (ctx, chart_rect, sec_w) + draw_annotations (ctx, proc_tree, trace.times, chart_rect) + draw_chart (ctx, CPU_PRESSURE_TOTAL_COLOR, True, chart_rect, \ + [(sample.time, sample.deltaTotal) for sample in trace.cpu_pressure], \ + proc_tree, None) + + # render avg10 cpu + max_sample = max (trace.cpu_pressure, key = lambda s: s.avg10) + if clip_visible (clip, chart_rect): + draw_chart (ctx, CPU_PRESSURE_AVG10_COLOR, False, chart_rect, \ + [(sample.time, sample.avg10) for sample in trace.cpu_pressure], \ + proc_tree, None) + + pos_x = off_x + ((max_sample.time - proc_tree.start_time) * w / proc_tree.duration) + + shift_x, shift_y = -20, 20 + if (pos_x < off_x + 245): + shift_x, shift_y = 5, 40 + + + label = "%d%%" % (max_sample.avg10) + draw_text (ctx, label, CPU_PRESSURE_AVG10_COLOR, pos_x + shift_x, curr_y + shift_y) + + curr_y = curr_y + 30 + bar_h + + # render delta total io + if trace.io_pressure: + draw_legend_line(ctx, "avg10 I/O Pressure", IO_PRESSURE_AVG10_COLOR, off_x, curr_y+20, leg_s) + draw_legend_box(ctx, "delta total I/O Pressure", IO_PRESSURE_TOTAL_COLOR, off_x + 140, curr_y+20, leg_s) + + # render avg10 io + chart_rect = (off_x, curr_y+30, w, bar_h) + if clip_visible (clip, chart_rect): + draw_box_ticks (ctx, chart_rect, sec_w) + draw_annotations (ctx, proc_tree, trace.times, chart_rect) + draw_chart (ctx, IO_PRESSURE_TOTAL_COLOR, True, chart_rect, \ + [(sample.time, sample.deltaTotal) for sample in trace.io_pressure], \ + proc_tree, None) + + # render io pressure + max_sample = max (trace.io_pressure, key = lambda s: s.avg10) + if clip_visible (clip, chart_rect): + draw_chart (ctx, IO_PRESSURE_AVG10_COLOR, False, chart_rect, \ + [(sample.time, sample.avg10) for sample in trace.io_pressure], \ + proc_tree, None) + + pos_x = off_x + ((max_sample.time - proc_tree.start_time) * w / proc_tree.duration) + + shift_x, shift_y = -20, 20 + if (pos_x < off_x + 245): + shift_x, shift_y = 5, 40 + + label = "%d%%" % (max_sample.avg10) + draw_text (ctx, label, IO_PRESSURE_AVG10_COLOR, pos_x + shift_x, curr_y + shift_y) + + curr_y = curr_y + 30 + bar_h + # render disk space usage # # Draws the amount of disk space used on each volume relative to the diff --git a/scripts/pybootchartgui/pybootchartgui/parsing.py b/scripts/pybootchartgui/pybootchartgui/parsing.py index b42dac6b88..004d6fb953 100644 --- a/scripts/pybootchartgui/pybootchartgui/parsing.py +++ b/scripts/pybootchartgui/pybootchartgui/parsing.py @@ -49,6 +49,8 @@ class Trace: self.parent_map = None self.mem_stats = [] self.monitor_disk = None + self.cpu_pressure = [] + self.io_pressure = [] self.times = [] # Always empty, but expected by draw.py when drawing system charts. if len(paths): @@ -554,6 +556,27 @@ def _parse_monitor_disk_log(file): return disk_stats +def _parse_pressure_logs(file, filename): + """ + Parse file for "some" pressure with 'avg10', 'avg60' 'avg300' and delta total values + (in that order) directly stored on one line for both CPU and IO, based on filename. + """ + pressure_stats = [] + if filename == "cpu.log": + SamplingClass = CPUPressureSample + else: + SamplingClass = IOPressureSample + for time, lines in _parse_timed_blocks(file): + for line in lines: + if not line: continue + tokens = line.split() + avg10 = float(tokens[0]) + avg60 = float(tokens[1]) + avg300 = float(tokens[2]) + delta = float(tokens[3]) + pressure_stats.append(SamplingClass(time, avg10, avg60, avg300, delta)) + + return pressure_stats # if we boot the kernel with: initcall_debug printk.time=1 we can # get all manner of interesting data from the dmesg output @@ -741,6 +764,11 @@ def _do_parse(writer, state, filename, file): state.cmdline = _parse_cmdline_log(writer, file) elif name == "monitor_disk.log": state.monitor_disk = _parse_monitor_disk_log(file) + #pressure logs are in a subdirectory + elif name == "cpu.log": + state.cpu_pressure = _parse_pressure_logs(file, name) + elif name == "io.log": + state.io_pressure = _parse_pressure_logs(file, name) elif not filename.endswith('.log'): _parse_bitbake_buildstats(writer, state, filename, file) t2 = time.process_time() diff --git a/scripts/pybootchartgui/pybootchartgui/samples.py b/scripts/pybootchartgui/pybootchartgui/samples.py index 9fc309b3ab..472dc27be0 100644 --- a/scripts/pybootchartgui/pybootchartgui/samples.py +++ b/scripts/pybootchartgui/pybootchartgui/samples.py @@ -37,6 +37,23 @@ class CPUSample: return str(self.time) + "\t" + str(self.user) + "\t" + \ str(self.sys) + "\t" + str(self.io) + "\t" + str (self.swap) +class CPUPressureSample: + def __init__(self, time, avg10, avg60, avg300, deltaTotal): + self.time = time + self.avg10 = avg10 + self.avg60 = avg60 + self.avg300 = avg300 + self.deltaTotal = deltaTotal + +class IOPressureSample: + def __init__(self, time, avg10, avg60, avg300, deltaTotal): + self.time = time + self.avg10 = avg10 + self.avg60 = avg60 + self.avg300 = avg300 + self.deltaTotal = deltaTotal + + class MemSample: used_values = ('MemTotal', 'MemFree', 'Buffers', 'Cached', 'SwapTotal', 'SwapFree',) From patchwork Wed Jun 22 19:21:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aryaman Gupta X-Patchwork-Id: 9515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B7C0CCA479 for ; Wed, 22 Jun 2022 19:21:34 +0000 (UTC) Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by mx.groups.io with SMTP id smtpd.web09.12268.1655925689047053655 for ; Wed, 22 Jun 2022 12:21:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@windriver.com header.s=pps06212021 header.b=g9dy3+91; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: windriver.com, ip: 205.220.178.238, mailfrom: prvs=3172a7b279=aryaman.gupta@windriver.com) Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25MBfm9e015681 for ; Wed, 22 Jun 2022 19:21:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=h+QFiApoTY1dRxNtmZFBdIIE1IE/sRVQfAR/AIDJazk=; b=g9dy3+91CMSRYjSv40qIoSv9rejHpAfEYVjDsSIdJseTfI9OFnpmvSLborg1rpXHN3lX fQdtkLTaip94GAMq4EVOIp/CPS8aj3l+MT7FACT4KnOVZaIbb9Z98s7cUodabowv/s/1 b2GRB/sV6ZD7/8nUJ7tOKyKCB2z9vSy3z74eEto5F5+T2ADXjvbS8iPO4RNbH3c47B1b IUTkF4Q/UDkl+x1FTiEaOMk3WYH89Nn5zDv8jbOk4/uI/LwrEexgHR8bVm5tsyjDzNbA dw0H9Mgjqglq6LkDFsQHgXUQMLSRa0EFJWwbmqfynbojXUSz2VvRKEeeT8CtA05TwL3p 2Q== Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3gs5p9kejf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Jun 2022 19:21:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ItyD4+gfF5zBR1Q1G6yAkRJCv7zTdyLHwQcQ0El961fsFG3GLdbfpla276pNMtQv1lqetNu2P4Ov4QUjbGtk/Qey26UOYi7K1kLPYvSkLlD+8d6D69Hpu/gcNxrs4wwJgW5GlyWwT6vXzp+XRLZq/ots2Zj9QOcjwOwfjazip4ok2tsBbc23gYueVvsYDUyuAq4ctBw3nHxlHSzpS+hl4rafPNNqoIk9rWMQdpmJhDvuw0zmr5UEKwXPfwQininCBEWP9UjXULFPdl8/ZXPOyYH90CPfOAJm2HrFTm8kNo9+hdu37BX/Z2GRD0+FnaCnlAg/OxShHAFJ6eUAuVGa5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h+QFiApoTY1dRxNtmZFBdIIE1IE/sRVQfAR/AIDJazk=; b=MOY418om6F+YuglsVp1dkfWPbBEDEcaqeVT7ErXOd/lIHWkla2jbbIbCCpBitTlbZ8WRM4/Wb5pEqJ3kBOt+AlWiwVr4SgqYwhmLb5X247zfuTUSxakdOGr7JJASl06I7vi751NTJFxBeIxNMbjmRbwUHKURm8DYtcENH05eNSTSGIAI1xUqqX0e6mlVr3BqIsRoLGZdT1iNXzsQ6AsPrmuv1zZRKxiDjbE9xHSBIOLnMBIm7N8bsk1AXf8pBGmzY0LC5KvrAtUYy4cLZ4tuQZ+YqNoVE9HX3dZzhPwIXrXHps2QISSIJxD6sRyX+JBq2/u0o0CFkpQ1L/LYjlVUvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from PH7PR11MB6030.namprd11.prod.outlook.com (2603:10b6:510:1d1::19) by BY5PR11MB4497.namprd11.prod.outlook.com (2603:10b6:a03:1cc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Wed, 22 Jun 2022 19:21:26 +0000 Received: from PH7PR11MB6030.namprd11.prod.outlook.com ([fe80::14a3:342b:5f14:eda6]) by PH7PR11MB6030.namprd11.prod.outlook.com ([fe80::14a3:342b:5f14:eda6%7]) with mapi id 15.20.5353.018; Wed, 22 Jun 2022 19:21:26 +0000 From: Aryaman Gupta To: openembedded-core@lists.openembedded.org Subject: [PATCH 3/3] buildstats.bbclass: correct sampling of system stats Date: Wed, 22 Jun 2022 15:21:05 -0400 Message-Id: <20220622192105.2177756-4-aryaman.gupta@windriver.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220622192105.2177756-1-aryaman.gupta@windriver.com> References: <20220622192105.2177756-1-aryaman.gupta@windriver.com> X-ClientProxiedBy: YQBPR0101CA0029.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00::42) To PH7PR11MB6030.namprd11.prod.outlook.com (2603:10b6:510:1d1::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84736e50-f978-436f-e798-08da548466af X-MS-TrafficTypeDiagnostic: BY5PR11MB4497:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7M4Jz677qCDXCU9fLpvzmxZIdqygbapZLMra8ecvO72Txhmh+B7W1/1iVdmFyCDor26zefgg1uDm6uSK+iAsOVxxlj8PzaHUPFA4egEH9wwQRHKD09YrPdrhaipOcgQA3YhG05N9znE3Qy39FJiYgPMt7xBbjdRx0gnBPNPzy1mPPjoXY6CbCZfu+ebjw5GwixREy58q0a4ci1pkEx0mRSrUrL6XEuF5n3/wXMkzqJrI0ywVvGz8DdxaYOmWENNwAUzbrxCx/wU50gtPV+i0npcenV0sinkRzAUbYRjeND23dVC9t0FPyNrJEO2amP6krDs7R0JJCs81B9Yc0nxX0dyApDRrpb2Wr1RZEGfIo7yyp5eASTO93CNOgu0O4ek93etqL+dCP1kc6w2p0AC4gSiREmsq08LURgs0IaUucSVLQfr+WdLFjoIb+41Xd7FPRVYt3XvaugKoUCoRPEjEHbH/Kc5RHEoMAYpLbOHJxLx1RdjeqY6YahRFYZzL53i7p9quYNASaGfCtSZBKUJ1UFEcMF0ilm+bpbS9f9l95fQBxfOjDJQwsYwskJWq7uBVaOYZjsiudIf8B0jc6r26OzXJ17DgqW8Eb5CnyTgm7ZJgNb4RyoNAFkh9gRntJABTPeFB7d1RJf34lUzp2pec+gJnLqk8dQcrOwHJ0hrTTQ8ookbO/+N2ydFcc3kNgj+iBddgzVhglGRcjUMDqnbwXnEscVN6KoYwUbPm4slcRXAo5b9H8DErhOTYSebjpeEm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB6030.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(396003)(376002)(39850400004)(366004)(346002)(83380400001)(186003)(6666004)(478600001)(1076003)(41300700001)(2616005)(38100700002)(38350700002)(86362001)(6916009)(5660300002)(2906002)(44832011)(8936002)(52116002)(6512007)(26005)(6506007)(316002)(8676002)(66946007)(66556008)(36756003)(66476007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2OjlOUkw53aa2fGtWCQZcaDxKX8fEohNuvz11AEzS6DR7YIFkvglspF27rIVcP3hco65Ws7yzp/R/ZJryN/aWSdTPL3c49s1bFfyCS3HAPdk3UFjQt6TtvbJ81LBpmCoPfE6+Qwf0pdcSuxHfJ98N1l88AoXKOLCCwrH991XuPnqGalhyg1Y5zP3mwuHI9EajLfCuNl4BqgCplf5APu/3NiSEucgugZ3K4QnPBgrGB0KcvDu/y0DE1Iq5kF7F7Bcwn6LIUoRKxvSrOIVNM6+pozgnPtOzGx/y0w8gjpXp/iZBMmy78pGI3Evk48/locLbkyoJVmimzOjbDeuP9B+N1sRo+QiVvaiYJaMlmbpeUpM05/Z19UOMq1LsCnweVg/L/t2g9qXhQ1XSHTjksCE9vM6j1/ryj7OrkRwv2i0HJIYRjBP2OZ7IdKG/yz5f+ny0nEN85DFBysiaNYL1l3pWU+ME+xbAYS7nnMJqbqABW+dyeFnWCRg9BKEyfDOoaG6wYRIBfO29bfZdmM5ECdpYSiIdZLRBpOF+eL+qUsrr2zCyt2HriKM7RCEYmqEbtLnQcGyq8mnWA5Shfz0urLRS/42Lyv24RXX11J2/Usoqwd9CaojbCzxWmujiDV3DsV9OMLPhV/D/nfpPGgkP2GP8rpW8fRZYu1izTyjt1Jau+W4aIXHsiCTDuN3u6tF82HAujk3KutdDiuz0VRYJX7Iw1Cp1mIli+VObkOyY2Wf3zapxTNJTucUIb0TGJAXNW+UdY0LvVoHJ7LaDpxOjBl0h52pU4MDi/4KnAPB6fqtqFA3X9CX6XomJ0YCvdx5qrwWlF3xL0RuwcBrtkUvXKWdyismEaklInKwSPtnDGEe3ClX4fY4AH5e2B9cyRf3w9NrO/Zc1zBVzkeVfPNGAg9+EwH0uf7nIGxUxM2ma5czKdZbshoGQTcZpnuQ5bhNja/E8tJlzPss29A5ead1GK82iM0xSPXyGPpfBMfqkiacA75WuGsyrqbj72Nc2Umy+Kow0zn+zsPH9Bb+j/MR8ll28mwuz+2MS8x2p7umLO5udfM/s4K28E2vJgTDrZ44+7n5/30UPSoxFfyJajWki/gdd/3j3Fz4dJXevTPvm8VUVqCbRHjfm1aafFGpkLOLJMfoaukXZcetMNwXBNsJfszosxznWH10w7wjLjxUSoYNRFPHeS3gCx7AKyKkjH2BZ8Y+H/4jKg1jAxJ+4KZ6S3CA0HpGp1Q5LIYYCh4vo0STDg6hMDO3G87GtEQEaDjFIkiLBTYnqs0j2f9V2xUXwE30J+FxiIWRaPCBmW/az/vnEDioE6WPjoN5EbfAYHzua52AGaxs+bx6d9uPChmFua6r5efzNkq1YBPIoYtTidqnnS9xDiotIrUm1+ClfiLGGB0UIddc86crQvEWLbHoSwUPKbThmvgdltPPkQnqnvzzdmkGT7DPrmf93l/R7MLYyC58tqdqYHjgm6c+/BHoCH7ImsL+GLGveeStH24UvGjZlEjW4L0DKmn4aXFki5GIht9RclO6pjE+qWUCVScT/dWA1WcNmW/VxKDmBMYnMXM+zIaGCZ0YxTgUHPSwribkjtjNZO8jcDMMZCkwYXI33r098OocWlD2CUJ6qhMGtgNzxEej+MGSJDVyMVIdBZTbqroYCtl2VaeD5ZROqnoYEd9614SXUsPC0wy6aEa+UTlrd5WxayvgfzItrH9FDj42YpPtCb1maFXLXWWgsu/EffjdS56OgBffqd9e+Fo+1Z2rvLA= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84736e50-f978-436f-e798-08da548466af X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB6030.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2022 19:21:26.2816 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WyHzo4dIA5FkO/ufU8HxEgdqi9knksSOo9dJNbd7j9tqqdblFRfCrdFTtAwPF5PlLtaZtFDlf9PDbN6J9F7ervZod93OXYHR0G/O2TRsojU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4497 X-Proofpoint-GUID: sth7ButSVRHM2EXrCstTOK1bknXwPsJS X-Proofpoint-ORIG-GUID: sth7ButSVRHM2EXrCstTOK1bknXwPsJS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-22_06,2022-06-22_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=845 spamscore=0 priorityscore=1501 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206220091 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 22 Jun 2022 19:21:34 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/167254 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. Signed-off-by: Aryaman Gupta Signed-off-by: Randy MacLeod --- meta/classes/buildstats.bbclass | 3 ++- meta/lib/buildstats.py | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) 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') diff --git a/meta/lib/buildstats.py b/meta/lib/buildstats.py index 64ad3ef40e..5d32a81906 100644 --- a/meta/lib/buildstats.py +++ b/meta/lib/buildstats.py @@ -51,11 +51,17 @@ class SystemStats: # Last time that we sampled /proc data resp. recorded disk monitoring data. self.last_proc = 0 self.last_disk_monitor = 0 - # Minimum number of seconds between recording a sample. This - # becames relevant when we get called very often while many - # short tasks get started. Sampling during quiet periods + # Minimum number of seconds between recording a sample. This 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 + # By default, 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 tolerance such that we sample a large majority + # of the Heartbeat events. This ignores rare events that fall outside the minimum + # and may lead an extra sample in a given second every so often. However, it allows for fairly + # consistent intervals between samples without missing many events. + self.tolerance = 0.01 + self.min_seconds = 1.0 - self.tolerance 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+.*)$') @@ -164,6 +170,12 @@ class SystemStats: return reduced def sample(self, event, force): + """ + Collect and log proc or disk_monitor stats periodically. + Return True if a new sample is collected and hence the value last_proc or last_disk_monitor + is changed. + """ + retval = False now = time.time() if (now - self.last_proc > self.min_seconds) or force: for filename, output, handler in self.proc_files: @@ -187,6 +199,7 @@ class SystemStats: data + b'\n') self.last_proc = now + retval = True if isinstance(event, bb.event.MonitorDiskEvent) and \ ((now - self.last_disk_monitor > self.min_seconds) or force): @@ -196,3 +209,5 @@ class SystemStats: for dev, sample in event.disk_usage.items()]).encode('ascii') + b'\n') self.last_disk_monitor = now + retval = True + return retval \ No newline at end of file