Skip to content

ZJIT: Create perf map files for profilers #13941

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

Merged
merged 10 commits into from
Jul 17, 2025
Merged

Conversation

tekknolagi
Copy link
Contributor

This lets us ZJIT compiled functions show up in the profiles of, say,
perf, or samply.

Fix Shopify#634

This lets us ZJIT compiled functions show up in the profiles of, say,
perf, or samply.

Fix Shopify#634
@tekknolagi tekknolagi changed the title ZJIT: Support jitdump ZJIT: Create perf map files for profilers Jul 17, 2025
@tekknolagi
Copy link
Contributor Author

Before:
Screenshot 2025-07-17 at 4 15 25 PM

After:
Screenshot 2025-07-17 at 4 15 33 PM

@tekknolagi tekknolagi marked this pull request as ready for review July 17, 2025 20:16
@matzbot matzbot requested a review from a team July 17, 2025 20:16
@tekknolagi
Copy link
Contributor Author

There are still some unnamed pointers in there. Perhaps I am not getting the full code range?

@k0kubun
Copy link
Member

k0kubun commented Jul 17, 2025

There are still some unnamed pointers in there. Perhaps I am not getting the full code range?

You recorded only the JIT entry trampoline. The frame for the main function would be unnamed, and the name of callees in JIT-to-JIT calls would never appear. I think both of them should have symbols.

@tekknolagi
Copy link
Contributor Author

Oh, silly

@tekknolagi
Copy link
Contributor Author

@k0kubun where should I be adding this? I think I am not finding the right place to get the (start, end) pair

@k0kubun
Copy link
Member

k0kubun commented Jul 17, 2025

gen_function() maybe? That seems to cover both cases.

@tekknolagi
Copy link
Contributor Author

That looks better but still has some magic numbers
Screenshot 2025-07-17 at 5 21 51 PM

@k0kubun
Copy link
Member

k0kubun commented Jul 17, 2025

You seem to have removed the symbol from the JIT entry trampoline. By both cases I meant the main function and callee ISEQs, not including the JIT entry. So you need to record symbols in two places now.

@tekknolagi
Copy link
Contributor Author

tekknolagi commented Jul 17, 2025

Awesome, thank you. Very cool
Screenshot 2025-07-17 at 5 30 17 PM

let start_ptr = start_addr.raw_ptr(cb) as usize;
let end_ptr = cb.get_write_ptr().raw_ptr(cb) as usize;
let code_size = end_ptr - start_ptr;
register_with_perf("entry".into(), start_ptr, code_size);
Copy link
Member

@k0kubun k0kubun Jul 17, 2025

Choose a reason for hiding this comment

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

I think it's helpful to include the ISEQ name in the symbol for the entry, also keeping "entry" as part of the symbol. We'd be interested in which ISEQs are called from C, which you could see by looking at the callee frame but it's easier to understand if it's annotated in the frame itself. Using the same "entry" symbol for all entries could be problematic depending on how you aggregate perf profiles too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do before landing

This comment has been minimized.

@tekknolagi tekknolagi enabled auto-merge (squash) July 17, 2025 21:58
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Should we add profiling related entries to doc/zjit.md too?

@tekknolagi tekknolagi merged commit 30b1368 into ruby:master Jul 17, 2025
84 checks passed
@tekknolagi tekknolagi deleted the mb-jitdump branch July 17, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZJIT: Support jitdump
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy