javierhonduco / rbperf

Low-overhead sampling profiler and tracer for Ruby for Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: Wrong main_thread offset

kakkoyun opened this issue · comments

I have discovered that >= 3.0.0 the main_thread_offset is wrong

main_thread_offset: 32

It was supposed to be 40, but it's been calculated as 32.

CleanShot 2024-02-10 at 21 23 43

I have no idea how things are not broken 🤔

I've opened the issue here to track it down. I'll report it back if I find something else.

Thanks for opening the issue, Kemal! I need to refresh my understanding of how actors and threads work under the hood, but I think the naming I picked might be wrong. I think that using main_ractor is more correct, as we want to fetch the stack of the currently executing code (no matter if it's the ractor or thread that was created first or not).

The best way to check this, besides inspecting CRuby's implementation might be to write a reproducer with multiple threads and ractors and checking which stack we are reading