Skip to content

Performance regression with Kotest 5.7.x classpath scanning #3746

@easimon

Description

@easimon

Since Kotest 5.7, classpath scanning for Extensions and Config has become very slow, adding multiple minutes to a test run.

This does NOT seem related to #3670

Tested Kotest versions

5.6.2 vs. 5.7.2

Note

Since it is not a public project where I noticed the issue first, I can't give access to the sources.
I also did not (yet) check on any other project yet, if that issue is reproducible there as well. I will add this if I find a public reproducer.

Description

I have a small/medium sized Spring Boot Application, using Maven as a build tool. The project does not have any Kotest specific configuration (no AbstractProjectConfig, no kotest.properties).

Prior to Kotest 5.7, this setup went well, and also auto-registered the SpringAutowireConstructorExtension, which we use heavily for injecting beans in Spring integration tests.

Now, with Kotest 5.7.2, Maven makes a large pause during test startup (see below).

Executing ./mvnw test makes a pause of multiple minutes between the TESTS banner and actually executing tests in Kotest 5.7.2. When using Kotest 5.6.2 (everything else the same), the pause is only a few seconds. See example logs below.

It seems to be depending on the size of the project (or amount of dependencies, or tests...?), but the pause makes the major contribution to the total runtime of ./mvnw test. In one project, the pause is 8 minutes of about 11 total execution time, in the other it is about 3:30 of 4:30 minutes.

Workaround

I found, that, if I disable the classpath scanning by adding a kotest.properties like below, and add a ProjectConfig to register the SpringAutowireConstructorExtension manually, the pause vanishes. If I set one of the flags to false, the pause is approximately half as long.

So it seems the classpath scanning feature (which itself predates 5.7) has received a major performance regression in 5.7.

kotest.framework.classpath.scanning.config.disable=true
kotest.framework.classpath.scanning.autoscan.disable=true
kotest.framework.config.fqn=my.path.to.KotestConfiguration

Details

Timed output of ./mvnw test | ts using 5.7.2

Oct 26 13:44:36 [INFO] --- surefire:3.2.1:test (default-test) @ ... ---
Oct 26 13:44:37 [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
Oct 26 13:44:37 [INFO] 
Oct 26 13:44:37 [INFO] -------------------------------------------------------
Oct 26 13:44:37 [INFO]  T E S T S
Oct 26 13:44:37 [INFO] -------------------------------------------------------
Oct 26 13:48:04 [INFO] Running ... (first test class name)

Timed output of ./mvnw test | ts using 5.6.2

Oct 26 13:56:31 [INFO] --- surefire:3.2.1:test (default-test) @ ... ---
Oct 26 13:56:31 [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
Oct 26 13:56:31 [INFO] 
Oct 26 13:56:31 [INFO] -------------------------------------------------------
Oct 26 13:56:31 [INFO]  T E S T S
Oct 26 13:56:31 [INFO] -------------------------------------------------------
Oct 26 13:56:37 [INFO] Running ... (first test class name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Issues that report a problem or error in the code.framework 🏗️Pertains to the core structure and components of the Kotest framework.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions