Skip to content

incremental: hash items' source tokens to generate DefId's. #53590

@eddyb

Description

@eddyb

We should strive to handle the "only touched one item" case very well, which means either knowing the exact modified range, or inferring it through a series of heuristics.

The current DefPath machinery doesn't know how to properly understand things like e.g. impls haven't changed, and would assume that adding an impl invalidates later ones in the same module.

If we only apply the existing machinery between the "leftover" old and new items that didn't have a match in their "source tokens hash", we should be able to get overall more consistent DefId matches, even in trickier situations where, for example, the whole file was moved around.

Original source could also be used, but ignoring whitespace & comments seems useful.


One way I can see us proceeding is by gathering some statistics of the hit/miss rate of this scheme for typical editing scenarios, and the cost of actually doing the hashing.

We can probably compute the hash for each Item after finishing parsing it, from its tokens field (which is there for proc macros, but it should be fine to reuse for our purposes).

cc @nikomatsakis @michaelwoerister

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions