Skip to content

Commit

Permalink
Merge pull request #4356 from DataDog/ivoanjo/prof-11311-remove-profi…
Browse files Browse the repository at this point in the history
…ling-loader

[PROF-11311] Remove datadog_profiling_loader
  • Loading branch information
ivoanjo authored Feb 7, 2025
2 parents 8295f62 + db67572 commit 6b6ec18
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 315 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dev/testing:
# Changes to Profiling
profiling:
- changed-files:
- any-glob-to-any-file: [ '{lib/datadog/profiling/**,ext/datadog_profiling_loader/**,ext/datadog_profiling_native_extension/**}' ]
- any-glob-to-any-file: [ '{lib/datadog/profiling/**,ext/datadog_profiling_native_extension/**}' ]

# Changes to CI-App
ci-app:
Expand Down
4 changes: 0 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,6 @@ NATIVE_EXTS = [
ext.ext_dir = 'ext/datadog_profiling_native_extension'
end,

Rake::ExtensionTask.new("datadog_profiling_loader.#{RUBY_VERSION}_#{RUBY_PLATFORM}") do |ext|
ext.ext_dir = 'ext/datadog_profiling_loader'
end,

Rake::ExtensionTask.new("libdatadog_api.#{RUBY_VERSION[/\d+.\d+/]}_#{RUBY_PLATFORM}") do |ext|
ext.ext_dir = 'ext/libdatadog_api'
end
Expand Down
1 change: 0 additions & 1 deletion datadog.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ Gem::Specification.new do |spec|

spec.extensions = [
'ext/datadog_profiling_native_extension/extconf.rb',
'ext/datadog_profiling_loader/extconf.rb',
'ext/libdatadog_api/extconf.rb'
]
end
1 change: 0 additions & 1 deletion ext/datadog_profiling_loader/.clang-format

This file was deleted.

142 changes: 0 additions & 142 deletions ext/datadog_profiling_loader/datadog_profiling_loader.c

This file was deleted.

60 changes: 0 additions & 60 deletions ext/datadog_profiling_loader/extconf.rb

This file was deleted.

6 changes: 6 additions & 0 deletions ext/datadog_profiling_native_extension/profiling.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ static VALUE _native_malloc_stats(DDTRACE_UNUSED VALUE _self);
static VALUE _native_safe_object_info(DDTRACE_UNUSED VALUE _self, VALUE obj);

void DDTRACE_EXPORT Init_datadog_profiling_native_extension(void) {
// The profiler still has a lot of limitations around being used in Ractors BUT for now we're choosing to take care of those
// on our side, rather than asking Ruby to block calling our APIs from Ractors.
#ifdef HAVE_RB_EXT_RACTOR_SAFE
rb_ext_ractor_safe(true);
#endif

VALUE datadog_module = rb_define_module("Datadog");
VALUE profiling_module = rb_define_module_under(datadog_module, "Profiling");
VALUE native_extension_module = rb_define_module_under(profiling_module, "NativeExtension");
Expand Down
34 changes: 1 addition & 33 deletions lib/datadog/profiling/load_native_extension.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
# frozen_string_literal: true

# This file is used to load the profiling native extension. It works in two steps:
#
# 1. Load the datadog_profiling_loader extension. This extension will be used to load the actual extension, but in
# a special way that avoids exposing native-level code symbols. See `datadog_profiling_loader.c` for more details.
#
# 2. Use the Datadog::Profiling::Loader exposed by the datadog_profiling_loader extension to load the actual
# profiling native extension.
#
# All code on this file is on-purpose at the top-level; this makes it so this file is executed only once,
# the first time it gets required, to avoid any issues with the native extension being initialized more than once.

begin
require "datadog_profiling_loader.#{RUBY_VERSION}_#{RUBY_PLATFORM}"
require "datadog_profiling_native_extension.#{RUBY_VERSION}_#{RUBY_PLATFORM}"
rescue LoadError => e
raise LoadError,
"Failed to load the profiling loader extension. To fix this, please remove and then reinstall datadog " \
"(Details: #{e.message})"
end

extension_name = "datadog_profiling_native_extension.#{RUBY_VERSION}_#{RUBY_PLATFORM}"
file_name = "#{extension_name}.#{RbConfig::CONFIG["DLEXT"]}"
full_file_path = "#{__dir__}/../../#{file_name}"

unless File.exist?(full_file_path)
extension_dir = Gem.loaded_specs["datadog"].extension_dir
candidate_path = "#{extension_dir}/#{file_name}"
if File.exist?(candidate_path)
full_file_path = candidate_path
else
# We found none of the files. This is unexpected. Let's go ahead anyway, the error is going to be reported further
# down anyway.
end
end

init_function_name = "Init_#{extension_name.split(".").first}"

status, result = Datadog::Profiling::Loader._native_load(full_file_path, init_function_name)

raise "Failure to load #{extension_name} due to #{result}" if status == :error
73 changes: 0 additions & 73 deletions spec/datadog/profiling/load_native_extension_spec.rb

This file was deleted.

0 comments on commit 6b6ec18

Please sign in to comment.