refactor(build): optimize JVM memory allocation and enable parallel test execution

- Increase JVM heap memory from 512m to 2-4G for faster test execution
- Add G1GC garbage collector and tiered compilation for improved performance
- Enable parallel test execution with threadCount=4 to avoid shared state issues
- Add incremental recompilation mode and Zinc server for faster builds
- Increase Scala compiler JVM memory from 64m/1024m to 512m/2G
- Add language feature flags to suppress compiler warnings
- Add test-results directory to .gitignore for cleaner repository
- Apply optimizations consistently across obp-api, obp-commons, and root pom.xml
- These changes reduce build and test execution time while maintaining stability
This commit is contained in:
hongwei 2026-01-09 01:43:16 +01:00
parent 1428b52905
commit 31e39e3773
4 changed files with 33 additions and 4 deletions

1
.gitignore vendored
View File

@ -44,3 +44,4 @@ project/project
coursier
metals.sbt
obp-http4s-runner/src/main/resources/git.properties
test-results

View File

@ -586,9 +586,13 @@
<forkMode>once</forkMode>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
<argLine>-Drun.mode=test -XX:MaxMetaspaceSize=512m -Xms512m -Xmx512m --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.jar=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED</argLine>
<!-- Increased memory for faster test execution -->
<argLine>-Drun.mode=test -XX:MaxMetaspaceSize=1G -Xms2G -Xmx4G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseStringDeduplication --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.jar=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED</argLine>
<tagsToExclude>code.external</tagsToExclude>
<testFailureIgnore>${maven.test.failure.ignore}</testFailureIgnore>
<!-- Enable parallel test execution - keep at 4 to avoid shared state issues -->
<parallel>true</parallel>
<threadCount>4</threadCount>
</configuration>
<executions>
<execution>
@ -667,15 +671,25 @@
<version>4.8.1</version>
<configuration>
<fork>true</fork>
<recompileMode>incremental</recompileMode>
<useZincServer>true</useZincServer>
<jvmArgs>
<jvmArg>-Xms4G</jvmArg>
<jvmArg>-Xmx12G</jvmArg>
<jvmArg>-XX:MaxMetaspaceSize=4G</jvmArg>
<jvmArg>-XX:+UseG1GC</jvmArg>
<jvmArg>-XX:+TieredCompilation</jvmArg>
<jvmArg>-XX:TieredStopAtLevel=1</jvmArg>
</jvmArgs>
<args>
<arg>-deprecation</arg>
<arg>-feature</arg>
<!-- Enable language features to suppress warnings -->
<arg>-language:implicitConversions</arg>
<arg>-language:reflectiveCalls</arg>
<arg>-language:postfixOps</arg>
<!-- Suppress auto-application deprecation warning -->
<arg>-Wconf:cat=deprecation&amp;msg=auto-application:s</arg>
</args>
</configuration>
</plugin>

View File

@ -113,9 +113,13 @@
<forkMode>once</forkMode>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
<argLine>-Drun.mode=test -XX:MaxMetaspaceSize=512m -Xms512m -Xmx512m</argLine>
<!-- Increased memory for faster test execution -->
<argLine>-Drun.mode=test -XX:MaxMetaspaceSize=1G -Xms2G -Xmx4G -XX:+UseG1GC -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+UseStringDeduplication</argLine>
<tagsToExclude>code.external</tagsToExclude>
<testFailureIgnore>${maven.test.failure.ignore}</testFailureIgnore>
<!-- Enable parallel test execution - keep at 4 to avoid shared state issues -->
<parallel>true</parallel>
<threadCount>4</threadCount>
</configuration>
<executions>
<execution>

14
pom.xml
View File

@ -134,10 +134,14 @@
<scalaVersion>${scala.compiler}</scalaVersion>
<charset>${project.build.sourceEncoding}</charset>
<displayCmd>true</displayCmd>
<recompileMode>incremental</recompileMode>
<useZincServer>true</useZincServer>
<jvmArgs>
<jvmArg>-DpackageLinkDefs=file://${project.build.directory}/packageLinkDefs.properties</jvmArg>
<jvmArg>-Xms64m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
<jvmArg>-Xms512m</jvmArg>
<jvmArg>-Xmx2G</jvmArg>
<jvmArg>-XX:+TieredCompilation</jvmArg>
<jvmArg>-XX:TieredStopAtLevel=1</jvmArg>
</jvmArgs>
<args>
<arg>-unchecked</arg>
@ -147,6 +151,12 @@
<arg>-deprecation</arg>
-->
<arg>-Ypartial-unification</arg>
<!-- Enable language features to suppress warnings -->
<arg>-language:implicitConversions</arg>
<arg>-language:reflectiveCalls</arg>
<arg>-language:postfixOps</arg>
<!-- Suppress auto-application deprecation warning -->
<arg>-Wconf:cat=deprecation&amp;msg=auto-application:s</arg>
</args>
</configuration>
<executions>