-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Description
Now, when code needs to look up attributes on an item, it fetches the complete list of attributes and sequentially looks for the interesting one. This could be made more efficient by making the attribute list a SortedIndexMultiMap
.
Steps:
- replace
&[ast::Attribute]
bySortedIndexMultiMap<u32, Symbol, &ast::Attribute>
inrustc_hir::hir
,rustc_middle::query
andrustc_middle::ty
; - build the
SortedIndexMultiMap
inrustc_ast_lowering
andrustc_metadata::decoder
usingAttribute::name_or_empty
as key; - adapt the use sites to fetch the attributes using
attrs.get_by_key(my_name)
instead ofattrs.iter().filter(|attr| attr.has_name(my_name)
; - evaluate performance impact.
Extra:
- implement
item_attrs
query for the local crate, and replace calls totcx.get_attrs
by calls totcx.item_attrs
.
I am available on zulip for more detailed information.
Metadata
Metadata
Assignees
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
is_doc_hidden
#94897camelid commentedon Mar 13, 2022
I would like to attempt this. @rustbot claim
raiyansayeed commentedon Jun 7, 2022
Hey @camelid , just wondering if you're still working on the task?
NEUDitao commentedon Jul 31, 2022
Since @camelid hasn't reported on this in a while, can I take a stab at it?
camelid commentedon Jul 31, 2022
Hi, sorry, I didn't see these previous messages. I did attempt this but got stuck and didn't have time to figure out the right approach. Feel free to try it!
NEUDitao commentedon Jul 31, 2022
@rustbot claim
hottea773 commentedon Sep 22, 2022
@NEUDitao are you actively working on this?
I had a little look at this, but hit an issue in replacing
&[ast::Attribute]
withSortedIndexMultiMap<u32, Symbol, &ast::Attribute>
inrustc_middle::query
; specifically, https://github.com/rust-lang/rust/blob/1.63.0/compiler/rustc_middle/src/query/mod.rs#L1105.Which is deliberate; as in https://github.com/rust-lang/rust/blob/1.63.0/compiler/rustc_middle/src/ty/query.rs#L108-L112.
I think this means this approach doesn't work; but I'm a total newbie to
rustc
development, so am not sure whether there are larger things we should be doing to get this working.cjgillot commentedon Sep 22, 2022
@hottea773 Query results indeed require to be
Copy
. If the information you are constructing is notCopy
, you can usearena_cache
in the query description. The computed value will be put on an arena, and the query will just return a reference to it, which isCopy
.czzrr commentedon Jan 29, 2023
@rustbot claim
Jesse-Bakker commentedon Mar 17, 2023
Hey @czzrr, are you actively working on this? Otherwise I'll take a stab at it
czzrr commentedon Mar 17, 2023
@Jesse-Bakker Go ahead - I don't have the time right now :)
Jesse-Bakker commentedon Mar 18, 2023
@rustbot claim
cjgillot commentedon Jul 1, 2023
Closing as this did not yield the wanted improvement in #109532.