Skip to content
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

Skip query in get_parent_item when possible. #130618

Merged
merged 2 commits into from
Sep 24, 2024
Merged

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Sep 20, 2024

For HirIds with a non-zero item local id, self.parent_owner_iter(hir_id).next() just returns the same HirId with the item local id set to 0, but also does a query to retrieve the Node which is ignored here, which seems wasteful.

@m-ou-se m-ou-se added the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Sep 20, 2024
@m-ou-se m-ou-se self-assigned this Sep 20, 2024
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 20, 2024
@m-ou-se
Copy link
Member Author

m-ou-se commented Sep 20, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 20, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 20, 2024
Skip query in get_parent_item when possible.

For HirIds with a non-zero item local id, `self.parent_owner_iter(hir_id).next()` just returns the same HirId with the item local id set to 0, but also does a query to retrieve the Node which is ignored here, which seems wasteful.
@bors
Copy link
Contributor

bors commented Sep 20, 2024

⌛ Trying commit 7a19b17 with merge c447636...

@bors
Copy link
Contributor

bors commented Sep 20, 2024

☀️ Try build successful - checks-actions
Build commit: c447636 (c4476362ade11f008d033195cd91744d0475c5a6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c447636): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 5
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.9%, secondary 1.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.2% [2.7%, 3.7%] 2
Regressions ❌
(secondary)
1.7% [1.7%, 1.7%] 1
Improvements ✅
(primary)
-3.6% [-3.6%, -3.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.9% [-3.6%, 3.7%] 3

Cycles

Results (primary 4.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
4.1% [4.1%, 4.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.1% [4.1%, 4.1%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 769.323s -> 767.803s (-0.20%)
Artifact size: 341.26 MiB -> 341.27 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 20, 2024
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine as a micro-optimization. Would appreciate a comment tho.

compiler/rustc_middle/src/hir/map/mod.rs Outdated Show resolved Hide resolved
Co-authored-by: Michael Goulet <michael@errs.io>
@m-ou-se
Copy link
Member Author

m-ou-se commented Sep 23, 2024

Seems like it doesn't have any measurable impact. I do think this would have helped me while understanding parents/owners/ids though. I was trying to understand those things, and got confused when I saw this function didn't just set the item local id to 0, which made me worried I completely misunderstood how the ids worked.

@m-ou-se m-ou-se marked this pull request as ready for review September 23, 2024 09:38
@m-ou-se m-ou-se removed the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Sep 23, 2024
@m-ou-se m-ou-se assigned compiler-errors and unassigned m-ou-se Sep 23, 2024
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 23, 2024

📌 Commit c0c569f has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 23, 2024
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Sep 24, 2024
Skip query in get_parent_item when possible.

For HirIds with a non-zero item local id, `self.parent_owner_iter(hir_id).next()` just returns the same HirId with the item local id set to 0, but also does a query to retrieve the Node which is ignored here, which seems wasteful.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 24, 2024
…mpiler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#129545 (rustdoc: redesign toolbar and disclosure widgets)
 - rust-lang#130618 (Skip query in get_parent_item when possible.)
 - rust-lang#130727 (Check vtable projections for validity in miri)
 - rust-lang#130739 (Pass bootstrap cargo when `--stage 0` and `COMPILETEST_FORCE_STAGE0`)
 - rust-lang#130750 (Add new Tier-3 target: `loongarch64-unknown-linux-ohos`)
 - rust-lang#130758 (Revert "Add recursion limit to FFI safety lint")
 - rust-lang#130759 (Update books)
 - rust-lang#130762 (stabilize const_intrinsic_copy)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 24, 2024
…mpiler-errors

Rollup of 7 pull requests

Successful merges:

 - rust-lang#129545 (rustdoc: redesign toolbar and disclosure widgets)
 - rust-lang#130618 (Skip query in get_parent_item when possible.)
 - rust-lang#130727 (Check vtable projections for validity in miri)
 - rust-lang#130750 (Add new Tier-3 target: `loongarch64-unknown-linux-ohos`)
 - rust-lang#130758 (Revert "Add recursion limit to FFI safety lint")
 - rust-lang#130759 (Update books)
 - rust-lang#130762 (stabilize const_intrinsic_copy)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c0f1a69 into rust-lang:master Sep 24, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 24, 2024
Rollup merge of rust-lang#130618 - m-ou-se:skip-query, r=compiler-errors

Skip query in get_parent_item when possible.

For HirIds with a non-zero item local id, `self.parent_owner_iter(hir_id).next()` just returns the same HirId with the item local id set to 0, but also does a query to retrieve the Node which is ignored here, which seems wasteful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants