From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Thomas Huth" <thuth@redhat.com>
Subject: [PULL 18/31] gitlab: add a new build_unit job to track build size
Date: Sat, 8 Mar 2025 21:53:13 +0000 [thread overview]
Message-ID: <20250308215326.2907828-19-alex.bennee@linaro.org> (raw)
In-Reply-To: <20250308215326.2907828-1-alex.bennee@linaro.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.
Cc: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20250304222439.2035603-19-alex.bennee@linaro.org>
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} <path_to_compile_commands.json>")
+ 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
--
2.39.5
next prev parent reply other threads:[~2025-03-08 22:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 21:52 [PULL 00/31] testing, plugin and maintainer updates Alex Bennée
2025-03-08 21:52 ` [PULL 01/31] tests/functional: move aarch64 GPU test into own file Alex Bennée
2025-03-08 21:52 ` [PULL 02/31] tests/functional: factor out common code in gpu test Alex Bennée
2025-03-08 21:52 ` [PULL 03/31] tests/functional: ensure we have a GPU device for tests Alex Bennée
2025-03-08 21:52 ` [PULL 04/31] tests/functional: bail early if vkmark hangs Alex Bennée
2025-03-08 21:53 ` [PULL 05/31] tests/functional: skip vulkan tests with nVidia Alex Bennée
2025-03-08 21:53 ` [PULL 06/31] tests/functional: expand tests to cover virgl Alex Bennée
2025-03-08 21:53 ` [PULL 07/31] tests/functional: update the aarch64_virg_gpu images Alex Bennée
2025-03-08 21:53 ` [PULL 08/31] plugins: add explicit dependency in functional tests Alex Bennée
2025-03-08 21:53 ` [PULL 09/31] tests/functional: Introduce the dso_suffix() helper Alex Bennée
2025-03-08 21:53 ` [PULL 10/31] tests/functional: Allow running TCG plugins tests on non-Linux/BSD hosts Alex Bennée
2025-03-08 21:53 ` [PULL 11/31] libvirt-ci: bump to latest for vulkan-tools Alex Bennée
2025-03-08 21:53 ` [PULL 12/31] tests/vm: bump timeout for shutdown Alex Bennée
2025-03-08 21:53 ` [PULL 13/31] tests/tcg: mark test-vma as a linux-only test Alex Bennée
2025-03-08 21:53 ` [PULL 14/31] tests/tcg: add message to _Static_assert in test-avx Alex Bennée
2025-03-08 21:53 ` [PULL 15/31] tests/tcg: fix constraints in test-i386-adcox Alex Bennée
2025-03-08 21:53 ` [PULL 16/31] tests/tcg: enable -fwrapv for test-i386-bmi Alex Bennée
2025-03-08 21:53 ` [PULL 17/31] tests/tcg: Suppress compiler false-positive warning on sha1.c Alex Bennée
2025-03-08 21:53 ` Alex Bennée [this message]
2025-03-08 21:53 ` [PULL 19/31] tests/functional: add boot error detection for RME tests Alex Bennée
2025-03-08 21:53 ` [PULL 20/31] plugins/api: use qemu_target_page_mask() to get value Alex Bennée
2025-03-08 21:53 ` [PULL 21/31] plugins/loader: populate target_name with target_name() Alex Bennée
2025-03-08 21:53 ` [PULL 22/31] include/qemu: plugin-memory.h doesn't need cpu-defs.h Alex Bennée
2025-03-08 21:53 ` [PULL 23/31] plugins/api: clean-up the includes Alex Bennée
2025-03-08 21:53 ` [PULL 24/31] plugins/plugin.h: include queue.h Alex Bennée
2025-03-08 21:53 ` [PULL 25/31] plugins/loader: compile loader only once Alex Bennée
2025-03-08 21:53 ` [PULL 26/31] plugins/api: split out binary path/start/end/entry code Alex Bennée
2025-03-08 21:53 ` [PULL 27/31] plugins/api: split out the vaddr/hwaddr helpers Alex Bennée
2025-03-08 21:53 ` [PULL 28/31] plugins/api: split out time control helpers Alex Bennée
2025-03-08 21:53 ` [PULL 29/31] plugins/api: build only once Alex Bennée
2025-03-08 21:53 ` [PULL 30/31] plugins/core: make a single build unit Alex Bennée
2025-03-08 21:53 ` [PULL 31/31] MAINTAINERS: remove widely sanctioned entities Alex Bennée
2025-03-09 3:44 ` [PULL 00/31] testing, plugin and maintainer updates Stefan Hajnoczi
2025-03-09 21:02 ` Alex Bennée
2025-03-10 5:44 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250308215326.2907828-19-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).