From 0d243b63b341a2ef698c1e700db68aab30b62f8c Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Fri, 8 Mar 2024 16:58:13 -0800 Subject: [PATCH] chore(labs): improve build and test speed This changeset optimizes the Guava build significantly by enabling parallel build and test features supported by Maven. With these flags enabled, only a few tests exhibit flaky behavior; applying a sensible count of test retries (3) solves the problem. As a result, the testsuite can now be executed often, because it takes about 2 minutes to run. Building is also much faster. After benchmarking different configurations, 2-threads-per-core and 2-test-forks-per-core seems optimal: ``` [INFO] Guava Maven Parent ..................... SUCCESS [ 0.121 s] [INFO] Guava: Google Core Libraries for Java .. SUCCESS [ 9.681 s] [INFO] Guava BOM .............................. SUCCESS [ 0.120 s] [INFO] Guava Testing Library .................. SUCCESS [ 47.883 s] [INFO] Guava Unit Tests ....................... SUCCESS [01:57 min] <-- [INFO] Guava GWT compatible libs .............. SUCCESS [ 6.909 s] ``` When built and executed serially: ``` [INFO] Guava Maven Parent ..................... SUCCESS [ 0.129 s] [INFO] Guava: Google Core Libraries for Java .. SUCCESS [ 15.653 s] [INFO] Guava BOM .............................. SUCCESS [ 0.064 s] [INFO] Guava Testing Library .................. SUCCESS [01:26 min] [INFO] Guava Unit Tests ....................... SUCCESS [06:26 min] <-- [INFO] Guava GWT compatible libs .............. SUCCESS [ 11.092 s] ``` Benchmark hardware: - Apple M2 Max, 96GB RAM - macOS Sonoma 14.3.1 - GraalVM CE JVM 21.0.2 ``` openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30) OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing) ``` - chore: enable parallel build - chore: enable parallel test execution - chore: enable parallel gc for maven - chore: tune tiered compilation for maven - chore: tune thread count for maven - fix: enable test retries (max = 3) for parallel-flaky tests Signed-off-by: Sam Gammon --- .mvn/jvm.config | 1 + .mvn/maven.config | 2 ++ guava-tests/pom.xml | 4 ++++ pom.xml | 9 ++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .mvn/jvm.config create mode 100644 .mvn/maven.config diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 000000000000..8fc30111dd55 --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1 @@ +-XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseParallelGC -Djava.awt.headless=true \ No newline at end of file diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 000000000000..cc57db8375d4 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,2 @@ +-T2C +--strict-checksums diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index 8596221d8316..6aba9122f4e4 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -87,6 +87,10 @@ maven-surefire-plugin + + true + 2.5C + maven-jar-plugin diff --git a/pom.xml b/pom.xml index 79ecb39a58dc..fb3964861235 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,10 @@ Parent for guava artifacts https://github.com/google/guava + + all + false + 48 %regex[.*.class] 1.4.2 @@ -31,6 +35,7 @@ HEAD-android-SNAPSHOT android android + 3 GitHub Issues @@ -230,7 +235,7 @@ maven-surefire-plugin - 2.7.2 + 3.2.5 ${test.include} @@ -249,6 +254,8 @@ -Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.opens} + true + 2C