Skip to content

Commit 9560fc2

Browse files
mattst88ralight
authored andcommitted
buildtest.py: Use ccache
Reduces the time to run `./buildtest.py` on my 8-core laptop from 25 minutes to 7 minutes. ``` # Before, without ccache $ time ./buildtest.py [...] ./buildtest.py 5844.08s user 755.75s system 434% cpu 25:17.99 total # After, with ccache, empty cache. $ time ./buildtest.py [...] ./buildtest.py 1620.97s user 472.66s system 482% cpu 7:13.54 total ``` The `ccache -s` status after building once from an empty cache shows just how much duplicated work is performed: 83.00% cache hits! ``` $ ccache -s Cacheable calls: 12538 / 22769 (55.07%) Hits: 10407 / 12538 (83.00%) Direct: 9093 / 10407 (87.37%) Preprocessed: 1314 / 10407 (12.63%) Misses: 2131 / 12538 (17.00%) Uncacheable calls: 10231 / 22769 (44.93%) Local storage: Cache size (GiB): 0.1 / 5.0 ( 1.97%) Hits: 10407 / 12538 (83.00%) Misses: 2131 / 12538 (17.00%) ``` Signed-off-by: Matt Turner <mattst88@gmail.com>
1 parent 6546b00 commit 9560fc2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.github/workflows/build-variants.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
run: |
2424
sudo apt-get update
2525
sudo apt-get install -y \
26+
ccache \
2627
docbook-xsl \
2728
libargon2-dev \
2829
libc-ares-dev \

buildtest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@
3636
import random
3737
import subprocess
3838

39+
env = os.environ.copy()
40+
env['CC'] = "ccache gcc"
41+
env['CXX'] = "ccache g++"
42+
3943
def run_test(msg, opts):
4044
subprocess.run(["make", "clean"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
4145
print("%s: %s" % (msg, str(opts)))
4246
args = ["make", "test-compile", "-j%d" % (os.cpu_count())] + opts
43-
proc = subprocess.run(args, stdout=subprocess.DEVNULL)
47+
proc = subprocess.run(args, stdout=subprocess.DEVNULL, env=env)
4448
if proc.returncode != 0:
4549
raise RuntimeError("BUILD FAILED: %s" % (' '.join(args)))
4650

0 commit comments

Comments
 (0)