Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add a per-item-kind index of public items in the crate. #676

Draft
wants to merge 1 commit into
base: rustdoc-v37
Choose a base branch
from

Conversation

obi1kenobi
Copy link
Owner

@obi1kenobi obi1kenobi commented Dec 17, 2024

Most items we'll see in the crate either aren't public, or aren't top-level items that would be returned by the Crate -[item]-> Item edge. For example, many of those items are methods, impls, trait associated types, associated constants, etc.

In this PR, we ensure we don't bother iterating over such items in queries where they can't possibly match. Queries that look at public structs should only iterate over structs, ones that look at enums should only iterate over enums, etc.

This has a substantial performance effect: it speeds up the median cargo-semver-checks lint by ~100x, and makes it so that a tiny handful (~5) of lints dominate all linting runtime — the combined runtime of all other lints becomes negligible. In end-to-end terms, cargo-semver-checks becomes about ~35% faster on our largest workload, but this number is misleadingly small w.r.t. the impact of this optimization: the new runtime is now equal to ~101% of the slowest lint, whereas that number was ~140% previously. If we can now optimize that slow lint in particular, we'll get tens of percent of additional speedup from the optimization in this PR.

Most items we'll see in the crate either aren't public, or aren't top-level items that would be returned by the `Crate -[item]-> Item` edge. For example, many of those items are methods, impls, trait associated types, associated constants, etc.

In this PR, we ensure we don't bother iterating over such items in queries where they can't possibly match. Queries that look at public structs should only iterate over structs, ones that look at enums should only iterate over enums, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant