Repository navigation
perf: optimize route and sidebar lookups - #4148
Conversation
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: 25022a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
delucis
left a comment
There was a problem hiding this comment.
These changes all make sense to me! Although it’s a bit hard to reason about exactly what the performance improvement will look like. Maybe as suggested by @HiDeoo on Discord we should wait to merge this after setting up some benchmarks so we can see clearly how we’ve improved.
Merging this PR will improve performance by ×30
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | sidebar |
11,853.8 µs | 70.1 µs | ×170 |
| ⚡ | route_data |
17 ms | 3.3 ms | ×5.2 |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing perf/routing-sidebar-lookups (25022a5) with main (dd7fb97)
delucis
left a comment
There was a problem hiding this comment.
Approving again because I added a changeset.
|
Ran the benchmarks on my machine:
|
* main: [i18nIgnore] Transpile Starlight packages (withastro#3572) i18n(ru): update translations (withastro#4170) [ci] release (withastro#4169) Fix hidden heading anchor links (withastro#4167) perf: optimize route and sidebar lookups (withastro#4148) chore: add benchmarks (withastro#4157)
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [@astrojs/starlight](https://starlight.astro.build) ([source](https://github.com/withastro/starlight/tree/HEAD/packages/starlight)) | [`0.41.10` → `0.41.11`](https://renovatebot.com/diffs/npm/@astrojs%2fstarlight/0.41.10/0.41.11) |  |  | --- ### Release Notes <details> <summary>withastro/starlight (@​astrojs/starlight)</summary> ### [`v0.41.11`](https://github.com/withastro/starlight/blob/HEAD/packages/starlight/CHANGELOG.md#04111) [Compare Source](https://github.com/withastro/starlight/compare/@astrojs/starlight@0.41.10...@astrojs/starlight@0.41.11) ##### Patch Changes - [#​4167](withastro/starlight#4167) [`32a5e29`](withastro/starlight@32a5e29) Thanks [@​HiDeoo](https://github.com/HiDeoo)! - Fixes a layout issue and anchor links appearing for hidden headings, e.g. footnote headings, when `markdown.headingLinks` is enabled or the `<AnchorHeading>` component is used. - [#​4148](withastro/starlight#4148) [`cdfafd8`](withastro/starlight@cdfafd8) Thanks [@​ematipico](https://github.com/ematipico)! - Optimizes sidebar data generation logic to speed up sites with large sidebars </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC42MS42IiwidXBkYXRlZEluVmVyIjoiNDQuNjEuNiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Description
Replaced repeated route and sidebar scans with maps, sets, and small caches. This reduces build work on documentation sites with many pages and avoids attaching unused route data to static paths.
This PR doesn't affect anything visual