Skip to content

Conversation

@tekknolagi
Copy link
Contributor

@tekknolagi tekknolagi commented May 14, 2025

Instead of trying to (potentially incorrectly) map the FrameState stack at any
random instruction back to the profiled types, record the profiled type
of an HIR instruction at the safepoint and expose an API to query that.

@matzbot matzbot requested a review from a team May 14, 2025 18:34
@tekknolagi tekknolagi marked this pull request as draft May 14, 2025 18:41
@tekknolagi
Copy link
Contributor Author

Eugh, going to fix some tests...

@launchable-app

This comment has been minimized.

@tekknolagi tekknolagi force-pushed the mb-profile-oracle branch from 4a7d775 to 5b4e3fe Compare May 15, 2025 15:02
@tekknolagi tekknolagi marked this pull request as ready for review May 15, 2025 19:26
@tekknolagi
Copy link
Contributor Author

(It would probably be ideal if this got squashed)

@tekknolagi
Copy link
Contributor Author

Come to think of it, @k0kubun should I just have it profile at the top of every instruction? It'll only allocate if we actually recorded anything in the interpreter

@k0kubun
Copy link
Member

k0kubun commented May 15, 2025

should I just have it profile at the top of every instruction?

You mean adding a zjit_ variant to every YARV instruction? Also, what made you think of it?

It'll only allocate if we actually recorded anything in the interpreter

My assumption is that just calling a C (Rust) function and retrieving profiling metadata could be non-zero overhead for profiled runs. Remember we weren't even allowed to increment a global counter vm_insns_count on the interpreter on the default build, for example. It's somewhat mitigated by rewriting them back after num-profile cycles, but profiled runs do get slower. At least I don't want to run a profiler on nop instruction (or anything that doesn't need to record anything).

@tekknolagi
Copy link
Contributor Author

Oh, no, sorry, I mean just in ISEQ->HIR translation. That will cause a read from IseqPayload in HIR creation but no other work (and, in particular, no other work in the interpreter).

@tekknolagi
Copy link
Contributor Author

Like lift the profile_stack so that it happens once per opcode.

@k0kubun
Copy link
Member

k0kubun commented May 15, 2025

sounds good then :)

@tekknolagi tekknolagi force-pushed the mb-profile-oracle branch from df4c70c to 3188dc5 Compare May 15, 2025 22:08
@k0kubun k0kubun merged commit d924885 into ruby:master May 16, 2025
82 checks passed
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.

2 participants