Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[nll] hash borrows in scope for better performance #53159
Comments
nikomatsakis
added
T-compiler
WG-compiler-nll
NLL-performant
labels
Aug 7, 2018
nikomatsakis
added this to the Rust 2018 RC milestone
Aug 7, 2018
nikomatsakis
added
the
I-nominated
label
Aug 7, 2018
This comment has been minimized.
This comment has been minimized.
|
This should be a big win for html5ever -- |
This comment has been minimized.
This comment has been minimized.
mikhail-m1
self-assigned this
Aug 8, 2018
nikomatsakis
removed
the
I-nominated
label
Aug 9, 2018
This comment has been minimized.
This comment has been minimized.
mikhail-m1
referenced this issue
Aug 13, 2018
Closed
[WIP]Hash borrows in scope for better performance #53306
bors
added a commit
that referenced
this issue
Aug 22, 2018
nikomatsakis
added
A-NLL
and removed
WG-compiler-nll
labels
Aug 27, 2018
nikomatsakis
referenced this issue
Aug 27, 2018
Merged
Avoid calling `unroll_place()` in a common case. #53733
This comment has been minimized.
This comment has been minimized.
|
Moving to RC 2 -- not a blocker. |
Mark-Simulacrum
modified the milestones:
Rust 2018 RC,
Edition RC 2
Sep 7, 2018
nikomatsakis
removed this from the Edition 2018 RC 2 milestone
Sep 11, 2018
nikomatsakis
added
the
NLL-deferred
label
Sep 11, 2018
nikomatsakis
unassigned
mikhail-m1
Sep 11, 2018
This comment has been minimized.
This comment has been minimized.
|
Removing from all milestones as this just doesn't release like a Rust 2018 blocker (perf is "good enough"). Marked as NLL-deferred. |
matthewjasper
removed
the
NLL-deferred
label
Dec 1, 2018
pnkfelix
added
the
WG-compiler-performance
label
Feb 19, 2019
This comment has been minimized.
This comment has been minimized.
|
NLL premeeting triage. Unclear what priority to assign here, since it is not clear whether or not this would still be much of a win. (Its possible it might be; I just don't know.) Continuing to leave off a P-label; hopfeully I'll revisit next week with more information. |
This comment has been minimized.
This comment has been minimized.
|
I'm inclined to just close this issue, personally, although I guess the idea may still be actionable and relevant. |
This comment has been minimized.
This comment has been minimized.
|
NLL triage: closing. If we later decide that this idea has merit, we can reopen (or open a fresh issue, or just implement a PR). |
nikomatsakis commentedAug 7, 2018
So I have an idea for how to improve performance in cases like html5ever where there are tons of borrows in scope at certain points. Right now, we have a pretty naive algorithm that implements over all borrows in scope:
rust/src/librustc_mir/borrow_check/path_utils.rs
Lines 40 to 52 in 18925de
I think we would do better if we stored the "borrows in scope" organized by the "root local" of the borrow:
rust/src/librustc_mir/borrow_check/place_ext.rs
Lines 20 to 23 in 18925de
In fact, I think we could do a "quick hack" to make this work. The
BorrowSetalready has an index of borrow indices based on their "root locals":rust/src/librustc_mir/borrow_check/borrow_set.rs
Lines 44 to 45 in 18925de
So what we can do is to modify
each_borrow_involving_path. Instead of taking an iterator over borrows in scope, it would take some sort ofis_borrow_in_scope: impl Fn(BorrowIndex) -> boolfunction. It would then find the root local (if any) of the access path, find all borrows that apply to that root local, and iterate over those, testing if each of them is in scope.We could make this more efficient in many ways -- e.g., using bitsets and things -- but this basic change should already eliminate some of the horrible
O(n^2)behavior.