dokka icon indicating copy to clipboard operation
dokka copied to clipboard

Revisit Gradle Workers usage in Dokka Gradle Plugin

Open whyoleg opened this issue 4 months ago • 4 comments

After the changes from #4182, it becomes unclear what the real benefits of using Gradle Workers are if we still need to do a lot of additional configuration and might even improve performance by using something similar to the KGP approach with ClassLoadersCachingBuildService.

More discussions on pros/cons: https://github.com/Kotlin/dokka/pull/4182#discussion_r2262973620

whyoleg avatar Aug 18 '25 16:08 whyoleg

I discussed ClassLoadersCachingBuildService more with @abdulowork and he suggested Dokka avoids it, because re-using classloaders could interfere with Coroutines mechanisms (please correct me if I'm wrong @abdulowork!)

That aside, we should still look at whether DGP could not use the Worker API and instead always use a custom classloader.

adam-enko avatar Aug 18 '25 18:08 adam-enko

Hopefully the memory leak in Gradle is fixed by https://github.com/gradle/gradle/pull/34963 and DGP can use classloader isolated workers as the default mode, and we don't have to manually implement workarounds.

adam-enko avatar Nov 03 '25 14:11 adam-enko

@adam-enko, correct me if I'm wrong, but this will be fixed only for Gradle 9.3+, while DGP supports Gradle 7.6+. So I don't think that it will be enough for us to switch to ClassLoader isolation by default.

Additionally, as I recall, we will also need a fix for https://github.com/gradle/gradle/issues/34442 to use our own stdlib version.

whyoleg avatar Nov 03 '25 15:11 whyoleg

correct me if I'm wrong, but this will be fixed only for Gradle 9.3+, while DGP supports Gradle 7.6+. So I don't think that it will be enough for us to switch to ClassLoader isolation by default.

Correct. But we could consider a conditional default. E.g. use process-isolated workers by default for older Gradle versions, and classpath-isolated for newer Gradles.

Additionally, as I recall, we will also need a fix for gradle/gradle#34442 to use our own stdlib version.

We'd need to workaround the kotlin-stdlib substitution for both process and classpath isolated workers.

adam-enko avatar Nov 17 '25 15:11 adam-enko