Skip to content

compiler: use FramePointer::NonLeaf on illumos#141798

Open
workingjubilee wants to merge 1 commit intorust-lang:mainfrom
workingjubilee:illumos-may-get-by-with-less-fp
Open

compiler: use FramePointer::NonLeaf on illumos#141798
workingjubilee wants to merge 1 commit intorust-lang:mainfrom
workingjubilee:illumos-may-get-by-with-less-fp

Conversation

@workingjubilee
Copy link
Copy Markdown
Member

It's not clear to me if Illumos requires full frame-pointers, including leaf frames, or not. I figured I'd ask the maintainers.

r? @ghost

cc @jclulow @pfmooney

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 30, 2025

These commits modify compiler targets.
(See the Target Tier Policy.)

@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. labels May 30, 2025
@apiraino
Copy link
Copy Markdown
Contributor

cc @jclulow @pfmooney do you have any feedback on this? thanks

@jclulow
Copy link
Copy Markdown
Contributor

jclulow commented Jun 26, 2025

Hey, sorry, I have been travelling!

In general we're quite fond of having proper stack frames wherever possible. It enables us to do things like sample-based profiling and get a reasonable picture of what's going on without needing to reach all the way into the DWARF.

Do you have some more detail or specifics about what impact this would have on code generation? Is there a huge performance win? What do representative profiled stacks look like before and after, etc? Or if there's some docs I could read that would help understand the mechanism and the motivation that would be good too!

@workingjubilee
Copy link
Copy Markdown
Member Author

@jclulow Hmm. My understanding of stack-based tracing is that it shouldn't have problems if the frame pointer is elided for the final function call into a leaf function. It shouldn't need a DWARF lookup. It may require more complex logic than the most naive form in order to recognize "I am in a leaf function that has elided its frame pointer", but from there it should be a simple matter to recover and get the trace. I am not familiar with the tooling on illumos, however, so I am not sure if dtrace has that amount of recovery logic.

In any case, this sort of thing has previously strongly affected inlining decisions for small-but-critical functions like mul_add.

@workingjubilee
Copy link
Copy Markdown
Member Author

@jclulow More generally: I made this PR because Windows, Apple, and Linux all use this setting on aarch64 machines and still can use stack-based tracing.

@jclulow
Copy link
Copy Markdown
Contributor

jclulow commented Jun 27, 2025

I have mentioned it to some colleagues, so hopefully we can study the differences more closely and come up with an answer!

@Enselic
Copy link
Copy Markdown
Member

Enselic commented Sep 2, 2025

Triage: @jclulow Any update on this? Thanks!

@apiraino
Copy link
Copy Markdown
Contributor

apiraino commented Mar 5, 2026

Sorry for yet another ping :-) is there any news here?
cc @jclulow @pfmooney

thanks

@iximeow
Copy link
Copy Markdown
Contributor

iximeow commented Mar 6, 2026

I dunno if this would be great to land particularly without a motivating size/perf win. on the dtrace side, https://www.illumos.org/issues/17744 is an issue I hit a few months ago that would be applicable in all leaf functions with this, not great. mdb/pstack/etc seem like they'd be fine, but dtrace's stalk walking is a bit different for ... reasons.

fwiw I checked this with something like

fn main() {
    eprintln!("i am pid {}", std::process::id());
    leaf_caller()
}

#[inline(never)]
fn leaf_oneoff(a: u8, b: u8) -> u8 {
    a.wrapping_add(b);
}

#[inline(never)]
fn leaf_caller() -> ! {
    let mut ctr = 4;
    loop {
        ctr = std::hint::black_box(leaf_oneoff(ctr, 3));
    }
}

and this dtrace:

# dtrace -n 'profile-1003 / pid==156128 / { @[ustack()] = count(); }' -c 'sleep 1'
dtrace: description 'profile-1003 ' matched 1 probe
dtrace: pid 156132 has exited

[...snip...]

              leaftest_141798_caller`_RNvCs1TB0fkQL3ly_8leaftest11leaf_oneoff+0x3
              leaftest_141798_caller`0x46b008
              leaftest_141798_caller`_RINvNtNtCs2EQkYFqb8Mq_3std3sys9backtrace28___rust_begin_short_backtraceFEuuECs1TB0fkQL3ly_8leaftest+0x6
              leaftest_141798_caller`_RNCINvNtCs2EQkYFqb8Mq_3std2rt10lang_startuE0Cs1TB0fkQL3ly_8leaftest+0xc
              leaftest_141798_caller`_RNvNtCs2EQkYFqb8Mq_3std2rt19lang_start_internal+0x3f4
              leaftest_141798_caller`main+0x2c
              leaftest_141798_caller`_start_crt+0x87
              leaftest_141798_caller`_start+0x18
              122

[...snip...]

and any mention of leaf_caller has disappeared when you're in leaf_oneoff :( (also dtrace {u}stack() handles the no-return call into leaf_caller poorly, but that's not related to this)

@Dylan-DPC Dylan-DPC added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. 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.

7 participants