-
Notifications
You must be signed in to change notification settings - Fork 20
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
Formatting can fail depending on the number of input files #203
Comments
I can reproduce this issue in our project. With 0.0.13 the tasks finishes as expected. |
Can confirm this issue. Getting |
We also noticed, that the formatting can now take minutes and consumes a lot of RAM. Sometimes around 10GB |
Is this happening in 0.14.0 only? As if so this is most likely the culprit: If you confirm that this is not happening in 0.13, I'm leaning towards releasing 0.14.1 with the revert of #182 and get back to it in the future |
Yes, from my testing this is only happening in 0.0.14. I think the general implementation offers some nice advantages. Especially that it is now possible to set the version of the formatter manually by the plugin version. Is it possible to keep this or do you think it is better to completly revert the commit? Edit: |
@simonhauck one thing that would really be helpful would be to provide a reproducer. |
Isn't the integration test above sufficient? It fails way before 10k files. Some notes after poking around:
Generic error during file processing: java.lang.OutOfMemoryError: Java heap space
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.initCEN(ZipFileSystem.java:1559)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:179)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getZipFileSystem(ZipFileSystemProvider.java:125)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:120)
at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:528)
at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:400)
at org.jetbrains.kotlin.com.intellij.ide.plugins.DescriptorLoadingContext.open(DescriptorLoadingContext.java:40)
at org.jetbrains.kotlin.com.intellij.ide.plugins.PluginDescriptorLoader.loadDescriptorFromJar(PluginDescriptorLoader.java:84)
at org.jetbrains.kotlin.com.intellij.ide.plugins.PluginManagerCore.registerExtensionPointAndExtensions(PluginManagerCore.java:1325)
at org.jetbrains.kotlin.com.intellij.core.CoreApplicationEnvironment.registerExtensionPointAndExtensions(CoreApplicationEnvironment.java:287)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerApplicationExtensionPointsAndExtensionsFrom(KotlinCoreEnvironment.kt:625)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createApplicationEnvironment(KotlinCoreEnvironment.kt:595)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironment(KotlinCoreEnvironment.kt:505)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironmentForProduction(KotlinCoreEnvironment.kt:492)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:440)
at com.facebook.ktfmt.format.Parser.<clinit>(Parser.kt:57)
at com.facebook.ktfmt.format.Formatter.sortedAndDistinctImports(Formatter.kt:143)
at com.facebook.ktfmt.format.Formatter.format(Formatter.kt:90)
at com.ncorti.ktfmt.gradle.tasks.worker.KtfmtFormatter.format(KtfmtFormatter.kt:41)
at com.ncorti.ktfmt.gradle.tasks.worker.KtfmtWorkAction.processFile(KtfmtWorkAction.kt:61)
at com.ncorti.ktfmt.gradle.tasks.worker.KtfmtWorkAction.execute(KtfmtWorkAction.kt:48)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:54)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:48)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:48)
at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.lambda$execute$0(IsolatedClassloaderWorkerFactory.java:57)
at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$$Lambda$1789/0x0000000800d5ba28.execute(Unknown Source)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41) |
From my point of view, the above test would be sufficient. It triggers the same exception when I tested it. But @cortinico if you would still prefer an example with a real project I can still do it. I read through the resources of @asapha and in this issue is a similar bug linked, that was solved with process isolation. The pull request is here. I forked this repository and did some testing that you can find here and the relevant commit here I tested all 3 isolation strategies and timed their execution time:
With these results, one of these 3 options seem the most suitable to me:
What is your opinion on that? |
@simonhauck thank you very much for you thorough investigation and testing! I believe we should offer the Gradle property you're exposing in e74a8a0 I would default to |
🐛 Describe the bug
Running
ktfmtFormatMain
on multiple files fails.The task manages to format a few files, then it hangs with error messages such as
[ktfmt] e: Generic error during file processing
or[ktfmt] Failed to analyse:
e.g:
💣 Steps to reproduce
Run this test in
KtfmtFormatTaskIntegrationTest
It fails when
n
is as low as 30 on my machine.📱 Tech info
git rev-parse HEAD
->e8f927180ffc388978c9e663fb4f35fcdeba19f2
openjdk 20.0.2 2023-07-18
macOS Version 13.6
When upgrading to 0.14, I can no longer run ktfmt on my whole codebase.
The text was updated successfully, but these errors were encountered: