consider optimizing how NLL region inference works to use bit sets #47542
Labels
A-NLL
Area: Non-lexical lifetimes (NLL)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
I-compiletime
Issue: Problems and improvements with respect to compile times.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone
Right now, the main loop of NLL region inference actually performs a lot of depth-first searches across the control-flow graph:
rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Lines 468 to 494 in 0f9c784
Basically, if we have a relation that
R1: R2 @ P
, then we do a depth-first search in the control-flow graph, starting at P; so long as the nodes we visit are members of R2, we add that node into R1 (if not already present). That code is indfs.rs
:rust/src/librustc_mir/borrow_check/nll/region_infer/dfs.rs
Lines 46 to 89 in 0f9c784
(There is also a bit of special treatment around the exit from the CFG.)
This is pretty naive. I think what we should be doing is probably more like this:
BitMatrix
(there exists code to do this already inlibrustc_data_structures
).R1: R2 @ P
, we can then intersectreachable(P)
withR2
to get "those members of R2 reachable from P".Anyway, before we do a specific solution, though, it'd be great to have some specific benchmarks.
The text was updated successfully, but these errors were encountered: