DataDog / dd-trace-py

Datadog Python APM Client
https://ddtrace.readthedocs.io/
Other
553 stars 416 forks source link

fix(profiler): initialize memory collector until after libdatadog #11438

Closed sanchda closed 5 days ago

sanchda commented 1 week ago

The current implementation of this system has a pretty negligent state initialization sequence.

In particular, the memory allocation profiler relies on libdatadog in some circumstances, and should be initialized after it.

Checklist

Reviewer Checklist

github-actions[bot] commented 1 week ago

CODEOWNERS have been resolved as:

ddtrace/releasenotes/notes/fix-profiler-memalloc-init-f097d604fb2af519.yaml  @DataDog/apm-python
ddtrace/profiling/profiler.py                                           @DataDog/profiling-python
pr-commenter[bot] commented 1 week ago

Benchmarks

Benchmark execution time: 2024-11-18 17:59:57

Comparing candidate commit 7ac81aa13181dd861dd5f06b4ba16d9a88c463fe in PR branch sanchda/fix_memalloc_init with baseline commit 343ba22bbe4010edb9206950fca5dc21c35d3d58 in branch main.

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

scenario:iast_aspects-ospathnormcase_aspect

scenario:iast_aspects-replace_aspect

scenario:iast_aspects-split_aspect

juanjux commented 6 days ago

Only semi-related, you can mostly ignore this: When reading Collector I thought this was an implementation of some unused/free memory collector, not a class to get memory data, maybe MemorySampler or something similar would be a better name?