Skip to content

Conversation

@fereidani
Copy link
Contributor

Hey,
as std::process::abort already has #[cold] attribute, and large part of rust core(no-std) is relying on intrinsics::abort instead, I believe marking it as cold will help the compiler generate more optimized code.

@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2026

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@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 Jan 5, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2026

r? @tgross35

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

@RalfJung
Copy link
Member

RalfJung commented Jan 5, 2026

Does this attribute even work when applied to an intrinsic (which is not a regular function)?

@fereidani
Copy link
Contributor Author

I have no idea, But even if that is the case couldn't we wrap it in another function and make it cold for optimization reason?

@saethlin
Copy link
Member

saethlin commented Jan 5, 2026

This might cause branch weight metadata to be produced in more cases because of this logic:

But also this intrinsic lowers to llvm.trap which already has the LLVM cold attribute, so I think it would be a missing optimization in LLVM if this PR actually improves optimization.

There is no reason to add a wrapper.

@Kobzol
Copy link
Member

Kobzol commented Jan 5, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jan 5, 2026
add #[cold] attribute to abort intrinsic for optimization hints
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 5, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 5, 2026

☀️ Try build successful (CI)
Build commit: 5d0861d (5d0861d01ea52af610896e2430e49b5232d304ca, parent: b7bcaa5c715ed07af2d74dac7ddb8786abeb4299)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5d0861d): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -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.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 1

Max RSS (memory usage)

Results (secondary -0.2%)

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)
2.9% [2.6%, 3.2%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.3%, -2.0%] 3
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.5%, secondary 3.3%)

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

mean range count
Regressions ❌
(primary)
2.5% [2.5%, 2.5%] 2
Regressions ❌
(secondary)
3.3% [2.2%, 5.4%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.5% [2.5%, 2.5%] 2

Binary size

Results (primary 0.0%, secondary 0.0%)

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

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

Bootstrap: 474.563s -> 472.66s (-0.40%)
Artifact size: 390.70 MiB -> 390.85 MiB (0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 5, 2026
@fereidani fereidani closed this Jan 5, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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