Skip to content

[PROF-13115] Re-enable heap profiling on Ruby 4.0#5121

Merged
ivoanjo merged 3 commits into
masterfrom
ivoanjo/prof-13115-reenable-heap-profiling-ruby4
Dec 9, 2025
Merged

[PROF-13115] Re-enable heap profiling on Ruby 4.0#5121
ivoanjo merged 3 commits into
masterfrom
ivoanjo/prof-13115-reenable-heap-profiling-ruby4

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Dec 9, 2025

Copy link
Copy Markdown
Member

What does this PR do?

This PR is a revert of #5090 + with a few extra cleanups of code that referenced Ruby 3.5, updating it to reference Ruby 4/4.0.

Motivation:

In #5090 we disabled heap profiling on Ruby 4 due to https://bugs.ruby-lang.org/issues/21710 because we weren't sure of when the issue would be fixed (either upstream or with extra work on our side).

It turns out that upstream made a very speedy fix, so we don't need to disable this feature anymore -- I've tested with current ruby-head and it works fine again.

Change log entry
None. (We never released #5090.)

Additional Notes:

Because CI is not on ruby-head, and is still on 4.0.0preview2 where the issue still happens, I've kept a skip for the heap profiling specs for that version.

While I was searching for other 3.5 references, I spotted a bunch in the codebase so I ended up updating those too. I've separated out the changes into commits so they can be reviewed separately if needed.

How to test the change?

CI is green + run profiler specs on latest ruby-head and validate it's still green.

Ruby 3.5.0 will never exist and has been renamed to 4.0.0.
…incompatibility"

This reverts commit 662eed8.

The upstream bug has been fixed so we'll add a 4.0.0preview2-specific
skip for CI but no need to fuse off heap profiling in the release
itself since we know 4.0.0 is expected to work fine again.
We still have 4.0.0preview2 in CI (which we don't want to break)
but the issue is fixed in master + I've locally validated it so
we just need to keep CI happy until we get rid of 4.0.0preview2.
@ivoanjo
ivoanjo requested review from a team as code owners December 9, 2025 09:42
@github-actions github-actions Bot added the profiling Involves Datadog profiling label Dec 9, 2025
@datadog-official

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 100.00%
Total Coverage: 95.23% (+0.00%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 978c774 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@lloeki lloeki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@ivoanjo
ivoanjo merged commit 49a28d5 into master Dec 9, 2025
554 checks passed
@ivoanjo
ivoanjo deleted the ivoanjo/prof-13115-reenable-heap-profiling-ruby4 branch December 9, 2025 10:06
@github-actions github-actions Bot added this to the 2.23.0 milestone Dec 9, 2025
ivoanjo added a commit that referenced this pull request Dec 15, 2025
**What does this PR do?**

This PR disables the heap profiling feature when running on Ruby 4 as
the current implementation (that relies on object_id) is not safe to use
on Ruby 4.

**Motivation:**

Avoid impacting applications running on Ruby 4.

**Additional Notes:**

Discussion with the Ruby core team in
https://bugs.ruby-lang.org/issues/21710 has uncovered that our use
of object_id from inside the NEWOBJ tracepoint is not safe on
Ruby 4, and it's likely it can't be made safe.

Until we're able to replace the Datadog profiler's usage of
object_id for heap profiling, we won't be able to safely offer
this feature on Ruby 4.

(We temporarily disabled the heap profiler for 4.0.0-preview2 in
 #5091 and re-enabled it in #5121 when it looked fixed but
discussion on the upstream ticket uncovered further issues)

**How to test the change?**

Validate that profiler doesn't enable heap profiling on Ruby 4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Involves Datadog profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants