From 5952f2a3ae9b86daef6d77de60bc8499a357fa0b Mon Sep 17 00:00:00 2001 From: Alysha Date: Mon, 9 Jun 2025 16:03:13 -0400 Subject: [PATCH 01/18] chore(profiling): add recursive test to benchmarking suite --- benchmarks/recursive_computation/config.yaml | 81 ++++++++++++++ benchmarks/recursive_computation/scenario.py | 109 +++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 benchmarks/recursive_computation/config.yaml create mode 100644 benchmarks/recursive_computation/scenario.py diff --git a/benchmarks/recursive_computation/config.yaml b/benchmarks/recursive_computation/config.yaml new file mode 100644 index 00000000000..8e290d14cd5 --- /dev/null +++ b/benchmarks/recursive_computation/config.yaml @@ -0,0 +1,81 @@ +shallow: &base + max_depth: 10 + enable_cache: false + computation_intensity: 100 + enable_sleep: false + sleep_duration: 0.1 + nspans: 1 + profiler_enabled: false + +shallow-cached: + <<: *base + enable_cache: true + +medium: + <<: *base + max_depth: 50 + computation_intensity: 200 + +medium-cached: + <<: *base + max_depth: 50 + computation_intensity: 200 + enable_cache: true + +deep: + <<: *base + max_depth: 100 + computation_intensity: 300 + +deep-cached: + <<: *base + max_depth: 100 + computation_intensity: 300 + enable_cache: true + +deep-with-spans: + <<: *base + max_depth: 100 + computation_intensity: 300 + enable_cache: true + nspans: 5 + +intensive: + <<: *base + max_depth: 50 + computation_intensity: 1000 + enable_cache: true + nspans: 3 + +sleep-scenario: + <<: *base + max_depth: 20 + enable_sleep: true + sleep_duration: 0.01 + enable_cache: true + +shallow-profiled: + <<: *base + profiler_enabled: true + +medium-profiled: + <<: *base + max_depth: 50 + computation_intensity: 200 + enable_cache: true + profiler_enabled: true + +deep-profiled: + <<: *base + max_depth: 100 + computation_intensity: 300 + enable_cache: true + profiler_enabled: true + +intensive-profiled: + <<: *base + max_depth: 50 + computation_intensity: 1000 + enable_cache: true + nspans: 3 + profiler_enabled: true \ No newline at end of file diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py new file mode 100644 index 00000000000..5cd5c4119d6 --- /dev/null +++ b/benchmarks/recursive_computation/scenario.py @@ -0,0 +1,109 @@ +import math +import os +import time +from typing import Callable +from typing import Generator + +import bm +import bm.utils as utils + +from ddtrace.trace import tracer + + +class RecursiveComputation(bm.Scenario): + name: str + max_depth: int + enable_cache: bool + computation_intensity: int + enable_sleep: bool + sleep_duration: float + nspans: int + profiler_enabled: bool + + def cpu_intensive_computation(self, depth: int) -> int: + """Very CPU intensive computation that can be cached""" + result = 0 + + iterations = self.computation_intensity + depth * 10 + + for i in range(iterations): + result += math.sin(i) * math.cos(i) + math.sqrt(abs(i * depth + 1)) + result += sum(j * j for j in range(10)) + + temp_str = str(i * depth) + result += len(temp_str.replace('0', '').replace('1', '').replace('2', '')) + + for n in range(depth + 50, depth + 100): + is_prime = True + for div in range(2, int(math.sqrt(n)) + 1): + if n % div == 0: + is_prime = False + break + if is_prime: + result += n + + return int(result) % 1000000 + + def recursive_traced_computation(self, depth: int = 0) -> int: + """Recursively calls itself with tracing and optional caching""" + with tracer.trace(f"recursive_computation.depth_{depth}") as span: + span.set_tag("recursion.depth", depth) + span.set_tag("recursion.max_depth", self.max_depth) + span.set_tag("cache.enabled", self.enable_cache) + span.set_tag("profiler.enabled", self.profiler_enabled) + span.set_tag("component", "recursive_computation") + + if self.enable_cache and self.depth_cache and depth in self.depth_cache: + result = self.depth_cache[depth] + span.set_tag("cache.hit", True) + span.set_metric("cache.size", len(self.depth_cache)) + else: + span.set_tag("cache.hit", False) + start_time = time.time() + result = self.cpu_intensive_computation(depth) + compute_time = time.time() - start_time + + span.set_metric("computation.time_ms", compute_time * 1000) + span.set_metric("computation.result", result) + + if self.enable_cache and self.depth_cache is not None: + self.depth_cache[depth] = result + span.set_metric("cache.size", len(self.depth_cache)) + + for i in range(self.nspans): + with tracer.trace(f"computation.span_{i}"): + math.sqrt(i + depth) + + if depth < self.max_depth: + child_result = self.recursive_traced_computation(depth + 1) + span.set_metric("child.result", child_result) + result += child_result + elif self.enable_sleep: + span.set_tag("action", "sleep_at_max_depth") + time.sleep(self.sleep_duration) + + span.set_metric("final.result", result) + return result + + def run(self) -> Generator[Callable[[int], None], None, None]: + if self.profiler_enabled: + os.environ.update({ + "DD_PROFILING_ENABLED": "1", + "DD_PROFILING_API_TIMEOUT": "0.1", + "DD_PROFILING_UPLOAD_INTERVAL": "10" + }) + import ddtrace.profiling.auto + + self.depth_cache = {} if self.enable_cache else None + + utils.drop_traces(tracer) + utils.drop_telemetry_events() + + def _(loops: int) -> None: + for _ in range(loops): + if self.enable_cache: + self.depth_cache = {} + + self.recursive_traced_computation() + + yield _ \ No newline at end of file From c9d1cfc9c89943fe61f2dbbc69f8298b96c45ba1 Mon Sep 17 00:00:00 2001 From: Alysha Date: Mon, 9 Jun 2025 16:44:37 -0400 Subject: [PATCH 02/18] removed os variables that aren't needed --- benchmarks/recursive_computation/scenario.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py index 5cd5c4119d6..b349398738c 100644 --- a/benchmarks/recursive_computation/scenario.py +++ b/benchmarks/recursive_computation/scenario.py @@ -89,8 +89,6 @@ def run(self) -> Generator[Callable[[int], None], None, None]: if self.profiler_enabled: os.environ.update({ "DD_PROFILING_ENABLED": "1", - "DD_PROFILING_API_TIMEOUT": "0.1", - "DD_PROFILING_UPLOAD_INTERVAL": "10" }) import ddtrace.profiling.auto From 374c15d46bee89381747f180dc99824b0071a57f Mon Sep 17 00:00:00 2001 From: Alysha Date: Mon, 9 Jun 2025 17:38:40 -0400 Subject: [PATCH 03/18] remove caching and added simpler cpu computation --- benchmarks/recursive_computation/config.yaml | 20 ------- benchmarks/recursive_computation/scenario.py | 55 +++++--------------- 2 files changed, 14 insertions(+), 61 deletions(-) diff --git a/benchmarks/recursive_computation/config.yaml b/benchmarks/recursive_computation/config.yaml index 8e290d14cd5..f94a0c63964 100644 --- a/benchmarks/recursive_computation/config.yaml +++ b/benchmarks/recursive_computation/config.yaml @@ -1,7 +1,5 @@ shallow: &base max_depth: 10 - enable_cache: false - computation_intensity: 100 enable_sleep: false sleep_duration: 0.1 nspans: 1 @@ -9,42 +7,31 @@ shallow: &base shallow-cached: <<: *base - enable_cache: true medium: <<: *base max_depth: 50 - computation_intensity: 200 medium-cached: <<: *base max_depth: 50 - computation_intensity: 200 - enable_cache: true deep: <<: *base max_depth: 100 - computation_intensity: 300 deep-cached: <<: *base max_depth: 100 - computation_intensity: 300 - enable_cache: true deep-with-spans: <<: *base max_depth: 100 - computation_intensity: 300 - enable_cache: true nspans: 5 intensive: <<: *base max_depth: 50 - computation_intensity: 1000 - enable_cache: true nspans: 3 sleep-scenario: @@ -52,7 +39,6 @@ sleep-scenario: max_depth: 20 enable_sleep: true sleep_duration: 0.01 - enable_cache: true shallow-profiled: <<: *base @@ -61,21 +47,15 @@ shallow-profiled: medium-profiled: <<: *base max_depth: 50 - computation_intensity: 200 - enable_cache: true profiler_enabled: true deep-profiled: <<: *base max_depth: 100 - computation_intensity: 300 - enable_cache: true profiler_enabled: true intensive-profiled: <<: *base max_depth: 50 - computation_intensity: 1000 - enable_cache: true nspans: 3 profiler_enabled: true \ No newline at end of file diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py index b349398738c..b57686bccf1 100644 --- a/benchmarks/recursive_computation/scenario.py +++ b/benchmarks/recursive_computation/scenario.py @@ -13,62 +13,40 @@ class RecursiveComputation(bm.Scenario): name: str max_depth: int - enable_cache: bool - computation_intensity: int enable_sleep: bool sleep_duration: float nspans: int profiler_enabled: bool def cpu_intensive_computation(self, depth: int) -> int: - """Very CPU intensive computation that can be cached""" - result = 0 + limit = 1000 + (depth * 100) + primes = [] - iterations = self.computation_intensity + depth * 10 - - for i in range(iterations): - result += math.sin(i) * math.cos(i) + math.sqrt(abs(i * depth + 1)) - result += sum(j * j for j in range(10)) - - temp_str = str(i * depth) - result += len(temp_str.replace('0', '').replace('1', '').replace('2', '')) - - for n in range(depth + 50, depth + 100): + for num in range(2, limit): is_prime = True - for div in range(2, int(math.sqrt(n)) + 1): - if n % div == 0: + for i in range(2, int(num ** 0.5) + 1): + if num % i == 0: is_prime = False break + if is_prime: - result += n + primes.append(num) - return int(result) % 1000000 + return len(primes) def recursive_traced_computation(self, depth: int = 0) -> int: - """Recursively calls itself with tracing and optional caching""" with tracer.trace(f"recursive_computation.depth_{depth}") as span: span.set_tag("recursion.depth", depth) span.set_tag("recursion.max_depth", self.max_depth) - span.set_tag("cache.enabled", self.enable_cache) span.set_tag("profiler.enabled", self.profiler_enabled) span.set_tag("component", "recursive_computation") - if self.enable_cache and self.depth_cache and depth in self.depth_cache: - result = self.depth_cache[depth] - span.set_tag("cache.hit", True) - span.set_metric("cache.size", len(self.depth_cache)) - else: - span.set_tag("cache.hit", False) - start_time = time.time() - result = self.cpu_intensive_computation(depth) - compute_time = time.time() - start_time - - span.set_metric("computation.time_ms", compute_time * 1000) - span.set_metric("computation.result", result) - - if self.enable_cache and self.depth_cache is not None: - self.depth_cache[depth] = result - span.set_metric("cache.size", len(self.depth_cache)) + start_time = time.time() + result = self.cpu_intensive_computation(depth) + compute_time = time.time() - start_time + + span.set_metric("computation.time_ms", compute_time * 1000) + span.set_metric("computation.result", result) for i in range(self.nspans): with tracer.trace(f"computation.span_{i}"): @@ -92,16 +70,11 @@ def run(self) -> Generator[Callable[[int], None], None, None]: }) import ddtrace.profiling.auto - self.depth_cache = {} if self.enable_cache else None - utils.drop_traces(tracer) utils.drop_telemetry_events() def _(loops: int) -> None: for _ in range(loops): - if self.enable_cache: - self.depth_cache = {} - self.recursive_traced_computation() yield _ \ No newline at end of file From f342a9abc96e4211e329597b34af56d923630b2b Mon Sep 17 00:00:00 2001 From: Alysha Date: Mon, 9 Jun 2025 17:39:15 -0400 Subject: [PATCH 04/18] style fixes --- benchmarks/recursive_computation/scenario.py | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py index b57686bccf1..fc8d53aa0db 100644 --- a/benchmarks/recursive_computation/scenario.py +++ b/benchmarks/recursive_computation/scenario.py @@ -21,17 +21,17 @@ class RecursiveComputation(bm.Scenario): def cpu_intensive_computation(self, depth: int) -> int: limit = 1000 + (depth * 100) primes = [] - + for num in range(2, limit): is_prime = True - for i in range(2, int(num ** 0.5) + 1): + for i in range(2, int(num**0.5) + 1): if num % i == 0: is_prime = False break - + if is_prime: primes.append(num) - + return len(primes) def recursive_traced_computation(self, depth: int = 0) -> int: @@ -40,18 +40,18 @@ def recursive_traced_computation(self, depth: int = 0) -> int: span.set_tag("recursion.max_depth", self.max_depth) span.set_tag("profiler.enabled", self.profiler_enabled) span.set_tag("component", "recursive_computation") - + start_time = time.time() result = self.cpu_intensive_computation(depth) compute_time = time.time() - start_time - + span.set_metric("computation.time_ms", compute_time * 1000) span.set_metric("computation.result", result) - + for i in range(self.nspans): with tracer.trace(f"computation.span_{i}"): math.sqrt(i + depth) - + if depth < self.max_depth: child_result = self.recursive_traced_computation(depth + 1) span.set_metric("child.result", child_result) @@ -59,15 +59,17 @@ def recursive_traced_computation(self, depth: int = 0) -> int: elif self.enable_sleep: span.set_tag("action", "sleep_at_max_depth") time.sleep(self.sleep_duration) - + span.set_metric("final.result", result) return result def run(self) -> Generator[Callable[[int], None], None, None]: if self.profiler_enabled: - os.environ.update({ - "DD_PROFILING_ENABLED": "1", - }) + os.environ.update( + { + "DD_PROFILING_ENABLED": "1", + } + ) import ddtrace.profiling.auto utils.drop_traces(tracer) @@ -77,4 +79,4 @@ def _(loops: int) -> None: for _ in range(loops): self.recursive_traced_computation() - yield _ \ No newline at end of file + yield _ From 25685868136f57b0ec9ed2641ee1bbc9bc0918a5 Mon Sep 17 00:00:00 2001 From: Alysha Date: Mon, 9 Jun 2025 17:56:09 -0400 Subject: [PATCH 05/18] get rid of caching config --- benchmarks/recursive_computation/config.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/benchmarks/recursive_computation/config.yaml b/benchmarks/recursive_computation/config.yaml index f94a0c63964..e599e03e32d 100644 --- a/benchmarks/recursive_computation/config.yaml +++ b/benchmarks/recursive_computation/config.yaml @@ -5,25 +5,14 @@ shallow: &base nspans: 1 profiler_enabled: false -shallow-cached: - <<: *base - medium: <<: *base max_depth: 50 -medium-cached: - <<: *base - max_depth: 50 - deep: <<: *base max_depth: 100 -deep-cached: - <<: *base - max_depth: 100 - deep-with-spans: <<: *base max_depth: 100 From 840bf2cc833b71394dcb0beb0675fc75ed093596 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 13:02:32 -0400 Subject: [PATCH 06/18] style fixes and adding to gitlab suite --- .gitlab/benchmarks/microbenchmarks.yml | 1 + benchmarks/recursive_computation/scenario.py | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.gitlab/benchmarks/microbenchmarks.yml b/.gitlab/benchmarks/microbenchmarks.yml index 82306707fe0..ef073ef5af1 100644 --- a/.gitlab/benchmarks/microbenchmarks.yml +++ b/.gitlab/benchmarks/microbenchmarks.yml @@ -162,6 +162,7 @@ microbenchmarks: - "rate_limiter" - "packages_package_for_root_module_mapping" - "packages_update_imported_dependencies" + - "recursive_computation" - "telemetry_add_metric" - "startup" diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py index fc8d53aa0db..74554e224b1 100644 --- a/benchmarks/recursive_computation/scenario.py +++ b/benchmarks/recursive_computation/scenario.py @@ -65,12 +65,7 @@ def recursive_traced_computation(self, depth: int = 0) -> int: def run(self) -> Generator[Callable[[int], None], None, None]: if self.profiler_enabled: - os.environ.update( - { - "DD_PROFILING_ENABLED": "1", - } - ) - import ddtrace.profiling.auto + import ddtrace.profiling.auto # noqa: F401 utils.drop_traces(tracer) utils.drop_telemetry_events() From d961a6cd1ab6ed1e9431c7ea58dc667d3635ea45 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 13:16:36 -0400 Subject: [PATCH 07/18] style fixes --- benchmarks/recursive_computation/scenario.py | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py index 74554e224b1..f7cd44a5f80 100644 --- a/benchmarks/recursive_computation/scenario.py +++ b/benchmarks/recursive_computation/scenario.py @@ -1,5 +1,4 @@ import math -import os import time from typing import Callable from typing import Generator From 29d1227a54cd70e90cced152ee15af36e1e76db1 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 13:31:06 -0400 Subject: [PATCH 08/18] remove nspans & increase max_depth --- benchmarks/recursive_computation/config.yaml | 5 +---- benchmarks/recursive_computation/scenario.py | 5 ----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/benchmarks/recursive_computation/config.yaml b/benchmarks/recursive_computation/config.yaml index e599e03e32d..ee22dd9edaa 100644 --- a/benchmarks/recursive_computation/config.yaml +++ b/benchmarks/recursive_computation/config.yaml @@ -2,7 +2,6 @@ shallow: &base max_depth: 10 enable_sleep: false sleep_duration: 0.1 - nspans: 1 profiler_enabled: false medium: @@ -21,7 +20,6 @@ deep-with-spans: intensive: <<: *base max_depth: 50 - nspans: 3 sleep-scenario: <<: *base @@ -40,11 +38,10 @@ medium-profiled: deep-profiled: <<: *base - max_depth: 100 + max_depth: 300 profiler_enabled: true intensive-profiled: <<: *base max_depth: 50 - nspans: 3 profiler_enabled: true \ No newline at end of file diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py index f7cd44a5f80..f3d2cab43b8 100644 --- a/benchmarks/recursive_computation/scenario.py +++ b/benchmarks/recursive_computation/scenario.py @@ -14,7 +14,6 @@ class RecursiveComputation(bm.Scenario): max_depth: int enable_sleep: bool sleep_duration: float - nspans: int profiler_enabled: bool def cpu_intensive_computation(self, depth: int) -> int: @@ -47,10 +46,6 @@ def recursive_traced_computation(self, depth: int = 0) -> int: span.set_metric("computation.time_ms", compute_time * 1000) span.set_metric("computation.result", result) - for i in range(self.nspans): - with tracer.trace(f"computation.span_{i}"): - math.sqrt(i + depth) - if depth < self.max_depth: child_result = self.recursive_traced_computation(depth + 1) span.set_metric("child.result", child_result) From 83c25cde35ee9360e9329a8bc2cf49cce0a8dd66 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 13:55:23 -0400 Subject: [PATCH 09/18] removed unused import --- benchmarks/recursive_computation/scenario.py | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/recursive_computation/scenario.py b/benchmarks/recursive_computation/scenario.py index f3d2cab43b8..7f1f9c2baab 100644 --- a/benchmarks/recursive_computation/scenario.py +++ b/benchmarks/recursive_computation/scenario.py @@ -1,4 +1,3 @@ -import math import time from typing import Callable from typing import Generator From 669b8fcd80f86b736d9751c1b8b8eb72d036baff Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 14:00:02 -0400 Subject: [PATCH 10/18] remove occurence of nspans --- benchmarks/recursive_computation/config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/benchmarks/recursive_computation/config.yaml b/benchmarks/recursive_computation/config.yaml index ee22dd9edaa..8fc2c03d584 100644 --- a/benchmarks/recursive_computation/config.yaml +++ b/benchmarks/recursive_computation/config.yaml @@ -15,7 +15,6 @@ deep: deep-with-spans: <<: *base max_depth: 100 - nspans: 5 intensive: <<: *base From 0e032e908e475fadf7cd1410877a20f4f7894b64 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 14:22:01 -0400 Subject: [PATCH 11/18] changes to the config --- benchmarks/recursive_computation/config.yaml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/benchmarks/recursive_computation/config.yaml b/benchmarks/recursive_computation/config.yaml index 8fc2c03d584..1b5c1103469 100644 --- a/benchmarks/recursive_computation/config.yaml +++ b/benchmarks/recursive_computation/config.yaml @@ -10,15 +10,7 @@ medium: deep: <<: *base - max_depth: 100 - -deep-with-spans: - <<: *base - max_depth: 100 - -intensive: - <<: *base - max_depth: 50 + max_depth: 300 sleep-scenario: <<: *base @@ -39,8 +31,3 @@ deep-profiled: <<: *base max_depth: 300 profiler_enabled: true - -intensive-profiled: - <<: *base - max_depth: 50 - profiler_enabled: true \ No newline at end of file From b81c0a598464b4eb86d3f88aa8c8965c785f5824 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 14:57:21 -0400 Subject: [PATCH 12/18] chore(profiling): delete set_max_nframes and referencesl --- .../dd_wrapper/include/ddup_interface.hpp | 1 - .../dd_wrapper/include/sample_manager.hpp | 1 - .../profiling/dd_wrapper/src/ddup_interface.cpp | 6 ------ .../profiling/dd_wrapper/src/sample_manager.cpp | 14 -------------- .../profiling/dd_wrapper/test/test_utils.hpp | 1 - ddtrace/internal/datadog/profiling/ddup/_ddup.pyi | 1 - ddtrace/internal/datadog/profiling/ddup/_ddup.pyx | 4 ---- ddtrace/profiling/profiler.py | 1 - 8 files changed, 29 deletions(-) diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp b/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp index cf09edec496..0ea7c121920 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp @@ -21,7 +21,6 @@ extern "C" void ddup_config_runtime(std::string_view runtime); void ddup_config_profiler_version(std::string_view profiler_version); void ddup_config_url(std::string_view url); - void ddup_config_max_nframes(int max_nframes); void ddup_config_timeline(bool enable); void ddup_config_output_filename(std::string_view filename); void ddup_config_sample_pool_capacity(uint64_t capacity); diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp b/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp index faafe37ff95..aeec5d1a33e 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp @@ -23,7 +23,6 @@ class SampleManager public: // Configuration static void add_type(unsigned int type); - static void set_max_nframes(unsigned int _max_nframes); static void set_timeline(bool enable); static void set_sample_pool_capacity(size_t capacity); diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp index b9647dcb6bf..d720cf8cb2c 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp @@ -108,12 +108,6 @@ ddup_config_sample_type(unsigned int _type) // cppcheck-suppress unusedFunction Datadog::SampleManager::add_type(_type); } -void -ddup_config_max_nframes(int max_nframes) // cppcheck-suppress unusedFunction -{ - Datadog::SampleManager::set_max_nframes(max_nframes); -} - void ddup_config_timeline(bool enabled) // cppcheck-suppress unusedFunction { diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp index 96ca6b936d4..9e2306b0ac6 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp @@ -8,20 +8,6 @@ Datadog::SampleManager::add_type(unsigned int type) type_mask = static_cast((type_mask | type) & SampleType::All); } -void -Datadog::SampleManager::set_max_nframes(unsigned int _max_nframes) -{ - if (_max_nframes > 0) { - max_nframes = _max_nframes; - } - - // If the user has requested more than we're allowed to give, reduce the limit and warn the user. - if (max_nframes > g_backend_max_nframes) { - // We don't emit an error here for now. - max_nframes = g_backend_max_nframes; - } -} - void Datadog::SampleManager::set_timeline(bool enable) { diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp index 25b236ddb68..f216812d16c 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp @@ -55,7 +55,6 @@ configure(const char* service, ddup_config_runtime(runtime); ddup_config_runtime_version(runtime_version); ddup_config_profiler_version(profiler_version); - ddup_config_max_nframes(max_nframes); ddup_start(); } diff --git a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi index 4b76ebdd0b7..d45488f424f 100644 --- a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi +++ b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi @@ -10,7 +10,6 @@ def config( service: StringType, version: StringType, tags: Optional[Dict[Union[str, bytes], Union[str, bytes]]], - max_nframes: Optional[int], timeline_enabled: Optional[bool], output_filename: Optional[str], sample_pool_capacity: Optional[int], diff --git a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx index 7d564044d64..e04dfb4aee2 100644 --- a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx +++ b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx @@ -45,7 +45,6 @@ cdef extern from "ddup_interface.hpp": void ddup_config_runtime_version(string_view runtime_version) void ddup_config_profiler_version(string_view profiler_version) void ddup_config_url(string_view url) - void ddup_config_max_nframes(int max_nframes) void ddup_config_timeline(bint enable) void ddup_config_output_filename(string_view output_filename) void ddup_config_sample_pool_capacity(uint64_t sample_pool_capacity) @@ -327,7 +326,6 @@ def config( env: StringType = None, version: StringType = None, tags: Optional[Dict[Union[str, bytes], Union[str, bytes]]] = None, - max_nframes: Optional[int] = None, timeline_enabled: Optional[bool] = None, output_filename: StringType = None, sample_pool_capacity: Optional[int] = None) -> None: @@ -349,8 +347,6 @@ def config( call_func_with_str(ddup_config_runtime_version, platform.python_version()) call_func_with_str(ddup_config_profiler_version, ddtrace.__version__) - if max_nframes is not None: - ddup_config_max_nframes(clamp_to_int64_unsigned(max_nframes)) if tags is not None: for key, val in tags.items(): if key and val: diff --git a/ddtrace/profiling/profiler.py b/ddtrace/profiling/profiler.py index 24b11f37f45..5925f26966f 100644 --- a/ddtrace/profiling/profiler.py +++ b/ddtrace/profiling/profiler.py @@ -193,7 +193,6 @@ def _build_default_exporters(self): service=self.service, version=self.version, tags=self.tags, # type: ignore - max_nframes=profiling_config.max_frames, timeline_enabled=profiling_config.timeline_enabled, output_filename=profiling_config.output_pprof, sample_pool_capacity=profiling_config.sample_pool_capacity, From 4401c536cf67369537e39bd48e518ab02faefe9e Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 14:57:21 -0400 Subject: [PATCH 13/18] chore(profiling): delete set_max_nframes and referencesl --- .../dd_wrapper/include/ddup_interface.hpp | 1 - .../dd_wrapper/include/sample_manager.hpp | 1 - .../profiling/dd_wrapper/src/ddup_interface.cpp | 6 ------ .../profiling/dd_wrapper/src/sample_manager.cpp | 14 -------------- .../profiling/dd_wrapper/test/test_utils.hpp | 1 - ddtrace/internal/datadog/profiling/ddup/_ddup.pyi | 1 - ddtrace/internal/datadog/profiling/ddup/_ddup.pyx | 4 ---- 7 files changed, 28 deletions(-) diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp b/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp index cf09edec496..0ea7c121920 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/include/ddup_interface.hpp @@ -21,7 +21,6 @@ extern "C" void ddup_config_runtime(std::string_view runtime); void ddup_config_profiler_version(std::string_view profiler_version); void ddup_config_url(std::string_view url); - void ddup_config_max_nframes(int max_nframes); void ddup_config_timeline(bool enable); void ddup_config_output_filename(std::string_view filename); void ddup_config_sample_pool_capacity(uint64_t capacity); diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp b/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp index faafe37ff95..aeec5d1a33e 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/include/sample_manager.hpp @@ -23,7 +23,6 @@ class SampleManager public: // Configuration static void add_type(unsigned int type); - static void set_max_nframes(unsigned int _max_nframes); static void set_timeline(bool enable); static void set_sample_pool_capacity(size_t capacity); diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp index b9647dcb6bf..d720cf8cb2c 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/src/ddup_interface.cpp @@ -108,12 +108,6 @@ ddup_config_sample_type(unsigned int _type) // cppcheck-suppress unusedFunction Datadog::SampleManager::add_type(_type); } -void -ddup_config_max_nframes(int max_nframes) // cppcheck-suppress unusedFunction -{ - Datadog::SampleManager::set_max_nframes(max_nframes); -} - void ddup_config_timeline(bool enabled) // cppcheck-suppress unusedFunction { diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp index 96ca6b936d4..9e2306b0ac6 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/src/sample_manager.cpp @@ -8,20 +8,6 @@ Datadog::SampleManager::add_type(unsigned int type) type_mask = static_cast((type_mask | type) & SampleType::All); } -void -Datadog::SampleManager::set_max_nframes(unsigned int _max_nframes) -{ - if (_max_nframes > 0) { - max_nframes = _max_nframes; - } - - // If the user has requested more than we're allowed to give, reduce the limit and warn the user. - if (max_nframes > g_backend_max_nframes) { - // We don't emit an error here for now. - max_nframes = g_backend_max_nframes; - } -} - void Datadog::SampleManager::set_timeline(bool enable) { diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp index 25b236ddb68..f216812d16c 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp @@ -55,7 +55,6 @@ configure(const char* service, ddup_config_runtime(runtime); ddup_config_runtime_version(runtime_version); ddup_config_profiler_version(profiler_version); - ddup_config_max_nframes(max_nframes); ddup_start(); } diff --git a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi index 4b76ebdd0b7..d45488f424f 100644 --- a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi +++ b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyi @@ -10,7 +10,6 @@ def config( service: StringType, version: StringType, tags: Optional[Dict[Union[str, bytes], Union[str, bytes]]], - max_nframes: Optional[int], timeline_enabled: Optional[bool], output_filename: Optional[str], sample_pool_capacity: Optional[int], diff --git a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx index 7d564044d64..e04dfb4aee2 100644 --- a/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx +++ b/ddtrace/internal/datadog/profiling/ddup/_ddup.pyx @@ -45,7 +45,6 @@ cdef extern from "ddup_interface.hpp": void ddup_config_runtime_version(string_view runtime_version) void ddup_config_profiler_version(string_view profiler_version) void ddup_config_url(string_view url) - void ddup_config_max_nframes(int max_nframes) void ddup_config_timeline(bint enable) void ddup_config_output_filename(string_view output_filename) void ddup_config_sample_pool_capacity(uint64_t sample_pool_capacity) @@ -327,7 +326,6 @@ def config( env: StringType = None, version: StringType = None, tags: Optional[Dict[Union[str, bytes], Union[str, bytes]]] = None, - max_nframes: Optional[int] = None, timeline_enabled: Optional[bool] = None, output_filename: StringType = None, sample_pool_capacity: Optional[int] = None) -> None: @@ -349,8 +347,6 @@ def config( call_func_with_str(ddup_config_runtime_version, platform.python_version()) call_func_with_str(ddup_config_profiler_version, ddtrace.__version__) - if max_nframes is not None: - ddup_config_max_nframes(clamp_to_int64_unsigned(max_nframes)) if tags is not None: for key, val in tags.items(): if key and val: From e33dc71c0328c9ce758117fadfc14bb98f919b1c Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 15:08:54 -0400 Subject: [PATCH 14/18] delete unused parameter --- .../internal/datadog/profiling/dd_wrapper/test/test_utils.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp index f216812d16c..672924760a2 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_utils.hpp @@ -45,8 +45,7 @@ configure(const char* service, const char* url, const char* runtime, const char* runtime_version, - const char* profiler_version, - int max_nframes) + const char* profiler_version) { ddup_config_service(service); ddup_config_env(env); From 9e14d8a37fec4addbafb74c92f1b82b345eaa352 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 15:12:23 -0400 Subject: [PATCH 15/18] fix reference to method --- .../datadog/profiling/dd_wrapper/test/test_initialization.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_initialization.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_initialization.cpp index e4729c9eeb6..22e9413418f 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_initialization.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_initialization.cpp @@ -9,7 +9,7 @@ void simple_init() { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 256); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); std::exit(0); } @@ -21,7 +21,7 @@ TEST(InitDeathTest, TestInit) void empty_init() { - configure("", "", "", "", "", "", "", 0); + configure("", "", "", "", "", "", ""); std::exit(0); } From 2299199f096c2e4b6b0bf4c050ff59e643b4277a Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 15:30:10 -0400 Subject: [PATCH 16/18] fixed method call --- .../datadog/profiling/dd_wrapper/test/test_api.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_api.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_api.cpp index 3b9ba35af75..7ec4861fc5c 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_api.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_api.cpp @@ -10,7 +10,7 @@ void single_sample_noframe() { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 256); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); // Collect and flush one sample auto h = ddup_start_sample(); @@ -33,7 +33,7 @@ TEST(UploadDeathTest, SingleSample) void single_oneframe_sample() { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 256); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); // Collect and flush one sample with one frame auto h = ddup_start_sample(); @@ -57,7 +57,7 @@ TEST(UploadDeathTest, SingleSampleOneFrame) void single_manyframes_sample() { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 512); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); // Collect and flush one sample with one frame auto h = ddup_start_sample(); @@ -89,7 +89,7 @@ TEST(UploadDeathTest, SingleSampleManyFrames) void single_toomanyframes_sample() { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 512); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); // Collect and flush one sample with one frame auto h = ddup_start_sample(); @@ -121,7 +121,7 @@ TEST(UploadDeathTest, SingleSampleTooManyFrames) void lotsa_frames_lotsa_samples() { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 512); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); // 60 seconds @ 100 hertz for (int i = 0; i < 60 * 100; i++) { From 0d3d83d8ed4a87fd50d0e343aa4b5bfaebeb4188 Mon Sep 17 00:00:00 2001 From: Alysha Date: Tue, 10 Jun 2025 15:35:06 -0400 Subject: [PATCH 17/18] more fixes to method calls --- .../internal/datadog/profiling/dd_wrapper/test/test_forking.cpp | 2 +- .../datadog/profiling/dd_wrapper/test/test_threading.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cpp index 1aaadd62b61..3a5328fafd2 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cpp @@ -76,7 +76,7 @@ join_pthread_samplers(std::vector& threads, std::atomic& done) void sample_in_threads_and_fork(unsigned int num_threads, unsigned int sleep_time_ns) { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 256); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); std::atomic done(false); std::vector thread_handles; std::vector ids; diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_threading.cpp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_threading.cpp index 1ea48c8ccce..921044d35af 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_threading.cpp +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/test_threading.cpp @@ -24,7 +24,7 @@ generic_launch_sleep_upload(int n, unsigned int sleep_time_ns) void emulate_profiler(unsigned int num_threads, unsigned int sample_ns) { - configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100", 256); + configure("my_test_service", "my_test_env", "0.0.1", "https://127.0.0.1:9126", "cpython", "3.10.6", "3.100"); generic_launch_sleep_upload(num_threads, sample_ns); // Assumed to execute within a thread From 5bdfccf2365537e1739ae334a56540df77627d09 Mon Sep 17 00:00:00 2001 From: Alysha Date: Thu, 12 Jun 2025 13:49:55 -0400 Subject: [PATCH 18/18] remove max_frames ref --- ddtrace/profiling/profiler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ddtrace/profiling/profiler.py b/ddtrace/profiling/profiler.py index 48f953e7856..ae42edbd1b8 100644 --- a/ddtrace/profiling/profiler.py +++ b/ddtrace/profiling/profiler.py @@ -171,7 +171,6 @@ def _build_default_exporters(self): service=self.service, version=self.version, tags=self.tags, - max_nframes=profiling_config.max_frames, timeline_enabled=profiling_config.timeline_enabled, output_filename=profiling_config.output_pprof, sample_pool_capacity=profiling_config.sample_pool_capacity,