Skip to content

Revert "Simplify internals of {Rc,Arc}::default"#153108

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
alexcrichton:revert
Feb 26, 2026
Merged

Revert "Simplify internals of {Rc,Arc}::default"#153108
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
alexcrichton:revert

Conversation

@alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Feb 25, 2026

This reverts #152591 following a perf run being done. I'm not really positioned at this time to dive in further and understand the performance regressions, so I'll back away from Rc/Arc and leave them as-is.

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 25, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, joboet

@Kivooeo Kivooeo removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 25, 2026
@joboet
Copy link
Member

joboet commented Feb 26, 2026

It appears that the pointer write trick doesn't work, the write of T::default() still emits a memcpy... and using Box::new also means the layout calculation will be optimised to constants. In general Box::new is just much more likely to have good behaviour even in debug builds.

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 26, 2026

📌 Commit 57d20c1 has been approved by joboet

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 26, 2026
@joboet joboet assigned joboet and unassigned Mark-Simulacrum Feb 26, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 26, 2026
Revert "Simplify internals of `{Rc,Arc}::default`"

This reverts rust-lang#152591 following a [perf run being done](rust-lang#152591 (comment)). I'm not really positioned at this time to dive in further and understand the performance regressions, so I'll back away from `Rc`/`Arc` and leave them as-is.
@jieyouxu
Copy link
Member

(This has perf differences so to not make rollup perf more noisy)
@bors rollup=never

@jieyouxu
Copy link
Member

Scheduling...
@bors p=1

@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 26, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 26, 2026

☀️ Test successful - CI
Approved by: joboet
Duration: 3h 21m 33s
Pushing 6a979b3 to main...

@rust-bors rust-bors bot merged commit 6a979b3 into rust-lang:main Feb 26, 2026
12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 26, 2026
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 25396cf (parent) -> 6a979b3 (this PR)

Test differences

Show 812 test diffs

812 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 6a979b3e32522049d0acb4a47f7ae44b7c8abfd5 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 2h 19m -> 1h 50m (-20.8%)
  2. dist-x86_64-apple: 2h 28m -> 2h 4m (-15.8%)
  3. pr-check-2: 35m 8s -> 39m 53s (+13.5%)
  4. x86_64-gnu-llvm-20-3: 1h 54m -> 1h 39m (-12.7%)
  5. x86_64-gnu-llvm-21-2: 1h 23m -> 1h 34m (+12.5%)
  6. aarch64-apple: 2h 56m -> 3h 15m (+10.7%)
  7. i686-gnu-2: 1h 35m -> 1h 26m (-9.5%)
  8. x86_64-gnu-nopt: 2h 11m -> 2h 23m (+9.3%)
  9. aarch64-msvc-1: 2h 11m -> 2h (-8.7%)
  10. dist-powerpc-linux: 1h 36m -> 1h 28m (-8.3%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6a979b3): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.7%, -0.3%] 6
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.6%] 1
All ❌✅ (primary) -0.4% [-0.7%, -0.3%] 6

Max RSS (memory usage)

Results (primary 6.5%, secondary 7.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

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

Cycles

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

Binary size

Results (primary -0.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-1.2%, -0.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-1.2%, -0.5%] 2

Bootstrap: 481.72s -> 484.473s (0.57%)
Artifact size: 395.60 MiB -> 397.64 MiB (0.52%)

@alexcrichton
Copy link
Member Author

@joboet FWIW I was just copying what Box does which references #136043. If that doesn't work for Rc it probably doesn't work for Box either.

I also suspect that's not the source of regressions since that was in (I think?) compiling Cargo and html5ever. My guess is they both heavily use Rc or Arc and LLVM had to work a bit harder to optimize this.

It sounds like the codegen of neither Rc nor Arc can change, even in debug mode, so I don't know how to refactor things with that constraint.

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. 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.

7 participants