Kotlin / dokka

API documentation engine for Kotlin

Home Page:https://kotl.in/dokka

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve dokka performance (documentable model generation)

owengray-google opened this issue · comments

With the recent re-architecture, generating documentable model was made single-threaded. This poses a major performance regression for us, of at least 100% runtime.

There also appear to be some low-handing fruit for performance improvements for that step:

  1. 8% of our runtime is in DokkaDescriptorVisitor.getDescriptorsWithKind-> filterDescriptorsInSourceSet -> UnixPath.toRealPath. I'm not sure toRealPath is even necessary?
  2. 8-18% of our runtime is in DokkaDescriptorVisitor.toBound() -> kotlin.types.WrappedType.getConstructor(); I suspect if nothing else types are often reused and something here could be cached.
  3. 1-6.4% of our runtime is in psi.KtFile.getPackageDirectiveByTree; this feels like it could be cached or use a heuristic. This seems to be much worse on KMP inputs.
  4. 1-3% of our runtime is transformDocumentationModelBeforeMerge, mostly in filters you provide; I hope some of these filters or their invocations could be merged or something? This seems to be much worse on KMP inputs.
  5. org.jetbrains.kotlin.resolve.FunctionDescriptorResolver.createValueParameterDescriptors is taking much more time than I would expect. It seems like this should be cacheable? I would expect many value classes to be reused.
  6. 3-7.5% of total runtime is getHierarchicalMethodSignature. This seems to be much worse on KMP inputs.