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

[PROF-7409] Do not auto-enable new profiler when rugged gem is detected #2741

Merged
merged 2 commits into from
Apr 5, 2023

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Apr 4, 2023

What does this PR do?:

This PR adds the rugged gem to the list of gems that prevent the new CPU Profiling 2.0 profiler from being auto-enabled.

This is needed because the rugged gem (more specifically, its C-level dependencies) do not correctly handle the unix signals that the new profiler uses.

We plan to do more than just add this workaround, but until we do so, this change will prevent customers from being bitten by the issue.

Motivation:

Make sure that customers being moved to the new CPU Profiling 2.0 profiler have a smooth experience.

Additional Notes:

N/A

How to test the change?:

The snippet shared by the customer in #2721 reproduces the issue for me every time.

With this change, as expected, the issue no longer appears.

This is useful when testing if a specific bit of code is affected by
sigprof signal delivery.

I'm using it to test the issue reported in #2721.

I think this helper is small enough/useful enough to keep around for
later.
**What does this PR do?**:

This PR adds the `rugged` gem to the list of gems that prevent the new
CPU Profiling 2.0 profiler from being auto-enabled.

This is needed because the `rugged` gem (more specifically, its
C-level dependencies) do not correctly handle the unix signals that the
new profiler uses.

We plan to do more than just add this workaround, but until we do so,
this change will prevent customers from being bitten by the issue.

**Motivation**:

Make sure that customers being moved to the new CPU Profiling 2.0
profiler have a smooth experience.

**Additional Notes**:

N/A

**How to test the change?**:

The snippet shared by the customer in
<#2721> reproduces the
issue for me every time.

With this change, as expected, the issue no longer appears.
@ivoanjo ivoanjo requested a review from a team April 4, 2023 13:47
@github-actions github-actions bot added the profiling Involves Datadog profiling label Apr 4, 2023
@@ -222,6 +223,7 @@ void collectors_cpu_and_wall_time_worker_init(VALUE profiling_module) {
rb_define_singleton_method(testing_module, "_native_simulate_handle_sampling_signal", _native_simulate_handle_sampling_signal, 0);
rb_define_singleton_method(testing_module, "_native_simulate_sample_from_postponed_job", _native_simulate_sample_from_postponed_job, 0);
rb_define_singleton_method(testing_module, "_native_is_sigprof_blocked_in_current_thread", _native_is_sigprof_blocked_in_current_thread, 0);
rb_define_singleton_method(testing_module, "_native_with_blocked_sigprof", _native_with_blocked_sigprof, 0);
Copy link
Member Author

Choose a reason for hiding this comment

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

I've added this as a useful helper to test in issues like this (see individual commits for details)

@ivoanjo ivoanjo merged commit a0cdcbc into master Apr 5, 2023
@ivoanjo ivoanjo deleted the ivoanjo/prof-7409-rugged-gem-workaround branch April 5, 2023 14:59
@github-actions github-actions bot added this to the 1.11.0 milestone Apr 5, 2023
if Gem.loaded_specs['rugged']
Datadog.logger.warn(
'Falling back to legacy profiler because rugged gem is installed. Some operations on this gem are ' \
'currently incompatible with the new CPU Profiling 2.0 profiler, as detailed in ' \
Copy link
Member

Choose a reason for hiding this comment

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

Is there a subset of the rugged gem that's safe, like an specific version? I'm asking so users know when it makes sense to try to enable profiling 2.0 anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, there isn't. It's on my next-things-to-do list to report this upstream and even seeing if I can submit a PR with a fix or workaround, which would allow us to indeed make this finer-grained than what this PR does.

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