swiftlang / swift-docc-render

Web renderer for Swift-DocC documentation.
Apache License 2.0
313 stars 52 forks source link

Slow rendering of root-level pages #894

Closed steviki closed 1 month ago

steviki commented 2 months ago

Description

After switching to Xcode 16 to build documentation and previewing it locally, I noticed a slowdown when opening top-level pages that contain a lot of symbols (the symbol graphs are > 100MB).

I suspect https://github.com/swiftlang/swift-docc-render/pull/877/ to be the cause of this, as I compared swift-DEVELOPMENT-SNAPSHOT-2024-07-15-a (which doesn't seem to include that change and doesn't show the slowdown) and swift-DEVELOPMENT-SNAPSHOT-2024-07-22-a (which does include the changes from the PR and does show the slowdown)

This is reproducible using the following symbol graphs (that have been created with Xcode 16 RC): symbol-graphs.zip

I used the following command to generate and preview the documentation for the above symbol graphs:

git clone --single-branch --branch swift-DEVELOPMENT-SNAPSHOT-2024-07-22-a https://github.com/swiftlang/swift-docc-render-artifact.git
export DOCC_HTML_DIR="./swift-docc-render-artifact/dist"
mkdir "Empty.docc"
$(xcrun --find docc) preview "Empty.docc" \
  --output-dir "Documentation.doccarchive" \
  --additional-symbol-graph-dir "symbol-graphs" \
  --transform-for-static-hosting

Opening http://localhost:8080/documentation/pspdfkitui now takes multiple seconds to open and show content. Navigating to symbols then sometimes is a bit faster, but sometimes also takes a few seconds.

Executing the above but using the swift-DEVELOPMENT-SNAPSHOT-2024-07-15-a for the swift-docc-render-artifact repo doesn't exhibit that slowdown and pages are shown almost instantaneous.

Checklist

Expected Behavior

Rendering documentation for frameworks that have a lot of symbols should be fast and navigating to pages should show content fast.

Actual behavior

Rendering documentation for frameworks that have a lot of symbols is slow and navigating to pages sometimes takes a few seconds to show content.

Steps To Reproduce

No response

Swift-DocC-Render Version Information

No response

mportiz08 commented 1 month ago

Thanks for catching this @steviki — your steps to reproduce this are super helpful!

I think the PR introducing this performance change is actually #878 from what I'm seeing. I will need to dig into this a bit more, but I'm hoping there is an easy fix to address this without reverting that PR. I expect there may be a way of short circuiting the logic adding the additional rendering time since this example project isn't actually combining multiple catalogs together in its index.

mportiz08 commented 1 month ago

Unfortunately I think I was wrong about there being a simple fix for this without reverting #878 :(

@d-ronnqvist I might need your help to discuss options for this offline.