Skip to content

perf(docs-site): split search index by section and stop indexing code blocks - #81736

Open
teknium1 wants to merge 1 commit into
mainfrom
docs/search-index-shrink
Open

teknium1 wants to merge 1 commit into
mainfrom
docs/search-index-shrink

Conversation

@teknium1

@teknium1 teknium1 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Makes docs search feel instant again. The client-side search index had grown to 16.3 MB raw / ~4.5 MB over the wire (4,500+ indexed docs), and since @easyops-cn/docusaurus-search-local shows no spinner, users stared at a completely blank search page for 25-30 seconds before the (correct) results popped in — indistinguishable from "search is broken entirely".

Three config-only levers in website/docusaurus.config.ts:

  • searchContextByPaths — the index is now built per section (user-guide, developer-guide, guides, reference, getting-started, integrations). Searching from any docs page fetches only that section's index (e.g. Reference: 1.4 MB raw / 387 KB gz) instead of the 16 MB monolith. The search page gains a section scope dropdown; searches started outside a section (docs landing page) still cover everything via useAllContextsWithNoSearchContext: true.
  • ignoreCssSelectors: ['pre'] — fenced code blocks are no longer indexed. YAML/shell/config samples were generating huge high-cardinality lunr token dictionaries for text nobody searches literally. Inline code in prose (command names, config keys) stays searchable.
  • ignoreFiles + user-stories — the community-quote collage page contributed 527 index documents of scraped testimonials that polluted results for generic terms.

Related Issue

Follow-up to #65103 (fuzzy-distance fix) — same disease, next stage: full-content client-side indexing doesn't scale with the docs tree. This buys headroom now; Algolia DocSearch remains the long-term answer.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • website/docusaurus.config.ts: added searchContextByPaths (6 sections), useAllContextsWithNoSearchContext: true, ignoreCssSelectors: ['pre'], and /^user-stories/ in ignoreFiles. Config-only; no dependency or code changes.

How to Test

  1. cd website && npm ci && npm run build
  2. Confirm per-section search-index-*.json files exist in build/ alongside the root index.
  3. Serve build/ under /docs/ and search "telegram" from a docs page — results should appear in well under a second.

Measured results (local build, both locales)

Index Before After
en root ("Everywhere") 16.3 MB raw / 4.42 MB gz 13.2 MB raw / 3.57 MB gz
en per-section 0.39–8.3 MB raw / 103 KB–2.2 MB gz
zh-Hans root 14.6 MB raw 12.6 MB raw

Time-to-first-dropdown-result on a local serve: ~175 ms searching "telegram" from a section page, ~205 ms from the landing page (was 25-30 s of blank UI on the live site). Search-page query returns the full 100 results with the new scope selector rendering correctly.

The root index still exists as the "Everywhere" fallback, so worst case is strictly better than before; the common case (searching while reading a section) downloads 87-97% less.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run the docs build for both locales and verified index output
  • I've tested on my platform: Linux

Documentation & Housekeeping

  • I've updated relevant documentation — N/A (site config; behavior verified in build output)
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've considered cross-platform impact — N/A (static site build)

Infographic

docs-search-split-index

… blocks

The client-side search index had grown to 16.3 MB raw / ~4.5 MB wire
(4,500+ docs), giving 25-30 s of blank UI before first results — users
read the dead window as 'search is broken entirely' (the engine itself
returned correct results).

Three levers, all config-only:

- searchContextByPaths: per-section index chunks. Searching from any
  docs page now fetches only that section's index (e.g. Reference:
  1.4 MB / 387 KB gz) instead of the 16 MB monolith. The search page
  gains a section dropdown; landing-page searches still cover
  everything via useAllContextsWithNoSearchContext.
- ignoreCssSelectors: ['pre']: fenced code blocks no longer indexed.
  YAML/shell samples were generating huge high-cardinality lunr token
  dictionaries; inline code in prose stays searchable.
- ignoreFiles: user-stories excluded (527 index docs of scraped
  community quotes rendered by a React component).

Measured (npm run build, both locales):
- root 'Everywhere' index: 16.3 MB -> 13.2 MB raw (4.42 -> 3.57 MB gz)
- per-section indexes: 0.4-8.3 MB raw (103 KB-2.2 MB gz)
- zh-Hans root: 14.6 -> 12.6 MB raw
- local serve: first dropdown results in ~175-205 ms for both scoped
  and Everywhere queries ('telegram' -> 8 options, search page -> 100)
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on a9d9634

⚠️ Warnings

OSV vulnerability scan · View job

56 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 2m58s vs 5m14s (-43.3%). 3 job(s) slower, 3 faster, 1 unchanged.

  • Docs Site / docs-site-checks: -14.0s
  • OSV scan / Scan lockfiles / osv-scan: +8.0s
  • OSV scan / Emit review status: +3.0s
  • Detect affected areas: +2.0s
  • All required checks pass: -2.0s

@alt-glitch alt-glitch added type/perf Performance improvement or optimization P3 Low — cosmetic, nice to have area/config Config system, migrations, profiles labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants