Skip to content

[nll] make causal tracking lazy #51710

Closed
Closed
@nikomatsakis

Description

@nikomatsakis

Analyzing profiles on my latest branch, it appears that approximately 4% of total compilation time is spent managing the "causal hash map":

/// If cause tracking is enabled, maps from a pair (r, e)
/// consisting of a region `r` that contains some element `e` to
/// the reason that the element is contained. There should be an
/// entry for every bit set to 1 in `SparseBitMatrix`.
causes: Option<CauseMap>,

Currently, that map is only non-None for the "liveness" set, which stores, for each region variable R, each point P where R is directly live (meaning typically that there is some local variable X that has R in its type and which may be used at some point Q reachable from P). The "cause" tracks basically this point Q. It's accessed later when constructing error messages, here:

// then return why `Y` was live at `elem`
self.liveness_constraints.cause(region_sub, elem)

We should remove the causal hashmap altogether. Instead, when constructing an error, we can do a BFS over the MIR graph from elem (a Location), looking for points that may use the region region_sub that we are interested in.

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.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

Relationships

None yet

Development

No branches or pull requests

Issue actions