Skip to content

optimize the way that loans are killed in borrowck dataflow #50934

Closed
@nikomatsakis

Description

@nikomatsakis

Profiling reveals that kill_loans_out_of_scope_at_location is a pretty major hot spot. It is pretty naive right now: for each point, it iterates over all borrows to check if that point is included. In fact, it seems to do that twice (@davidtwco opened #50891 to deal with that).

I am not sure the best way to handle this computation. One option that is not theoretically better but seems likely to be much better in practice would be:

  • Iterate over each borrow expression B, with associated region 'a:
    • For each borrow B, do a depth-first search starting at the location of the borrow
    • When this DFS reaches a point P that is not in 'a, end the walk, but add B to kill set for P

This is still O(n^2), but I think it seems likely to be much better in practice, and I can't think of a better way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NLL-performantWorking towards the "performance is good" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions