← Back to Pull requests

sitemaps: split per-letter sitemaps into two-char buckets #3768

Open
unknown opened this pull request with 221 lines diff across 2 files
View on GitHub
unknown unknown commented on Dec 02, 2026 11:59 UTC
Author

Some of our per-letter sitemaps were over Google's 50k-URL limit: s had ~64k URLs and r ~52k, with c and a close behind. Every crate adds two URLs (the crate root and all.html). We never got an alert because the check counted crates instead of URLs.

This splits the sitemaps into smaller buckets, inspired by the folder layout of the crates.io index: single-character crate names go into bucket 1, and everything else is bucketed by the first two characters of the normalized crate name (ru, se, a-, …). The largest bucket is currently ru with ~13k URLs, so there's plenty of headroom. If we ever outgrow that, we can split further the same way the index does (se/rd).

I checked the bucket logic against a dump of all ~394k crate names: every name lands in exactly one bucket.

Changes:


  • The sitemap index is now a static list of 963 buckets. Almost all of them have crates on prod, and a static list means no full-table query.

  • Bucket queries use equality on a new expression index, left(normalize_crate_name(name), 2), so the result doesn't depend on the DB collation.

  • Sitemap items are streamed in 64 KiB chunks instead of one chunk per crate.

  • The limit alert now counts URLs instead of crates.
  • Fixes I found along the way:


  • The sitemap header sent a literal \n (an escape inside a raw string) inside <urlset>.

  • The recent sitemaps listed today and the next 6 days instead of the previous 6, so 6 of the 7 were always empty.
  • Deploy notes:


  • Contains a migration that adds an index on crates.

  • The old /-/sitemap/{letter}/sitemap.xml URLs now return 404. Search engines pick up the new buckets from /sitemap.xml.

  • Sitemaps still aren't cached in the CDN (they never were). I'd leave that for a follow-up.
  • Diff: 221 lines (+165 / -56) across 2 files Reviewer: GuillaumeGomez Review duration: 840m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 221 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.323
    Real PR Conversation Timeline
    1 comments
    "Review active on #3768"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.8% (MEDIUM) · Higher = larger blast radius
    36.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.6% · Safe to merge
    19.6%