From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH 1/2] ci: Rework ccache test
Date: Tue, 7 Jun 2022 07:24:04 +0200 [thread overview]
Message-ID: <20220607052405.28963-2-ubely@ilbers.de> (raw)
In-Reply-To: <20220607052405.28963-1-ubely@ilbers.de>
Previous ccache test implementation was based on comparing difference
between non-cached and cached build time. It is not reliable enough
because results may depend on overall CPU/disk load.
New implementation analyzes ccache statistics provided by */*/stats
files in ccache directory. Field with index 22 is used to check hits.
To reduce test time, we compile only `hello-isar` (and `libhello` as
the dependency) amd64 target during the test.
Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
testsuite/cibase.py | 33 ++++++++++++++++++++++++---------
testsuite/cibuilder.py | 3 +++
testsuite/citest.py | 2 +-
3 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/testsuite/cibase.py b/testsuite/cibase.py
index 2ffb8191..722d7bd2 100755
--- a/testsuite/cibase.py
+++ b/testsuite/cibase.py
@@ -46,32 +46,47 @@ class CIBaseTest(CIBuilder):
self.bitbake(targets, **kwargs)
def perform_ccache_test(self, targets, **kwargs):
+ def ccache_stats(dir, field):
+ # Look ccache source's 'src/core/Statistic.hpp' for field meanings
+ count = 0
+ for filename in glob.iglob(dir + '/**/stats', recursive=True):
+ if os.path.isfile(filename):
+ with open(filename,'r') as file:
+ content = file.readlines()
+ if (field < len(content)):
+ count += int(content[field])
+ return count
+
self.configure(ccache=True, **kwargs)
+ # Field that stores direct ccache hits
+ direct_cache_hit = 22
+
self.delete_from_build_dir('tmp')
+ self.delete_from_build_dir('sstate-cache')
self.delete_from_build_dir('ccache')
self.log.info('Starting build and filling ccache dir...')
- start = time.time()
self.bitbake(targets, **kwargs)
- first_time = time.time() - start
- self.log.info('Non-cached build: ' + str(round(first_time)) + 's')
+ hit1 = ccache_stats(self.build_dir + '/ccache', direct_cache_hit)
+ self.log.info('Ccache hits 1: ' + str(hit1))
self.delete_from_build_dir('tmp')
+ self.delete_from_build_dir('sstate-cache')
self.log.info('Starting build and using ccache dir...')
- start = time.time()
self.bitbake(targets, **kwargs)
- second_time = time.time() - start
- self.log.info('Cached build: ' + str(round(second_time)) + 's')
+ hit2 = ccache_stats(self.build_dir + '/ccache', direct_cache_hit)
+ self.log.info('Ccache hits 2: ' + str(hit2))
- speedup_k = 1.1
- if first_time / second_time < speedup_k:
- self.fail('No speedup after rebuild with ccache')
+ if hit2 <= hit1:
+ self.fail('Ccache was not used on second build')
# Cleanup
self.delete_from_build_dir('tmp')
+ self.delete_from_build_dir('sstate-cache')
self.delete_from_build_dir('ccache')
+ self.unconfigure()
def perform_sstate_test(self, image_target, package_target, **kwargs):
def check_executed_tasks(target, expected):
diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index bc48d47f..dfb0a376 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -107,6 +107,9 @@ class CIBuilder(Test):
f.write('BASE_REPO_KEY="file://' + gpg_pub_key + '"\n')
if distro_apt_premir:
f.write('DISTRO_APT_PREMIRRORS = "%s"\n' % distro_apt_premir)
+ if ccache:
+ f.write('USE_CCACHE = "1"\n')
+ f.write('CCACHE_TOP_DIR = "${TOPDIR}/ccache"\n')
# include ci_build.conf in local.conf
with open(self.build_dir + '/conf/local.conf', 'r+') as f:
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 16e38d07..9135475e 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -56,7 +56,7 @@ class CcacheTest(CIBaseTest):
:avocado: tags=ccache
"""
def test_ccache_rebuild(self):
- targets = ['mc:de0-nano-soc-bullseye:isar-image-base']
+ targets = ['mc:qemuamd64-bullseye:hello-isar']
self.init()
self.perform_ccache_test(targets)
--
2.20.1
next prev parent reply other threads:[~2022-06-07 5:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 5:24 [PATCH 0/2] Rework and enable " Uladzimir Bely
2022-06-07 5:24 ` Uladzimir Bely [this message]
2022-06-07 5:24 ` [PATCH 2/2] ci: Add ccache test to fast and full test groups Uladzimir Bely
2022-07-04 7:06 ` [PATCH 0/2] Rework and enable ccache test Anton Mikanovich
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=20220607052405.28963-2-ubely@ilbers.de \
--to=ubely@ilbers.de \
--cc=isar-users@googlegroups.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