Skip to content

Make tracepoints with set_trace_func or TracePoint.new ractor local #7184

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

luke-gru
Copy link
Contributor

Before this change, GC'ing any Ractor object caused you to lose all enabled tracepoints across all ractors (even main). Now tracepoints are ractor-local and this doesn't happen.

Fixes [Bug #19112]

NOTE: I have yet to change the docs for TracePoint to mention that they are ractor-local, but I'm going to do that
in a separate PR. Also, I want to make it so that there's a flag to TracePoint#enable to make them global.

@luke-gru
Copy link
Contributor Author

This broke some internal events tests, like GC events, so I'll take a look soon.

@ivoanjo
Copy link
Contributor

ivoanjo commented Jan 26, 2023

Thanks for picking up this fix!

Also, I want to make it so that there's a flag to TracePoint#enable to make them global.

This would be great as well! I work on the profiler included in the ddtrace gem and while we don't have support for gathering information from non-main Ractors yet, it would be great if there was a global mechanism to say "I want to get informed of things, regardless of where they come from".

This way, we won't have to do things like intercept Ractor creation to make sure we reactivate our tracepoints for every new one that gets created.

Even if such an API is only available from C (I understand it may be harder to get Ruby-level tracepoints working cross-ractor), it would be incredibly valuable :)

Before this change, GC'ing any Ractor object caused you to lose all
enabled tracepoints across all ractors (even main). Now tracepoints are
ractor-local and this doesn't happen. Internal events are still global.

Fixes [Bug #19112]
@luke-gru luke-gru force-pushed the tracepoint_ractor_gc branch from ff26fcd to 06ead01 Compare January 26, 2023 13:49
@luke-gru
Copy link
Contributor Author

luke-gru commented Jan 26, 2023

Thanks for picking up this fix!

Not a problem 😄

I think a :global keyword being introduced for TracePoint#enable would be good. It doesn't look too complicated to get global tracepoint hooks to work alongside ractor hooks, but I'll leave that work for a separate commit and after (or if) this gets accepted.

@marknuzz
Copy link

Just wanted to follow up to ask if there's any plans to finish this. This would help enable reliable memory allocation profiling in our infrastructure.

@luke-gru
Copy link
Contributor Author

luke-gru commented Apr 7, 2025

This should be getting more attention soon. I plan on working on the 'debug' gem to enable breakpoints to work inside Ractors, and this PR would enable that work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants