Skip to content

Large sidebars (i.e autogenerating all folders) causes build slowdowns due to repeated getSidebar calls #2215

@KianNH

Description

@KianNH

What version of starlight are you using?

0.25.2

What version of astro are you using?

4.13.4

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

On Starlight sites with a large (thousands of items) sidebar, which may be filtered with a Sidebar override (i.e to the current folder), individual pages will build slower as the sidebar size increases.

For example, with cloudflare/cloudflare-docs as an example, there are ~4,000 pages and each top-level folder within src/content/docs is an autogenerate entry for the sidebar.

As part of generateRouteData, getSidebar is called on each page with the current page's path (to mark a given page as current). With a very large sidebar, this can represent a large amount of the time spent rendering a page.

NodeJS Dev Tools profile:

image

Full build flamegraph:

image

I will try and follow-up with a proper MRE in StackBlitz!

Link to Minimal Reproducible Example

https://github.com/cloudflare/cloudflare-docs

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions