Skip to content

rustdoc: search.index/ grows on every cargo doc run of an unchanged crate #166236

Description

@simonsan

Reproduction Steps

cargo new --lib repro && cd repro
printf '//! Repro.\n\n/// A.\npub struct A;\n' > src/lib.rs
for run in 1 2 3 4 5 6 7 8; do
  touch src/lib.rs
  cargo doc -q --no-deps
  echo "run $run: $(du -sb target/doc/search.index | cut -f1) bytes"
done
rm -rf target/doc && cargo doc -q --no-deps
echo "fresh: $(du -sb target/doc/search.index | cut -f1) bytes"

Expected Outcome

Every run writes the same search index as a run into an empty doc folder:
2725 bytes. The crate does not change between runs.

Actual Output

run 1: 2725 bytes
run 2: 2799 bytes
run 3: 2908 bytes
run 4: 2943 bytes
run 5: 2978 bytes
run 6: 2988 bytes
run 7: 3003 bytes
run 8: 3025 bytes
fresh: 2725 bytes

Each run merges its index into the one already in target/doc/search.index/
and keeps the entries of the earlier runs.

Version

  • rustdoc 1.100.0 (0ef1bc3 2026-11-09), cargo 1.100.0 (3acc79c0c 2026-11-05)
  • rustdoc 1.102.0-nightly (5f4effd 2026-11-13) shows the same sizes
  • x86_64-unknown-linux-gnu

Additional Details

On a real workspace documented with --document-private-items, each rerun
added about 500 bytes to search.index/root.js and 53 shards. After a week
the index held 770 MB, and rustdoc used 28 GB of memory to merge it. On an
empty doc folder, the same run takes 2.8 GB and 21 s.

Workaround: remove target/doc before cargo doc.

Possibly related: #136802 (a corrupt search-index.js after cargo doc runs
with different configurations).

Activity

  1. added
    T-rustdoc
    C-bug
    on Nov 20, 2026
  2. added
    needs-triage
    on Nov 20, 2026
  3. added
    A-rustdoc-search
    and removed
    needs-triage
    on Nov 23, 2026
  4. added
    T-rustdoc-frontend
    on Nov 23, 2026
  5. GuillaumeGomez commented on Nov 23, 2026

    @GuillaumeGomez
    Member
  6. GuillaumeGomez commented on Nov 23, 2026

    @GuillaumeGomez
    Member

    Actually taking a look...

  7. GuillaumeGomez commented on Nov 23, 2026

    @GuillaumeGomez
    Member

    Fixed in #166420. Thanks for the detailed reproducer @simonsan, it allowed me to save quite a lot of time. :)

  8. added a commit that references this issue on Nov 24, 2026
  9. added 3 commits that reference this issue on Nov 24, 2026
  10. added a commit that references this issue on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-searchC-bugT-rustdocT-rustdoc-frontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions