Skip to content

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

Merged
luke-gru merged 1 commit intoruby:masterfrom
luke-gruber:tracepoint_ractor_gc_new
Dec 16, 2025
Merged

Make tracepoints with set_trace_func or TracePoint.new ractor local#15468
luke-gru merged 1 commit intoruby:masterfrom
luke-gruber:tracepoint_ractor_gc_new

Conversation

@luke-gruber
Copy link
Copy Markdown
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. Internal events are still global.

Fixes [Bug #19112]

@luke-gruber luke-gruber force-pushed the tracepoint_ractor_gc_new branch 7 times, most recently from 7e80eaf to 480abc0 Compare December 10, 2025 17:31
@luke-gruber luke-gruber marked this pull request as ready for review December 12, 2025 16:58
@matzbot matzbot requested a review from a team December 12, 2025 16:59
@luke-gruber luke-gruber changed the title Make tracepoints with set_trace_func or TracePoint.new ractor local (DRAFT) Make tracepoints with set_trace_func or TracePoint.new ractor local Dec 12, 2025
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-gruber luke-gruber force-pushed the tracepoint_ractor_gc_new branch from 1e41e82 to eda1848 Compare December 16, 2025 18:29
@luke-gru luke-gru merged commit 4fb537b into ruby:master Dec 16, 2025
90 checks passed
ivoanjo added a commit to DataDog/dd-trace-rb that referenced this pull request Jan 5, 2026
**What does this PR do?**

For a while now, whenever the GC and more importantly the allocation
profiling features were enabled, we logged a user-visible message that
if Ractors were used, a bug in Ruby could cause the profiler to miss
data (due to https://bugs.ruby-lang.org/issues/19112 ).

The upstream issue has been fixed in
<ruby/ruby#15468> (some discussion as well
in <ruby/ruby#7184> ).

Thus, this PR does a few small things:

* Update the logged messages to mention the bug doesn't happen on
  Ruby 4

* Moves all messages to be debug-level messages (our logic already
  made sure they were only printed on Ruby 3, hah turns out we
  predicted this!)

  In particular our concern in the past for making the message
  user-visible by default was that customers might use Ractors and
  run into this issue. As it turns out that in Ruby 3 ractors were
  always experimental and had a number of bugs/issues, we don't
  expect anyone to run Ractors in production with Ruby 3. (Maybe
  this will change with Ruby 4?)

* Removes the `OnlyOnce` that was used to limit verboseness -- this
  is extra complexity that we don't need to maintain now that the
  log is debug level

**Motivation:**

Avoid annoying customers with log messages about Ractor support on
Ruby 3.

**Additional Notes:**

N/A

**How to test the change?**

For the warnings themselves, I've updated our tests to match the
new setup.

For the upstream issue, I manually used the testcase from
https://bugs.ruby-lang.org/issues/19112 and added prints to the
profiling GC and NEWOBJ tracepoints, confirming that on Ruby 3.4
they get disabled but on Ruby 4.0 they work fine.

I considered adding an explicit test for this but it seems a bit
brittle as it would be a test for something not happening after
Ractor GC which is kinda fishy to test for, so I ended up not doing
it.
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