From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7106364625045684224 X-Received: by 2002:ad4:4433:0:b0:464:4626:7a85 with SMTP id e19-20020ad44433000000b0046446267a85mr20149216qvt.52.1654579449653; Mon, 06 Jun 2022 22:24:09 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6214:291:b0:46a:6282:90bd with SMTP id l17-20020a056214029100b0046a628290bdls3357516qvv.10.gmail; Mon, 06 Jun 2022 22:24:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUswoF8mS25yIGHSPFiHWL6SAQ7xkL76AZw/A+NFsYDqpP4iEUjamSqC/0H/MIPohMdkoL X-Received: by 2002:a0c:fa81:0:b0:461:e391:820b with SMTP id o1-20020a0cfa81000000b00461e391820bmr75030966qvn.6.1654579449108; Mon, 06 Jun 2022 22:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654579449; cv=none; d=google.com; s=arc-20160816; b=yq5YvxbTzob9l8Hv1/7tObAkLQ61MRdGu0VD22e7dbIt8XR02znlw2MI3VWztmA9N3 uKYIXdbMzqHmFS0JeBE0gVw4gchx9BGWdz6RnM8iSCjIyxax2ZNT+c1o+urDlz7mSrDw WMSA7vTzRZOTEo0/6SlezmAaJMGACd1W21k9aMV3B3YXfBAsFI/hgsk0BjdxR6m3dVNb xFNm4a3lto9dua5LLV0wIaKUkG25A4Qj8yuvjy2KPbglx+GWgTKve+0ueAMG/eJpkvVQ trK3IglAqYw1xuWmf8m3L/xg6FoelyorL16LndwZNIayd1JxpL731itw4nU3fwkGq2Fr g7WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=jKADb4NGDAMglo/6oANQoz9EzP4VS66fs/bHXJZQmxs=; b=QZJKwSjDOiblcR9ZZezcqT0VCgt1u97OER423Ck1D0Mqzu7wleYV824g6q5+N5Of80 +yGkCLbxbHN6pf6wYjPs6n5GgqXkTL/a4Q/1B7dNdZJPaqY69wmT0mycQDoxB/06xMCL 9S1h+NtnS6SE6qXyjZrtFMW4aDQLajHgrlbVBuK4KyxPi7ltMWIlJfuMbhvE5scFYXUG FpXzcmL09SaKcipL+aOCB60zzNf3KVCAFAxcnhn2GFfKQ/M4yNJECJ0EWCxAJ9SQGlvd BcZHEjD/QVZSjB62CP3L2hVI1S3oqGRGm6ZeRKVz1kygTkkoKDADLOJrbcsEZOyXKRgb IJ4A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id q4-20020a05620a0d8400b006a585be8750si744609qkl.3.2022.06.06.22.24.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jun 2022 22:24:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from baighyz.m.ilbers.de (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 2575O53J029926 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 7 Jun 2022 07:24:06 +0200 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH 1/2] ci: Rework ccache test Date: Tue, 7 Jun 2022 07:24:04 +0200 Message-Id: <20220607052405.28963-2-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220607052405.28963-1-ubely@ilbers.de> References: <20220607052405.28963-1-ubely@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: eYiZ16w8uM3T 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 --- 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