From patchwork Tue Mar 4 22:24:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 870137 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:178f:b0:38f:210b:807b with SMTP id e15csp493345wrg; Tue, 4 Mar 2025 14:28:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWBjF7NtjqpKmao+qwzhItp+dQWbOaAuA6MgSNXeNZOEn0MgyU9lZMjZ1p0TXb4qEabCRBM7A==@linaro.org X-Google-Smtp-Source: AGHT+IHk5/4ljUGrY9a7FohHLerPydfzJA1zI9SKAMJtxPitqKmAax60STRgOfUv6LjUcYFnyLcJ X-Received: by 2002:a05:6214:2526:b0:6e4:4331:aae6 with SMTP id 6a1803df08f44-6e8e6d1ec58mr16024126d6.39.1741127320259; Tue, 04 Mar 2025 14:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741127320; cv=none; d=google.com; s=arc-20240605; b=ewpGlmwuSSmy1xPu4B9vEdU8BFl9WhMgP6A0XwoYhGTeyJvqWNmg205eGJRIq29BO6 KltSjRSU8LhGXm8NHZaEmMYPcf0vRHIwptpk10oc5TD/9eHg747vvBjhEHV8YqrnTZaQ xx9xPRd09aEN45J7LwtIhbomfTICcgLAM6mhXzmNb9lAJhR5WKnWq9ykPQITA5XY77Zj gnodSlCGRsw9lgGIxSDxgA0On/5/fq12hNH2yIKXWpBhfbaKlUlSaTpK+HwYzdtGbDQ+ mseFrA7sc1vqGhpoYw1UVGFOKf7kTA8imXeylJ0KoDAIBAk1bcSRpPlrll0eqWRib5EB hOPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hl3FvxWtvNwG3y+1922WYsiibfe37dBnVTxNDuvBYeE=; fh=6Bzz00MUAZSz1sM9FDoE/jB6E9D8TQzH70NWpntkZX8=; b=M2k0TBTQ9H/5QBRbIKsMaQ/YuQrKH0zKz5JRfXO5Q3Ge5b73SSsrqc4gPU+xOv7KnR t/seBROdZCA/yqDeEndNWeLOjPO/vISixn7EdWO0tJHYDAvDC5hdafnT+pXX3YnAt1tS EMWsvzdN/5SmQQj527JE1IwKCcQe78eRxQ20BjCa3r0lB4j0rCosdweJc/imtIH9s7kZ XH9PufI9pFofZBxwoqawYbEqSmQwtINIMcUwQeC8kmcphzahjUK3F3DI3gfQTy7/VEsH A1l/vLm/49NNgXi/VSbM/nt3c69U9J7ZrZarNh4VgIagXmuGGIAMFlyMiqG9bUiLrNkl 6yeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RmXgQVLO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6e8976c05b3si114963086d6.191.2025.03.04.14.28.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Mar 2025 14:28:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RmXgQVLO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tpaiU-0007BP-2A; Tue, 04 Mar 2025 17:26:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tpahA-0005SZ-Nh for qemu-devel@nongnu.org; Tue, 04 Mar 2025 17:25:09 -0500 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tpah5-0006ZA-IK for qemu-devel@nongnu.org; Tue, 04 Mar 2025 17:24:59 -0500 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5e0813bd105so9784496a12.1 for ; Tue, 04 Mar 2025 14:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741127094; x=1741731894; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hl3FvxWtvNwG3y+1922WYsiibfe37dBnVTxNDuvBYeE=; b=RmXgQVLOISEuh9CEtfKesy4t9IZ58BvWXTmsMjTVJOwHIS2rboU+5qTmAeiWnDELaL fBWER288znTdXHmcpeu8hh84p+7QDZ0zUIvvvq5ewhk+mcgmEelCEYbnEf3+ynrvTZ8n ki4sGkSi+713i1ejspIGx2g6QE9KZrXTiYf7sTKL5ENxvRhV8rVp91bLrtkxo5zuwlZX 3bOkgXIld343F7Ot4BZjXL4E5ce/bgZ25Fr2K30G2RW9laaA0p+h5i6afsCSprcNbpIC YF8eQ7Eciog9ZR+aJy938zD7iGVmkWiU0Hn7j7gIYVnpCYPY7HxRzkxMT7FxMm+nCjGT elqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741127094; x=1741731894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hl3FvxWtvNwG3y+1922WYsiibfe37dBnVTxNDuvBYeE=; b=Qc8hEfddlNwlfUo8JJWsEUKk+IteIfRJhLzlOEPhnJlprEjtHkOqYV32wErkQ7u7r3 iAEqQIxzgJH6z9Thhy7uW7OH8JxBEx2NCV8yj9Bfgc3Jr87gXzhe56Fvq4vDAFcbDZrV HOFIHtjb0Z32RKyYevI4wo2kN8HohkIengTEvZhRPuPOxGBJI6KpIwd7YuFUAcH3Ubbq kR4zIOokjgjrPKFIU3P1XJgjk/gR9omh2/ga7IWDF/1RoEe/mIQBVVLum1sxn//5Shgb qKzGzJ3dWcQhVyd9/VMNq0fuveuGkH3DBeabvZkduKQ1uENIOK/zcDibUxnaQM67hHDd CrwQ== X-Gm-Message-State: AOJu0Yw4PNnqrFtaW//gqsFdhsBm4+QehQyWbuncBAifuWf8cev1xnVN 6FT0XqwNXB7c4Obe4SqLolXiwGEgBwJXMMiP9zEkuvbkWHCcllCVXLW8bq9kbyE= X-Gm-Gg: ASbGnctqu9iydQ2abiccleCRz/1+Lkg+ixk4Fa6Zdg0niqJywtteOLrBboiP4nApN+P jTUKex5aLyxqRO7yplCcAAiW4zTcshTx5YoLmqo7GByf5gDuV7lsywT0qMm+AD1/1NyR7Kz4ZmB dFRQHkTgmRjXuWhZV4fk0KiI46DyPGE22xBbH1mH5jmeKC9FsztIW9PfO3+q0L/8Wf4d5+gKid3 kBnnbWyoChZyh1pBSEKIPnrYIUg+FMY4sylM2V2nsSxwYw+kfRQOVSW3AFR6JzVgtHpwdBVR0ml Ld6FUx61+bUUf4eqHo1RNCYbryHRL8pGm1I3yegrcn5OV2E= X-Received: by 2002:a05:6402:3784:b0:5db:e7eb:1b34 with SMTP id 4fb4d7f45d1cf-5e59f3d67famr765205a12.13.1741127093846; Tue, 04 Mar 2025 14:24:53 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e4c3bb5ad8sm8715799a12.34.2025.03.04.14.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 14:24:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 32B946082D; Tue, 4 Mar 2025 22:24:41 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Li-Wen Hsu , Peter Maydell , Laurent Vivier , qemu-arm@nongnu.org, Alexandre Iooss , Paolo Bonzini , Richard Henderson , Riku Voipio , Warner Losh , Brian Cain , Mahmoud Mandour , Kyle Evans , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ed Maste , Pierrick Bouvier , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth Subject: [PATCH v2 18/32] gitlab: add a new build_unit job to track build size Date: Tue, 4 Mar 2025 22:24:25 +0000 Message-Id: <20250304222439.2035603-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304222439.2035603-1-alex.bennee@linaro.org> References: <20250304222439.2035603-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x534.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We want to reduce the total number of build units in the system to get on our way to a single binary. It will help to have some numbers so lets add a job to gitlab to track our progress. Signed-off-by: Alex Bennée Cc: Pierrick Bouvier Cc: Philippe Mathieu-Daudé Cc: Richard Henderson --- v2 - do all json in python --- .gitlab-ci.d/check-units.py | 66 ++++++++++++++++++++++++++++++++++ .gitlab-ci.d/static_checks.yml | 22 ++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 .gitlab-ci.d/check-units.py diff --git a/.gitlab-ci.d/check-units.py b/.gitlab-ci.d/check-units.py new file mode 100755 index 0000000000..268a4118d5 --- /dev/null +++ b/.gitlab-ci.d/check-units.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# +# check-units.py: check the number of compilation units and identify +# those that are rebuilt multiple times +# +# Copyright (C) 2025 Linaro Ltd. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from os import access, R_OK, path +from sys import argv, exit +import json +from collections import Counter + + +def extract_build_units(cc_path): + """ + Extract the build units and their counds from compile_commands.json file. + + Returns: + Hash table of ["unit"] = count + """ + + j = json.load(open(cc_path, 'r')) + files = [f['file'] for f in j] + build_units = Counter(files) + + return build_units + + +def analyse_units(build_units): + """ + Analyse the build units and report stats and the top 10 rebuilds + """ + + print(f"Total source files: {len(build_units.keys())}") + print(f"Total build units: {sum(units.values())}") + + # Create a sorted list by number of rebuilds + sorted_build_units = sorted(build_units.items(), + key=lambda item: item[1], + reverse=True) + + print("Most rebuilt units:") + for unit, count in sorted_build_units[:20]: + print(f" {unit} built {count} times") + + print("Least rebuilt units:") + for unit, count in sorted_build_units[-10:]: + print(f" {unit} built {count} times") + + +if __name__ == "__main__": + if len(argv) != 2: + script_name = path.basename(argv[0]) + print(f"Usage: {script_name} ") + exit(1) + + cc_path = argv[1] + if path.isfile(cc_path) and access(cc_path, R_OK): + units = extract_build_units(cc_path) + analyse_units(units) + exit(0) + else: + print(f"{cc_path} doesn't exist or isn't readable") + exit(1) diff --git a/.gitlab-ci.d/static_checks.yml b/.gitlab-ci.d/static_checks.yml index c0ba453382..c3ed6de453 100644 --- a/.gitlab-ci.d/static_checks.yml +++ b/.gitlab-ci.d/static_checks.yml @@ -70,3 +70,25 @@ check-rust-tools-nightly: expire_in: 2 days paths: - rust/target/doc + +check-build-units: + extends: .base_job_template + stage: build + image: $CI_REGISTRY_IMAGE/qemu/debian:$QEMU_CI_CONTAINER_TAG + needs: + job: amd64-debian-container + before_script: + - source scripts/ci/gitlab-ci-section + - section_start setup "Install Tools" + - apt install --assume-yes --no-install-recommends jq + - section_end setup + script: + - mkdir build + - cd build + - section_start configure "Running configure" + - ../configure + - cd .. + - section_end configure + - section_start analyse "Analyse" + - .gitlab-ci.d/check-units.py build/compile_commands.json + - section_end analyse