Skip to content

[PROF-15559] Drop usage of MJIT headers for Ruby 2.6 to 3.1 - #6135

Merged
ivoanjo merged 11 commits into
masterfrom
ivoanjo/prof-15559-move-away-mjit-headers
Aug 18, 2026
Merged

[PROF-15559] Drop usage of MJIT headers for Ruby 2.6 to 3.1#6135
ivoanjo merged 11 commits into
masterfrom
ivoanjo/prof-15559-move-away-mjit-headers

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Jul 30, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This PR pairs with DataDog/datadog-ruby_core_source#29 and switches Ruby 2.6 to 3.1 over to using vendored headers instead of the MJIT header.

Motivation:

We've been considering dropping our use of the MJIT headers, and just use the "vendored headers" approach for all Rubies.

There's a few advantages to doing so:

  1. We remove a legacy code path -- modern Rubies don't have MJIT so having everyone using vendored headers helps make sure that changes work similarly to all Rubies.

  2. It opens the door for SSI (single step instrumentation) for the Ruby profiler. By not needing to rely on something from the target Ruby (the MJIT header), we should be able in the future to produce precompiled builds of the profiler extension. (To be clear, that's out of scope for this PR)

  3. One less corner case setting up the profiler -- the profiler now works even on Rubies where MJIT was disabled.

Change log entry

Yes. Profiling: Drop usage of MJIT headers for Ruby 2.6 to 3.1

(It's unlikely that this will break anyone, yet I think it's worthy of a changelog entry in case customers see compilation issues and check the changelog for probable causes for it)

Additional Notes:

I've tested this change will all stable releases from Ruby 2. to 3.2.9.

How to test the change?

Green CI is good!

@dd-octo-sts dd-octo-sts Bot added the profiling Involves Datadog profiling label Jul 30, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

⚠️ Warnings

🚦 1 Pipeline job failed

Check Pull Request CI Status | all-jobs-are-green

View in Datadog · View in GitHub Actions

Job failed: CI checks or statuses failed, please check the summary table.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 90.26% (+0.00%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1127056 | Docs | View more details | Give us feedback!

@ivoanjo

ivoanjo commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

I've queued up a few more cleanups in the branch. My plan is to:

  1. Get [PROF-15559] Add headers for Ruby 2.6 to 3.2 + bump gem version to 3.5.5 datadog-ruby_core_source#29 released
  2. Then do a cleanup of this branch
  3. Then this will be ready for review

@ivoanjo
ivoanjo force-pushed the ivoanjo/prof-15559-move-away-mjit-headers branch from edc67c7 to 545410b Compare August 18, 2026 10:35
@ivoanjo ivoanjo changed the title RFC: Drop usage of MJIT headers for Ruby 2.6 to 3.1 [PROF-15559] Drop usage of MJIT headers for Ruby 2.6 to 3.1 Aug 18, 2026
This is the first version that re-adds headers for Ruby 2.6, 2.7, 3.0,
3.1 and 3.2, allowing us to drop MJIT header usage.
I've checked all versions between 2.6.0 and 2.6.10 and all of them
pass the profiler test suite without the mjit headers.
I've checked all versions between 2.7.0 and 2.7.8 and all of them
pass the profiler test suite without the mjit headers.
I've checked all versions between 3.0.0 and 3.0.7 and all of them
pass the profiler test suite without the mjit headers.
I've checked all versions between 3.1.0 and 3.1.7 and all of them
pass the profiler test suite without the mjit headers.
I've checked all versions between 3.2.0 and 3.2.9 and all of them
pass the profiler test suite without the mjit headers.
@ivoanjo
ivoanjo force-pushed the ivoanjo/prof-15559-move-away-mjit-headers branch from 545410b to 5009d55 Compare August 18, 2026 10:42
@pr-commenter

pr-commenter Bot commented Aug 18, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-18 15:59:47

Comparing candidate commit 1127056 in PR branch ivoanjo/prof-15559-move-away-mjit-headers with baseline commit 2d0fbaf in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 49 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@ivoanjo
ivoanjo marked this pull request as ready for review August 18, 2026 13:03
@ivoanjo
ivoanjo requested review from a team as code owners August 18, 2026 13:03
@ivoanjo

ivoanjo commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

I've cleaned up the branch -- this is ready for review now!

@ivoanjo
ivoanjo requested a review from eregon August 18, 2026 13:03
Comment thread ext/datadog_profiling_native_extension/extconf.rb Outdated
Comment on lines +5 to 8
// The private_vm_api_access.c includes private VM headers (via datadog-ruby_core_source) which replace and conflict
// with any other Ruby headers; so we use PRIVATE_VM_API_ACCESS_SKIP_RUBY_INCLUDES to be able to include
// private_vm_api_access.h on that file without also dragging the incompatible includes
#ifndef PRIVATE_VM_API_ACCESS_SKIP_RUBY_INCLUDES

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.

I wonder why they conflict, I'll try.

@eregon eregon Aug 18, 2026

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.

On 4.0.6 the only conflicts seems the typedefs, i.e. this compiles on Ruby 4.0.6:

#include <ruby/thread_native.h>
#include <ruby/vm.h>
#ifndef PRIVATE_VM_API_ACCESS_SKIP_RUBY_INCLUDES
  typedef struct RubyCME rb_callable_method_entry_t;
  typedef struct RubyISEQ rb_iseq_t;
#endif

Also works on 2.6.10

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.

No need to change this in this PR, but maybe something we can try in another PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This might be a remnant of the mjit header days so do share what you learned! (I'll open up a follow-up PR with any improvements, rather than waiting on this one)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah I pushed my comment without seeing yours; ack I'll try in a follow-up PR to remove this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(I'm going to mark this as resolved to merge, and then I'll unresolve :P)

@ivoanjo
ivoanjo enabled auto-merge August 18, 2026 15:37
Comment thread ext/datadog_profiling_native_extension/extconf.rb
@ivoanjo
ivoanjo merged commit 7a21844 into master Aug 18, 2026
701 of 703 checks passed
@ivoanjo
ivoanjo deleted the ivoanjo/prof-15559-move-away-mjit-headers branch August 18, 2026 16:04
@dd-octo-sts dd-octo-sts Bot added this to the 2.42.0 milestone Aug 18, 2026
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.

5 participants