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

Add #[inline] to BTreeMap::new constructor #122099

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Mar 6, 2024

This PR add the #[inline] attribute to BTreeMap::new constructor as to make it eligible for inlining.

For some context: I was profiling rustc --check-cfg with callgrind and due to the way we currently setup all the targets and we end-up calling BTreeMap::new multiple times for (nearly) all the targets. Adding the #[inline] attribute reduced the number of instructions needed.

@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2024

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 6, 2024
@workingjubilee
Copy link
Member

This seems unobjectionable but:

@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 Mar 6, 2024
@bors
Copy link
Contributor

bors commented Mar 6, 2024

⌛ Trying commit cc38c1e with merge 55e9de3...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 6, 2024
Add  `#[inline]` to `BTreeMap::new` constructor

This PR add the `#[inline]` attribute to `BTreeMap::new` constructor as to make it eligible for inlining.

<details>

For some context: I was profiling `rustc --check-cfg` with callgrind and due to the way we currently setup all the targets and we end-up calling `BTreeMap::new` multiple times for (nearly) all the targets. Adding the `#[inline]` attribute reduced the number of instructions needed.

</details>
@bors
Copy link
Contributor

bors commented Mar 6, 2024

☀️ Try build successful - checks-actions
Build commit: 55e9de3 (55e9de3cd4241b6476d28a56267226cad79a5ce2)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (55e9de3): comparison URL.

Overall result: ❌ regressions - 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)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

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.6% [1.1%, 6.1%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.8% [-2.4%, -1.2%] 2
Improvements ✅
(secondary)
-3.3% [-3.8%, -2.4%] 6
All ❌✅ (primary) 0.9% [-2.4%, 6.1%] 4

Cycles

Results

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)
- - 0
Regressions ❌
(secondary)
2.7% [2.2%, 3.2%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 644.65s -> 646.164s (0.23%)
Artifact size: 175.06 MiB -> 175.05 MiB (-0.00%)

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

I feel like I don't know how to read the perf runes again, today.

@Urgau
Copy link
Member Author

Urgau commented Mar 7, 2024

I don't see any regressions, neither do the bot: "no action needed".

As for deep-vector it has been very noisy in recent times.

image

@Amanieu
Copy link
Member

Amanieu commented Mar 7, 2024

I'm surprised const fn isn't getting automatically inlined.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 7, 2024

📌 Commit cc38c1e has been approved by Amanieu

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 Mar 7, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 8, 2024
Add  `#[inline]` to `BTreeMap::new` constructor

This PR add the `#[inline]` attribute to `BTreeMap::new` constructor as to make it eligible for inlining.

<details>

For some context: I was profiling `rustc --check-cfg` with callgrind and due to the way we currently setup all the targets and we end-up calling `BTreeMap::new` multiple times for (nearly) all the targets. Adding the `#[inline]` attribute reduced the number of instructions needed.

</details>
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#118623 (Improve std::fs::read_to_string example)
 - rust-lang#119365 (Add asm goto support to `asm!`)
 - rust-lang#120608 (Docs for std::ptr::slice_from_raw_parts)
 - rust-lang#121885 (Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attribute to inner type.)
 - rust-lang#121938 (Fix quadratic behavior of repeated vectored writes)
 - rust-lang#122099 (Add  `#[inline]` to `BTreeMap::new` constructor)
 - rust-lang#122143 (PassWrapper: update for llvm/llvm-project@a3319371970b)

Failed merges:

 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)

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

Rollup of 8 pull requests

Successful merges:

 - rust-lang#118623 (Improve std::fs::read_to_string example)
 - rust-lang#119365 (Add asm goto support to `asm!`)
 - rust-lang#120608 (Docs for std::ptr::slice_from_raw_parts)
 - rust-lang#121832 (Add new Tier-3 target: `loongarch64-unknown-linux-musl`)
 - rust-lang#121938 (Fix quadratic behavior of repeated vectored writes)
 - rust-lang#122099 (Add  `#[inline]` to `BTreeMap::new` constructor)
 - rust-lang#122103 (Make TAITs and ATPITs capture late-bound lifetimes in scope)
 - rust-lang#122143 (PassWrapper: update for llvm/llvm-project@a3319371970b)

Failed merges:

 - rust-lang#122076 (Tweak the way we protect in-place function arguments in interpreters)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d16c55d into rust-lang:master Mar 8, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
Rollup merge of rust-lang#122099 - Urgau:btreemap-inline-new, r=Amanieu

Add  `#[inline]` to `BTreeMap::new` constructor

This PR add the `#[inline]` attribute to `BTreeMap::new` constructor as to make it eligible for inlining.

<details>

For some context: I was profiling `rustc --check-cfg` with callgrind and due to the way we currently setup all the targets and we end-up calling `BTreeMap::new` multiple times for (nearly) all the targets. Adding the `#[inline]` attribute reduced the number of instructions needed.

</details>
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-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants