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

How to fix OOM #168

Open
CLOVIS-AI opened this issue Feb 14, 2024 · 6 comments
Open

How to fix OOM #168

CLOVIS-AI opened this issue Feb 14, 2024 · 6 comments
Labels
documentation Improvements or additions to documentation

Comments

@CLOVIS-AI
Copy link
Contributor

Hi!

I'm using the version 2.0.0. In CI, I'm seeing:

* What went wrong:
Execution failed for task ':compat:compat-ktor:dokkatooGeneratePublicationHtml'.
> A failure occurred while executing dev.adamko.dokkatoo.workers.DokkaGeneratorWorker
   > Java heap space

How much memory should I configure? How can I configure it?

@aSemy
Copy link
Contributor

aSemy commented Feb 14, 2024

hey @CLOVIS-AI 👋. Unfortunately Dokka is quite memory intensive, depending on the project. How many subprojects do you have? Are there a lot of dependencies?

Specifying memory options

Changing the JVM memory args is different depending on your version of Dokkatoo.

v2.0.0

The memory for the worker process can be specified in the tasks:

// build.gradle.kts

tasks.withType<DokkatooGenerateTask>.configureEach {
  workerMinHeapSize.set("512m")
  workerMaxHeapSize.set("2g")
}

v2.1.0

In v2.1.0 the options have been changed a bit. You can choose run Dokka in the same Gradle process, so if you increase the memory for a Gradle build (set org.gradle.jvmargs=... in gradle.properties), then that will be shared with the Dokka generator.

// build.gradle.kts

dokkatoo {
  // run Dokka Generator in the current Gradle build process
  dokkaGeneratorIsolation.set(
    ClassLoaderIsolation()
  )
}

Alternatively, you can continue to use a separate process for Dokka, and specify the memory in the buildscript DSL:

// build.gradle.kts

dokkatoo {
  dokkaGeneratorIsolation.set(
    ProcessIsolation {
      debug.set(false)
      enableAssertions.set(true)
      minHeapSize.set("512m")
      maxHeapSize.set("1g")
      // ...
    }
  )
}

Recommendations

I am not an expert at all when it comes to Java memory usage or tuning!

@aSemy aSemy added the documentation Improvements or additions to documentation label Feb 14, 2024
@aSemy
Copy link
Contributor

aSemy commented Feb 14, 2024

I have vague plans to create the documentation more thorough, and JVM args, particularly memory settings, would be a thing good to document.

@CLOVIS-AI
Copy link
Contributor Author

Do you know if it would be possible to display the Dokka memory usage in a build scan? The memory usage for the Gradle daemon itself is included, I'm not sure if it's possible to add that information.

@aSemy
Copy link
Contributor

aSemy commented Feb 15, 2024

Do you know if it would be possible to display the Dokka memory usage in a build scan?

I have no idea, but I think it's a good feature request for Gradle Build Scans!

@CLOVIS-AI
Copy link
Contributor Author

Well, the great news is updating to Dokkatoo 2.1.0 fixed the OOM. Still no idea what it was caused by, but it's not that important now.

Please ping me if this info ever becomes available in logs/build scans :) I don't know your workflow with issues, but I got all the info I needed, so I think this can be closed?

@aSemy
Copy link
Contributor

aSemy commented Feb 20, 2024

Good to hear!

I'm happy to leave this open for now in lieu of writing proper documentation.

I've also been wondering about instrumenting Dokka Generator and figuring out some statistics. It should be possible to inject OpenTelemetry automatically. Though I'm not sure if there's a nice way to view the metrics. It would be nice to be able to do so without spinning up Prometheus and Grafana.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants