Skip to content

[PROF-4779] Refactor in preparation for use of libddprof from profiling native extension#1885

Merged
ivoanjo merged 15 commits into
masterfrom
ivoanjo/prof-4779-enable-libddprof
May 17, 2022
Merged

[PROF-4779] Refactor in preparation for use of libddprof from profiling native extension#1885
ivoanjo merged 15 commits into
masterfrom
ivoanjo/prof-4779-enable-libddprof

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Feb 7, 2022

Copy link
Copy Markdown
Member

libddprof is a Rust-based library that implements common functionality used by our profilers:

  • aggregation of profiling data
  • serialization of profiling data
  • reporting of profiling data to backend

This PR adds the scaffolding to enable usage of libddprof from dd-trace-rb, but does not yet make use of any of its functionality.

Currently, libddprof works for all supported Rubies (2.1 to 3.2 dev) but only on x86-64 and 64-bit ARM Linux. The current integration has been set up in such a way that on other platforms we print a nice banner telling customers that they won't have profiling but do not otherwise impact the customer in using all other Datadog products (tracing, ci, appsec, ...).

This PR includes a nice refactoring + addition of tests to make sure this safe installation behavior is working correctly.

Note: To allow this PR to be merged in more quickly, I've commented out the actual libddprof linking bits in extconf.rb; I'll re-enable that in a later PR.

@ivoanjo
ivoanjo requested a review from a team February 7, 2022 11:49

@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, probably worth another pair of eyes as to how this behaves overall WRT general ddtrace user usage.

@ivoanjo
ivoanjo force-pushed the ivoanjo/prof-4779-enable-libddprof branch from b68274a to 1090d71 Compare February 28, 2022 15:51
@ivoanjo
ivoanjo changed the base branch from 1.0 to master February 28, 2022 15:51
@ivoanjo

ivoanjo commented Feb 28, 2022

Copy link
Copy Markdown
Member Author

This PR was opened to target the 1.0 branch. I've just rebased it now on top of current master, and moved it to target that branch, since 1.0 is no more. No further changes :)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #1885 (73863f8) into master (b5bae3c) will decrease coverage by 0.00%.
The diff coverage is 97.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1885      +/-   ##
==========================================
- Coverage   97.51%   97.51%   -0.01%     
==========================================
  Files         997      999       +2     
  Lines       48739    48858     +119     
==========================================
+ Hits        47528    47642     +114     
- Misses       1211     1216       +5     
Impacted Files Coverage Δ
spec/datadog/profiling/native_extension_spec.rb 94.50% <0.00%> (-2.13%) ⬇️
...iling_native_extension/native_extension_helpers.rb 100.00% <100.00%> (ø)
spec/datadog/core/configuration/components_spec.rb 99.68% <100.00%> (-0.01%) ⬇️
spec/datadog/core/configuration_spec.rb 100.00% <100.00%> (ø)
spec/datadog/profiling/integration_spec.rb 97.29% <100.00%> (-0.02%) ⬇️
...datadog/profiling/native_extension_helpers_spec.rb 100.00% <100.00%> (ø)
spec/datadog/profiling/pprof/builder_spec.rb 100.00% <100.00%> (ø)
spec/datadog/profiling/pprof/stack_sample_spec.rb 100.00% <100.00%> (ø)
spec/datadog/profiling/pprof/template_spec.rb 100.00% <100.00%> (ø)
spec/datadog/profiling/spec_helper.rb 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5bae3c...73863f8. Read the comment docs.

@ivoanjo

ivoanjo commented Mar 2, 2022

Copy link
Copy Markdown
Member Author

@delner care to chime in?

@ivoanjo

ivoanjo commented Apr 25, 2022

Copy link
Copy Markdown
Member Author

I've just did another rebase of this PR, fixing a conflict and adding a few cleanups for things that had since became a bit stale.

Before this PR gets merged in we must release libddprof 0.6.0 on rubygems.org: DataDog/libddprof#59 since older versions will break some of our integration tests (see da925a0 for details).

@ivoanjo ivoanjo changed the title [PROF-4779] [Not for 1.0.0] Enable use of libddprof from profiling native extension [PROF-4779] [Not for 1.0.0/1.1.0] Enable use of libddprof from profiling native extension May 5, 2022
@ivoanjo
ivoanjo marked this pull request as draft May 5, 2022 10:13
@ivoanjo

ivoanjo commented May 5, 2022

Copy link
Copy Markdown
Member Author

Converted to draft as we're still waiting on 1.1.0 to go out, and then possible a rebase and maybe pull in a fix or two :)

@ivoanjo ivoanjo changed the title [PROF-4779] [Not for 1.0.0/1.1.0] Enable use of libddprof from profiling native extension [PROF-4779] Enable use of libddprof from profiling native extension May 16, 2022
ivoanjo added 13 commits May 16, 2022 09:38
Also reviewed some of the wording in the user-visible banners.
These validations mean that the profiler native extension will no
longer be built unless libddprof is avaliable.

The extension itself does not yet get compiled using libddprof.
Because we're not yet using any of the functions, libddprof will
actually be thrown away at linking time, but everything is ready for
us to use them.
…ment in docker volume

This avoids a massive performance hit when this folder is shared
with a macOS host (seconds to minutes, I kid you not!).
I was not liking how this was looking. This is much nicer!
…on is available

Now that libddprof is in the picture, the profiling native extension
will usually not be built for macOS, so we allow these tests to
fail when no extension is available.
ivoanjo added 2 commits May 16, 2022 10:22
This is a much nicer approach than just adding them and hoping for the
best! Also, it means we can enable more warnings, even if they get
ignored on older compilers.
This is a temporary measure to simplify PR
<#1885>.

A later PR will re-enable all of this.
@ivoanjo
ivoanjo force-pushed the ivoanjo/prof-4779-enable-libddprof branch from da925a0 to be6fb26 Compare May 16, 2022 09:48
@ivoanjo ivoanjo changed the title [PROF-4779] Enable use of libddprof from profiling native extension [PROF-4779] Refactor in prepraration for use of libddprof from profiling native extension May 16, 2022
@ivoanjo
ivoanjo marked this pull request as ready for review May 16, 2022 09:56
@ivoanjo

ivoanjo commented May 16, 2022

Copy link
Copy Markdown
Member Author

I've rebased this PR, did a few cleanups, and disabled actually linking to libddprof so we can merge it in ASAP.

before do
skip 'Profiling is not supported on JRuby' if PlatformHelpers.jruby?
skip 'Profiling is not supported on TruffleRuby' if PlatformHelpers.truffleruby?
skip_if_profiling_not_supported(self)

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.

🧹

@ivoanjo

ivoanjo commented May 17, 2022

Copy link
Copy Markdown
Member Author

Thanks y'all! Let's get this show on the road :)

@ivoanjo
ivoanjo merged commit b8801d1 into master May 17, 2022
@ivoanjo
ivoanjo deleted the ivoanjo/prof-4779-enable-libddprof branch May 17, 2022 08:41
@github-actions github-actions Bot added this to the 1.1.0 milestone May 17, 2022
@ivoanjo ivoanjo changed the title [PROF-4779] Refactor in prepraration for use of libddprof from profiling native extension [PROF-4779] Refactor in preparation for use of libddprof from profiling native extension May 25, 2022
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.

5 participants