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

Inline Arc and Rc dealloc for T: !Drop #97676

Closed
wants to merge 1 commit into from

Conversation

nvzqz
Copy link
Contributor

@nvzqz nvzqz commented Jun 3, 2022

This avoids creating and calling drop_slow when all it does is decrement the weak count and potentially dealloc, which should not generate much code.

This change applies to types like Arc<str> and Arc<[u8]>.

@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jun 3, 2022
@rust-highfive
Copy link
Collaborator

r? @kennytm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 3, 2022
@nvzqz nvzqz marked this pull request as draft June 3, 2022 07:37
@rust-log-analyzer

This comment has been minimized.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 16, 2022
Make `std::mem::needs_drop` accept `?Sized`

This change attempts to make `needs_drop` work with types like `[u8]` and `str`.

This enables code in types like `Arc<T>` that was not possible before, such as rust-lang#97676.
This avoids creating and calling `drop_slow` when all it does is
decrement the weak count and potentially dealloc, which should not
generate much code.
@nvzqz nvzqz marked this pull request as ready for review June 17, 2022 02:36
@thomcc
Copy link
Member

thomcc commented Jun 19, 2022

r? @thomcc

@rust-highfive rust-highfive assigned thomcc and unassigned kennytm Jun 19, 2022
@thomcc
Copy link
Member

thomcc commented Jun 19, 2022

This looks fine to me, but I'd like to see a perf run.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 19, 2022
@bors
Copy link
Contributor

bors commented Jun 19, 2022

⌛ Trying commit 5d0137e with merge 551fa756dcf11dc344f6bec4c58f2bb69f802765...

@bors
Copy link
Contributor

bors commented Jun 19, 2022

☀️ Try build successful - checks-actions
Build commit: 551fa756dcf11dc344f6bec4c58f2bb69f802765 (551fa756dcf11dc344f6bec4c58f2bb69f802765)

@rust-timer
Copy link
Collaborator

Queued 551fa756dcf11dc344f6bec4c58f2bb69f802765 with parent 21e9336, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (551fa756dcf11dc344f6bec4c58f2bb69f802765): comparison url.

Instruction count

  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
0.5% 0.6% 4
Regressions 😿
(secondary)
2.0% 5.0% 16
Improvements 🎉
(primary)
-0.6% -1.0% 9
Improvements 🎉
(secondary)
-0.8% -1.5% 14
All 😿🎉 (primary) -0.3% -1.0% 13

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: 😿 relevant regression found
mean1 max count2
Regressions 😿
(primary)
0.0% 0.0% 1
Regressions 😿
(secondary)
3.3% 3.3% 1
Improvements 🎉
(primary)
-2.7% -2.7% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -1.3% -2.7% 2

Cycles

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
4.3% 6.1% 3
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 19, 2022
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Jun 23, 2022
Make `std::mem::needs_drop` accept `?Sized`

This change attempts to make `needs_drop` work with types like `[u8]` and `str`.

This enables code in types like `Arc<T>` that was not possible before, such as rust-lang/rust#97676.
@thomcc
Copy link
Member

thomcc commented Jun 23, 2022

Given that this turned out to be a perf regression, I'm going to close. Let me know if you want to try more.

@thomcc thomcc closed this Jun 23, 2022
antoyo pushed a commit to rust-lang/rustc_codegen_gcc that referenced this pull request Aug 26, 2022
Make `std::mem::needs_drop` accept `?Sized`

This change attempts to make `needs_drop` work with types like `[u8]` and `str`.

This enables code in types like `Arc<T>` that was not possible before, such as rust-lang/rust#97676.
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request Sep 15, 2022
Make `std::mem::needs_drop` accept `?Sized`

This change attempts to make `needs_drop` work with types like `[u8]` and `str`.

This enables code in types like `Arc<T>` that was not possible before, such as rust-lang/rust#97676.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 28, 2023
Outline deallocation from Rc::drop since decrementing refcount usually is warmer

Something similar was tried in rust-lang#97676 but let's see if letting PGO figure things out instead of being aggressive with the inline annotations leads to better results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants