-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize HIR map #60246
Optimize HIR map #60246
Conversation
@bors try |
⌛ Trying commit d3bd03ce1d50238d54a70a96b22731cd76cc5e20 with merge 890cc87d1001f65c608c711d7a4d0d48129a43c1... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☀️ Try build successful - checks-travis |
@rust-timer build 890cc87d1001f65c608c711d7a4d0d48129a43c1 |
Success: Queued 890cc87d1001f65c608c711d7a4d0d48129a43c1 with parent e305df1, comparison URL. |
Finished benchmarking try commit 890cc87d1001f65c608c711d7a4d0d48129a43c1 |
Seems like this approach works well. There's still some slight memory regressions though. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC this fixes a regression introduced in #59042 and doesn't look like a very invasive change (limited only to one data structure) - should we not land it?
src/librustc/hir/map/mod.rs
Outdated
@@ -160,6 +161,8 @@ impl Forest { | |||
} | |||
} | |||
|
|||
pub(super) type HirMap<'hir> = [Vec<Option<IndexVec<ItemLocalId, Option<Entry<'hir>>>>>; 2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes a while to decipher what the structure looks like and why it looks this way - it'd be great if we could add a doc-comment here with an explanation
fn all_ids<'a>(&'a self) -> impl Iterator<Item = HirId> + 'a { | ||
let map = &self.map; | ||
let spaces = [DefIndexAddressSpace::Low, DefIndexAddressSpace::High].iter().cloned(); | ||
spaces.flat_map(move |space| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great to also add a comment here and/or rustfmt the function body
☔ The latest upstream changes (presumably #60337) made this pull request unmergeable. Please resolve the merge conflicts. |
src/librustc/hir/map/mod.rs
Outdated
@@ -160,6 +161,8 @@ impl Forest { | |||
} | |||
} | |||
|
|||
pub(super) type HirMap<'hir> = [Vec<Option<IndexVec<ItemLocalId, Option<Entry<'hir>>>>>; 2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hir::map::Map
is the HIR map. Can you rename this type alias to HirEntryMap
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, r=me modulo nits!
@bors r=eddyb |
📌 Commit d33db6e has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
return Some(idx) | ||
} | ||
} | ||
fn matces_suffix(&self, hir: HirId) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*matches
} | ||
}; | ||
|
||
self.all_ids().filter(move |hir| nodes.matces_suffix(*hir)).map(move |hir| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*matches
I am a little confused about the order of comments on this PR: bors merges (1h ago) -> me reviewing it (few min ago) -> Zoxc gives r+ (3h ago). |
@bjorn3 It's github new feature, time-travelling comments. |
When looking at my notifications list, it said bors was the last commenter :) |
You can see that I will post my comment in 3 hours. Github simply sorts comments by time! |
On mobile it says 2 hours ago though. |
Builds on #59042
cc @ljedrz
r? @eddyb