Skip to content
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

Disable profiler on Ruby 3.3 due to incompatibility #3054

Merged
merged 5 commits into from
Aug 18, 2023

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Aug 17, 2023

What does this PR do?:

In #3053 I reported the discovery that the profiler is currently not working on Ruby 3.3-head (reported by a customer that tests with head in CI).

A full fix for #3053 seems like it may take a while, so until it's available, let's gracefully disable the profiler in Ruby 3.3, so that instead of a compilation failure, customers just get a nice message saying we don't support 3.3 right now.

Motivation:

Improve experience for current customers testing with 3.3-head and future customers trying to profile 3.3.

Additional Notes:

Customers will be shown the following message when trying to profile on Ruby 3.3:

WARN -- ddtrace: [ddtrace] Profiling was requested but is not supported, profiling disabled: Your ddtrace installation is missing support for the Continuous Profiler because the profiler in the current version of ddtrace does not yet support Ruby version 3.3. (See #3053 for details). Try upgrading to the latest ddtrace, as this issue may have been fixed by now. For help solving this issue, please contact Datadog support at https://docs.datadoghq.com/help/. You can also check out the
Continuous Profiler troubleshooting page at https://dtdg.co/ruby-profiler-troubleshooting.

How to test the change?:

Try to profile ruby-3.3 (any version) and confirm the profiler disables itself gracefully.

**What does this PR do?**:

In #3053 I reported the discovery that the profiler is currently not
working on Ruby 3.3-head (reported by a customer that tests with
head in CI).

A full fix for #3053 seems like it may take a while, so until it's
available, let's gracefully disable the profiler in Ruby 3.3, so that
instead of a compilation failure, customers just get a nice message
saying we don't support 3.3 right now.

**Motivation**:

Improve experience for current customers testing with 3.3-head and
future customers trying to profile 3.3.

**Additional Notes**:

Customers will be shown the following message when trying to profile
on Ruby 3.3:

```
WARN -- ddtrace: [ddtrace] Profiling was requested but is not supported,
profiling disabled: Your ddtrace installation is missing support for the
Continuous Profiler because the profiler in the current version of
ddtrace does not yet support Ruby version 3.3. (See
#3053 for details). Try
upgrading to the latest ddtrace, as this issue may have been fixed by
now. For help solving this issue, please contact Datadog support at
<https://docs.datadoghq.com/help/>. You can also check out the
Continuous Profiler troubleshooting page at
<https://dtdg.co/ruby-profiler-troubleshooting>.
```

**How to test the change?**:

Try to profile ruby-3.3 (any version) and confirm the profiler
disables itself gracefully.
@ivoanjo ivoanjo requested a review from a team August 17, 2023 10:25
@github-actions github-actions bot added the profiling Involves Datadog profiling label Aug 17, 2023
@ivoanjo ivoanjo force-pushed the ivoanjo/disable-profiling-ruby3_3 branch from cd7069a to 21deae1 Compare August 17, 2023 10:47
@ivoanjo
Copy link
Member Author

ivoanjo commented Aug 17, 2023

CircleCI seems to not be picking up the extra commits I added to this PR 😓... and triggering it manually gets me
image

I'll wait for a few hours and see if they're able to recover.

@ivoanjo ivoanjo force-pushed the ivoanjo/disable-profiling-ruby3_3 branch from 21deae1 to 06c2ac6 Compare August 17, 2023 13:58
This is slightly ugly, but we'll be able to remove it when we drop
support for Ruby 2.1/2.2 and/or re-add support for Ruby 3.3.
@ivoanjo ivoanjo force-pushed the ivoanjo/disable-profiling-ruby3_3 branch from 5296240 to 8b93b27 Compare August 17, 2023 15:27
Sigh, trying to fix specs during meetings >_>
@codecov-commenter
Copy link

Codecov Report

Merging #3054 (855cd0b) into master (4761891) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3054   +/-   ##
=======================================
  Coverage   98.13%   98.13%           
=======================================
  Files        1328     1328           
  Lines       75039    75049   +10     
  Branches     3408     3411    +3     
=======================================
+ Hits        73639    73651   +12     
+ Misses       1400     1398    -2     
Files Changed Coverage Δ
...iling_native_extension/native_extension_helpers.rb 96.90% <100.00%> (+0.16%) ⬆️
...datadog/profiling/native_extension_helpers_spec.rb 97.85% <100.00%> (+0.04%) ⬆️
spec/datadog/profiling/spec_helper.rb 95.55% <100.00%> (+0.20%) ⬆️

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ivoanjo
Copy link
Member Author

ivoanjo commented Aug 18, 2023

After CircleCI went back up, I pushed a few small fixes for the integration apps (I had not disabled testing for profiler on 3.3 for those). Thanks Tony && Marco for the review, going ahead and merging!

@ivoanjo ivoanjo merged commit 1532b27 into master Aug 18, 2023
203 checks passed
@ivoanjo ivoanjo deleted the ivoanjo/disable-profiling-ruby3_3 branch August 18, 2023 07:25
@github-actions github-actions bot added this to the 1.14.0 milestone Aug 18, 2023
ivoanjo added a commit that referenced this pull request Sep 28, 2023
**What does this PR do?**

Back in #3053, a customer reported that profiling was not working
on ruby-head (for Ruby 3.3).

At the time, I tracked it down to two issues:
1. A bunch of headers had changed, and thus we needed a new
   release of `debase-ruby_core_source` to include them
2. We were getting errors when loading the profiler due to the
   `ruby_current_ec` VM symbol no longer being available.

At the time, I chose to disable profiling on Ruby 3.3 (#3054) until
we could tackle these two items.

Item 1. was fixed in #3163, that pulls in a new release of
`debase-ruby_core_source` that includes the 3.3-preview2 headers.

This PR fixes item 2. and re-enables profiling on Ruby 3.3
(and thus reverts #3054).

**Motivation:**

Make sure we're in good shape for the Ruby 3.3 final release in
December.

**Additional Notes:**

We didn't use the magic `ruby_current_ec` VM symbol directly.
Instead, we were using `GET_RACTOR()` and `GET_EC()` which call
a few methods that are defined as `inline` in `vm_core.h`.

Those methods all relied on `ruby_current_ec`, and thus hiding
that symbol made them break.

As an alternative, we can get to the same objects by starting
with the current thread, and navigating the object graph a bit.

The `rb_thread_current()` also relies on `ruby_current_ec` but
crucially **is not inline** and is actually a public API of the VM,
so that one kept working.

I hesitated on if we should use `rb_thread_current()` on all
Rubies with Ractors, or if we should keep the fast path for
3.0 to 3.2. I ended up deciding to keep the fast path since
it was quite easy to do, but in the future we could instead
choose to simplify this whole thing.

P.s.: This is one of those PRs where a lot of work went into
a handful of unimpressive lines of code 😅 .

**How to test the change?**

Validate that CI is passing on Ruby 3.3!

Fixes #3053
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.

None yet

4 participants