Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution fails with "Retried waiting for GCLocker too often allocating" #3895

Open
mgroth0 opened this issue Feb 26, 2024 · 7 comments
Open
Labels
documentation 📚 Matters related to creating or updating project documentation. extensions 🔋 Related to the extensions mechanisms within the testing framework
Milestone

Comments

@mgroth0
Copy link

mgroth0 commented Feb 26, 2024

When testing my module, it fails with errors like:

[4.776s][warning][gc,alloc] ClassGraph-worker-15: Retried waiting for GCLocker too often allocating 1026 words

This occurs for a module which does not define any Kottest tests. Simply adding kotest as a test dependency causes this error, and removing it as a dependency prevents the error.

This does not occur on all of my modules. I suspect it is only happen on those with a larger amount of items on the classpath.

Kotest version: 5.8.0
Gradle version: 8.6
Gradle-JVM version: temurin-20.0.2

@mgroth0
Copy link
Author

mgroth0 commented Feb 26, 2024

@mgroth0
Copy link
Author

mgroth0 commented Feb 26, 2024

I just discovered a workaround:

tasks.withType<Test>().configureEach {
    systemProperty("kotest.framework.classpath.scanning.config.disable","true")
    systemProperty("kotest.framework.classpath.scanning.autoscan.disable","true")
}

This prevents the error.

@mgroth0
Copy link
Author

mgroth0 commented Feb 26, 2024

My recommendation is that as an essential fix, Kotest should find a way to catch this exception and report a more informative error message to the user. Otherwise, the error message that is currently printed will confuse many people.

This will be a breaking change, but for future versions I suggest making classpath scanning features opt-in. If they are causing OOM-like errors, they must have a large performance cost. And from what I just read on the docs, the features they support are not essential for running basic tests. I think autoscanning is a great feature but it should just be opt-in. Users who do not get the error message I am getting here might incur performance costs that they do not realize, and their tests will run slower for reasons they do not understand.

@LeoColman LeoColman added extensions 🔋 Related to the extensions mechanisms within the testing framework documentation 📚 Matters related to creating or updating project documentation. labels Mar 3, 2024
@sksamuel
Copy link
Member

My recommendation is that as an essential fix, Kotest should find a way to catch this exception and report a more informative error message to the user. Otherwise, the error message that is currently printed will confuse many people.

This will be a breaking change, but for future versions I suggest making classpath scanning features opt-in. If they are causing OOM-like errors, they must have a large performance cost. And from what I just read on the docs, the features they support are not essential for running basic tests. I think autoscanning is a great feature but it should just be opt-in. Users who do not get the error message I am getting here might incur performance costs that they do not realize, and their tests will run slower for reasons they do not understand.

In 6.0, classpath scanning will be disabled by default.

@mgroth0
Copy link
Author

mgroth0 commented Apr 21, 2024

Hey @sksamuel, thank you for the update.

Just to confirm, will both of these be disabled by default in 6.0?

  • kotest.framework.classpath.scanning.config.disable
  • kotest.framework.classpath.scanning.autoscan.disable

@smocherla-brex
Copy link

smocherla-brex commented May 10, 2024

I did want to echo as well that in large repositories/projects, kotest ends up using a enormous amount of heap memory and it's a huge bottleneck in having test parallelism. Until we actually did heap dump analysis, it wasn't clear and we found out it was happening because of classgraph scanning of the whole classpath. It's possible other folks might run into it and it's not quite easy to find out - for existing 5.x versions it'd be good to highlight in the docs that the defaults can have a huge performance impact (memory wise).

Disabling this reduces our test heap usage quite a bit from 4B to ~1Gb, but even that seems large. It seems like classgraph is still used for loading some JAR files in memory, which results in OutofMemory errors. Is there a way to disable this so that we can reduce the memory usage further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📚 Matters related to creating or updating project documentation. extensions 🔋 Related to the extensions mechanisms within the testing framework
Projects
None yet
Development

No branches or pull requests

4 participants