Skip to content

perf: optimize route and sidebar lookups - #4148

Merged
ematipico merged 3 commits into
mainfrom
perf/routing-sidebar-lookups
Sep 1, 2026
Merged

ematipico merged 3 commits into
mainfrom
perf/routing-sidebar-lookups

Conversation

@ematipico

Copy link
Copy Markdown
Member

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

@netlify

netlify Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 25022a5
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/6a96ef367128f00008c586e1
😎 Deploy Preview https://deploy-preview-4148--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the 🌟 core Changes to Starlight’s main package label Aug 25, 2026
@changeset-bot

changeset-bot Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25022a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

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

@astrobot-houston

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
/index.html 6.1 KB (0%)
/guides/example/index.html 6.13 KB (0%)
/_astro/*.js 25.44 KB (0%)
/_astro/*.css 14.7 KB (0%)

delucis
delucis previously approved these changes Aug 25, 2026

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@delucis delucis mentioned this pull request Sep 1, 2026
@codspeed

codspeed Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by ×30

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks

Performance Changes

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)

Open in CodSpeed

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving again because I added a changeset.

@ematipico

Copy link
Copy Markdown
Member Author

Ran the benchmarks on my machine:

  • route_data 35.8x faster
  • sidebar 1,409x faster

@ematipico
ematipico merged commit cdfafd8 into main Sep 1, 2026
18 checks passed
@ematipico
ematipico deleted the perf/routing-sidebar-lookups branch September 1, 2026 16:22
@astrobot-houston astrobot-houston mentioned this pull request Sep 1, 2026
HiDeoo added a commit to HiDeoo/starlight that referenced this pull request Sep 2, 2026
* 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)
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Sep 5, 2026
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) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@astrojs%2fstarlight/0.41.11?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@astrojs%2fstarlight/0.41.10/0.41.11?slim=true) |

---

### Release Notes

<details>
<summary>withastro/starlight (@&#8203;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

- [#&#8203;4167](withastro/starlight#4167) [`32a5e29`](withastro/starlight@32a5e29) Thanks [@&#8203;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.

- [#&#8203;4148](withastro/starlight#4148) [`cdfafd8`](withastro/starlight@cdfafd8) Thanks [@&#8203;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==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌟 core Changes to Starlight’s main package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants