Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

perf(core): optimize broken links checker #9778

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jan 22, 2024

Motivation

Fix #9754

The new logic added for the broken anchor link checker made the algorithm slow for large sites with many routes and links.

This PR optimizes the algo:

  • reduces the number of useless matchRoutes(routes,pathname) calls
  • reduces the number of routes to match against when possible
  • uses more scalable Set/Map data structures

Test Plan

CI + unit tests


Considering this site/commit: harness/developer-hub@d5d1311

Upgrading to Docusaurus v3.1 leads the broken link checker to take 5 minutes. After this PR it only takes 1 second.

Another site reporting significant build time improvements:
#9754 (comment)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jan 22, 2024
@slorber slorber added pr: bug fix This PR fixes a bug in a past release. and removed CLA Signed Signed Facebook CLA labels Jan 22, 2024
Copy link

netlify bot commented Jan 22, 2024

[V2]

Name Link
🔨 Latest commit 3e750bb
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/65aeaa992e588b0008713fbe
😎 Deploy Preview https://deploy-preview-9778--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jan 22, 2024
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 74 🟢 98 🟢 100 🟢 100 🟠 89 Report
/docs/installation 🟠 89 🟢 98 🟢 100 🟢 100 🟠 89 Report
/docs/category/getting-started 🟠 76 🟢 100 🟢 100 🟢 90 🟠 89 Report
/blog 🟠 71 🟢 100 🟢 100 🟢 90 🟠 89 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 64 🟢 97 🟢 100 🟢 100 🟠 89 Report
/blog/tags/release 🟠 71 🟢 100 🟢 100 🟠 80 🟠 89 Report
/blog/tags 🟠 76 🟢 100 🟢 100 🟢 90 🟠 89 Report

@slorber slorber changed the title pref(core)): optimize broken links checker pref(core): optimize broken links checker Jan 22, 2024
@slorber slorber added pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient. to backport This PR is planned to be backported to a stable version of Docusaurus and removed pr: bug fix This PR fixes a bug in a past release. labels Jan 22, 2024
Copy link

Size Change: 0 B

Total Size: 986 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 75.1 kB
website/build/assets/css/styles.********.css 114 kB
website/build/assets/js/main.********.js 759 kB
website/build/index.html 37.9 kB

compressed-size-action

@slorber slorber changed the title pref(core): optimize broken links checker perf(core): optimize broken links checker Jan 22, 2024
@slorber slorber merged commit c827b6d into main Jan 24, 2024
4 checks passed
@slorber slorber deleted the slorber/optimize-broken-links-checker branch January 24, 2024 11:14
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
CLA Signed Signed Facebook CLA pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient. to backport This PR is planned to be backported to a stable version of Docusaurus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After updating to v3.1, large repo build takes 3 hours
2 participants