Skip to content

chore(profiling): delete set_max_nframes and its references #13641

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5952f2a
chore(profiling): add recursive test to benchmarking suite
alyshawang Jun 9, 2025
20505b5
Merge branch 'main' into alysha.wang/add_recursive_benchmarking
taegyunkim Jun 9, 2025
c9d1cfc
removed os variables that aren't needed
alyshawang Jun 9, 2025
aeee61e
Merge branch 'alysha.wang/add_recursive_benchmarking' of github.com:D…
alyshawang Jun 9, 2025
374c15d
remove caching and added simpler cpu computation
alyshawang Jun 9, 2025
f342a9a
style fixes
alyshawang Jun 9, 2025
2568586
get rid of caching config
alyshawang Jun 9, 2025
840bf2c
style fixes and adding to gitlab suite
alyshawang Jun 10, 2025
d961a6c
style fixes
alyshawang Jun 10, 2025
29d1227
remove nspans & increase max_depth
alyshawang Jun 10, 2025
83c25cd
removed unused import
alyshawang Jun 10, 2025
669b8fc
remove occurence of nspans
alyshawang Jun 10, 2025
0e032e9
changes to the config
alyshawang Jun 10, 2025
090f8d7
Merge branch 'main' into alysha.wang/add_recursive_benchmarking
taegyunkim Jun 10, 2025
b81c0a5
chore(profiling): delete set_max_nframes and referencesl
alyshawang Jun 10, 2025
0735633
Merge remote-tracking branch 'origin/main' into alysha.wang/max_stack…
alyshawang Jun 10, 2025
4401c53
chore(profiling): delete set_max_nframes and referencesl
alyshawang Jun 10, 2025
b5399ef
Merge branch 'alysha.wang/max_stack_frames' of github.com:DataDog/dd-…
alyshawang Jun 10, 2025
e33dc71
delete unused parameter
alyshawang Jun 10, 2025
9e14d8a
fix reference to method
alyshawang Jun 10, 2025
2299199
fixed method call
alyshawang Jun 10, 2025
0d3d83d
more fixes to method calls
alyshawang Jun 10, 2025
0471475
Merge remote-tracking branch 'origin/main' into alysha.wang/max_stack…
alyshawang Jun 11, 2025
5bdfccf
remove max_frames ref
alyshawang Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab/benchmarks/microbenchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ microbenchmarks:
- "rate_limiter"
- "packages_package_for_root_module_mapping"
- "packages_update_imported_dependencies"
- "recursive_computation"
- "telemetry_add_metric"
- "startup"

Expand Down
33 changes: 33 additions & 0 deletions benchmarks/recursive_computation/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
shallow: &base
max_depth: 10
enable_sleep: false
sleep_duration: 0.1
profiler_enabled: false

medium:
<<: *base
max_depth: 50

deep:
<<: *base
max_depth: 300

sleep-scenario:
<<: *base
max_depth: 20
enable_sleep: true
sleep_duration: 0.01

shallow-profiled:
<<: *base
profiler_enabled: true

medium-profiled:
<<: *base
max_depth: 50
profiler_enabled: true

deep-profiled:
<<: *base
max_depth: 300
profiler_enabled: true
70 changes: 70 additions & 0 deletions benchmarks/recursive_computation/scenario.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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_sleep: bool
sleep_duration: float
profiler_enabled: bool

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):
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:
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("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)

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:
import ddtrace.profiling.auto # noqa: F401

utils.drop_traces(tracer)
utils.drop_telemetry_events()

def _(loops: int) -> None:
for _ in range(loops):
self.recursive_traced_computation()

yield _
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@ Datadog::SampleManager::add_type(unsigned int type)
type_mask = static_cast<SampleType>((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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ join_pthread_samplers(std::vector<pthread_t>& threads, std::atomic<bool>& 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<bool> done(false);
std::vector<pthread_t> thread_handles;
std::vector<unsigned int> ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -21,7 +21,7 @@ TEST(InitDeathTest, TestInit)
void
empty_init()
{
configure("", "", "", "", "", "", "", 0);
configure("", "", "", "", "", "", "");
std::exit(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -55,7 +54,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();
}

Expand Down
1 change: 0 additions & 1 deletion ddtrace/internal/datadog/profiling/ddup/_ddup.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 0 additions & 4 deletions ddtrace/internal/datadog/profiling/ddup/_ddup.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Loading