From a5f31a5820b76a873812eaa9916b1a570703c798 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 11 May 2023 18:22:03 -0700 Subject: [PATCH] Only search for test suite jdk files once compatibility.mk is included 33 times on aosp, and 47 times on internal master. Each of these would run this shell command, and there would be an entry in the kati stamp file for each time it was run, causing this command to be run the 33/47 times every single build. This took ~0.2 seconds, which can be saved by only running it once. (However these ~0.2 seconds are parallelized with other parts of the stamp checking) Bug: 282079550 Test: m nothing Change-Id: I364836d1cb0cc26ca9116eda6d954170e1cb7761 --- core/tasks/tools/compatibility.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk index c770b34925..8ae2a9ae5a 100644 --- a/core/tasks/tools/compatibility.mk +++ b/core/tasks/tools/compatibility.mk @@ -44,10 +44,16 @@ test_tools += $(test_suite_tools) # The JDK to package into the test suite zip file. Always package the linux JDK. test_suite_jdk_dir := $(ANDROID_JAVA_HOME)/../linux-x86 +ifndef test_suite_jdk_files + # This file gets included many times, so make sure we only run the $(shell) once. + # Otherwise it will slow down every build due to all copies of it being rerun when kati + # checks the stamp file. + test_suite_jdk_files :=$= $(shell find $(test_suite_jdk_dir) -type f | sort) +endif test_suite_jdk := $(call intermediates-dir-for,PACKAGING,$(test_suite_name)_jdk,HOST)/jdk.zip $(test_suite_jdk): PRIVATE_JDK_DIR := $(test_suite_jdk_dir) $(test_suite_jdk): PRIVATE_SUBDIR := $(test_suite_subdir) -$(test_suite_jdk): $(shell find $(test_suite_jdk_dir) -type f | sort) +$(test_suite_jdk): $(test_suite_jdk_files) $(test_suite_jdk): $(SOONG_ZIP) $(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) -sha256