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

Remove box_free lang item #100036

Merged
merged 1 commit into from
Jun 17, 2023
Merged

Conversation

beepster4096
Copy link
Contributor

This PR removes the box_free lang item, replacing it with Box's Drop impl. Box dropping is still slightly magic because the contained value is still dropped by the compiler.

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

r? @wesleywiser

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

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2022

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 @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. 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

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 1, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tmiasko
Copy link
Contributor

tmiasko commented Aug 6, 2022

Failing test case enables -Zstack-protector=strong, which according to rustc --print stack-protector-strategies:

    strong
        Generate stack canaries in a function if it either:
        - has a local variable of `[T; N]` type, regardless of `T` and `N`
        - takes the address of a local variable.

          (Note that a local variable being borrowed is not equivalent to its
          address being taken: e.g. some borrows may be removed by optimization,
          while by-value argument passing may be implemented with reference to a
          local stack variable in the ABI.)

Freeing a box calls the drop implementation which accepts &mut Box<T> as a parameter. Now that the address of a box temporary is taken the stack canary seems expected. I think, it should be fine to update this part of the test case.

@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 Aug 6, 2022
@bors
Copy link
Contributor

bors commented Aug 6, 2022

⌛ Trying commit 3247cc8bcd7ba9bcf0a5debf2d73f2b6b5e9ad2f with merge 3cd4647996dc90f68700aa3bbc775e1a318ab11f...

@bors
Copy link
Contributor

bors commented Aug 6, 2022

☀️ Try build successful - checks-actions
Build commit: 3cd4647996dc90f68700aa3bbc775e1a318ab11f (3cd4647996dc90f68700aa3bbc775e1a318ab11f)

@rust-timer
Copy link
Collaborator

Queued 3cd4647996dc90f68700aa3bbc775e1a318ab11f with parent 76b0484, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3cd4647996dc90f68700aa3bbc775e1a318ab11f): comparison url.

Instruction count

  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
1.3% 2.6% 8
Regressions 😿
(secondary)
1.4% 4.6% 12
Improvements 🎉
(primary)
-1.5% -2.4% 2
Improvements 🎉
(secondary)
-0.8% -1.7% 9
All 😿🎉 (primary) 0.7% 2.6% 10

Max RSS (memory usage)

Results
  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
6.7% 9.7% 6
Regressions 😿
(secondary)
4.5% 7.0% 3
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-2.2% -2.7% 4
All 😿🎉 (primary) 6.7% 9.7% 6

Cycles

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
2.4% 2.4% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-2.8% -2.8% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -0.2% -2.8% 2

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 Aug 6, 2022
@wesleywiser
Copy link
Member

@drmeepster does this need another perf run?

@rust-log-analyzer

This comment has been minimized.

@beepster4096
Copy link
Contributor Author

Sorry for disappearing for a while!

Another perf run would be great, thanks.

@tmiasko
Copy link
Contributor

tmiasko commented Oct 3, 2022

@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 Oct 3, 2022
@bors
Copy link
Contributor

bors commented Oct 3, 2022

⌛ Trying commit e1bb0f0ebcf38e3c22bf387c68b445a28cefc983 with merge 5b44952011bb7348f9ce89c5b0099b43c87531ba...

@bors
Copy link
Contributor

bors commented Jun 7, 2023

⌛ Testing commit 12af10afed5a84cebd005dae90cb78be5c34ed7b with merge 26612d19e3967dd80d4c9b5f8717155b4f066bf4...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 7, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 7, 2023
@bors
Copy link
Contributor

bors commented Jun 15, 2023

☔ The latest upstream changes (presumably #106343) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 17, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Jun 17, 2023

📌 Commit a5c6cb8 has been approved by oli-obk

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 Jun 17, 2023
@bors
Copy link
Contributor

bors commented Jun 17, 2023

⌛ Testing commit a5c6cb8 with merge a8a2907...

@bors
Copy link
Contributor

bors commented Jun 17, 2023

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing a8a2907 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 17, 2023
@bors bors merged commit a8a2907 into rust-lang:master Jun 17, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 17, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a8a2907): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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)
1.2% [1.0%, 1.7%] 4
Regressions ❌
(secondary)
1.7% [1.1%, 3.4%] 5
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 2
Improvements ✅
(secondary)
-2.5% [-4.4%, -1.4%] 4
All ❌✅ (primary) 0.6% [-0.6%, 1.7%] 6

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.3% [3.3%, 3.3%] 1
Regressions ❌
(secondary)
2.6% [2.1%, 3.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.9%] 1
All ❌✅ (primary) 3.3% [3.3%, 3.3%] 1

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)
1.5% [1.5%, 1.6%] 2
Regressions ❌
(secondary)
2.2% [0.7%, 3.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-3.4%, -1.4%] 3
All ❌✅ (primary) 1.5% [1.5%, 1.6%] 2

Binary size

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.7% [0.0%, 1.6%] 39
Regressions ❌
(secondary)
1.6% [0.4%, 3.7%] 82
Improvements ✅
(primary)
-0.3% [-0.8%, -0.0%] 51
Improvements ✅
(secondary)
-1.6% [-2.6%, -1.3%] 5
All ❌✅ (primary) 0.1% [-0.8%, 1.6%] 90

Bootstrap: 656.011s -> 655.353s (-0.10%)

@nnethercote
Copy link
Contributor

Lots of binary size regressions here. Is that expected?

@@ -1211,8 +1211,16 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {

#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<#[may_dangle] T: ?Sized, A: Allocator> Drop for Box<T, A> {
#[inline]
Copy link
Contributor

Choose a reason for hiding this comment

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

Idk, maybe that inline increased binary size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

box_free was also marked as inline, so I don't think that is the cause.

@rylev
Copy link
Member

rylev commented Jun 21, 2023

@oli-obk @drmeepster any thoughts on the binary size regressions?

@beepster4096
Copy link
Contributor Author

The only real difference is that box_free took fields by value but drop takes a mutable reference. I bet that affects how LLVM inlines.

antoyo pushed a commit to antoyo/rust that referenced this pull request Oct 9, 2023
Remove `box_free` lang item

This PR removes the `box_free` lang item, replacing it with `Box`'s `Drop` impl. Box dropping is still slightly magic because the contained value is still dropped by the compiler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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.