Skip to content

Commit e946f2b

Browse files
committed
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 <[email protected]>
1 parent d70366d commit e946f2b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Diff for: .mvn/jvm.config

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-XX:-TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseParallelGC -Djava.awt.headless=true

Diff for: .mvn/maven.config

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-T2C
2+
--strict-checksums

Diff for: pom.xml

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<description>Parent for guava artifacts</description>
1313
<url>https://github.com/google/guava</url>
1414
<properties>
15+
<!-- Enable parallel test execution -->
16+
<parallel>all</parallel>
17+
<perCoreThreadCount>false</perCoreThreadCount>
18+
<threadCount>48</threadCount>
1519
<!-- Override this with -Dtest.include="**/SomeTest.java" on the CLI -->
1620
<test.include>%regex[.*.class]</test.include>
1721
<truth.version>1.4.2</truth.version>
@@ -31,6 +35,7 @@
3135
<otherVariant.version>HEAD-android-SNAPSHOT</otherVariant.version>
3236
<otherVariant.jvmEnvironment>android</otherVariant.jvmEnvironment>
3337
<otherVariant.jvmEnvironmentVariantName>android</otherVariant.jvmEnvironmentVariantName>
38+
<surefire.rerunFailingTestsCount>3</surefire.rerunFailingTestsCount>
3439
</properties>
3540
<issueManagement>
3641
<system>GitHub Issues</system>
@@ -230,7 +235,7 @@
230235
</plugin>
231236
<plugin>
232237
<artifactId>maven-surefire-plugin</artifactId>
233-
<version>2.7.2</version>
238+
<version>3.2.5</version>
234239
<configuration>
235240
<includes>
236241
<include>${test.include}</include>
@@ -249,6 +254,8 @@
249254
<!-- Set max heap for tests. -->
250255
<!-- Catch dependencies on the default locale by setting it to hi-IN. -->
251256
<argLine>-Xmx1536M -Duser.language=hi -Duser.country=IN ${test.add.opens}</argLine>
257+
<reuseForks>true</reuseForks>
258+
<forkCount>2C</forkCount>
252259
</configuration>
253260
</plugin>
254261
<plugin>

0 commit comments

Comments
 (0)