Skip to content

chore(profiling): add recursive test to benchmarking suite #13628

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

Merged
merged 17 commits into from
Jun 10, 2025

Conversation

alyshawang
Copy link
Contributor

@alyshawang alyshawang commented Jun 9, 2025

New benchmarking scenario to measure the performance impact of different DD_PROFILING_STACK_V2_MAX_FRAMES values on applications with deep call stacks.

For context, DD_PROFILING_STACK_V2_MAX_FRAMES controls the maximum number of stack frames captured and sampled by the profiler. We want to test the performance overhead of different stack frame upper limits (by running a recursive function to create the stack frames) and we are planning to increase this limit from 64 to 512 frames to provide users with more complete stack traces.

The configurable parameters are

  • max_depth: controls recursion depth (stack frame count)
  • enable_sleep/sleep_duration: mixed CPU/idle workload patterns
  • profiler_enabled: enable profiler for frame limit testing

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@alyshawang alyshawang requested a review from a team as a code owner June 9, 2025 20:03
@alyshawang alyshawang requested a review from brettlangdon June 9, 2025 20:03
Copy link
Contributor

github-actions bot commented Jun 9, 2025

CODEOWNERS have been resolved as:

benchmarks/recursive_computation/config.yaml                            @DataDog/apm-core-python
benchmarks/recursive_computation/scenario.py                            @DataDog/apm-core-python
.gitlab/benchmarks/microbenchmarks.yml                                  @DataDog/python-guild @DataDog/apm-core-python

@taegyunkim taegyunkim added the changelog/no-changelog A changelog entry is not required for this PR. label Jun 9, 2025
Copy link
Contributor

@taegyunkim taegyunkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind adding a PR description or README on what this benchmark does?

Copy link
Contributor

github-actions bot commented Jun 9, 2025

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 272 ± 2 ms.

The average import time from base is: 273 ± 2 ms.

The import time difference between this PR and base is: -1.36 ± 0.09 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 1.945 ms (0.72%)
ddtrace.bootstrap.sitecustomize 1.274 ms (0.47%)
ddtrace.bootstrap.preload 1.274 ms (0.47%)
ddtrace.internal.remoteconfig.client 0.631 ms (0.23%)
ddtrace 0.671 ms (0.25%)
ddtrace.internal._unpatched 0.021 ms (0.01%)

@pr-commenter
Copy link

pr-commenter bot commented Jun 9, 2025

Benchmarks

Benchmark execution time: 2025-06-10 21:26:33

Comparing candidate commit a6b4e5c in PR branch alysha.wang/add_recursive_benchmarking with baseline commit e7c0d74 in branch main.

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

scenario:iastaspects-format_map_aspect

  • 🟥 execution_time [+439.570ns; +523.888ns] or [+13.713%; +16.344%]

scenario:iastaspectsospath-ospathsplit_aspect

  • 🟥 execution_time [+713.949ns; +865.727ns] or [+14.786%; +17.929%]

Copy link
Contributor

@taegyunkim taegyunkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-py/-/jobs/974592671

   |
71 |                 }
72 |             )
73 |             import ddtrace.profiling.auto
   |                    ^^^^^^^^^^^^^^^^^^^^^^ F401
74 |
75 |         utils.drop_traces(tracer)
   |
   = help: Remove unused import: `ddtrace.profiling.auto`

@alyshawang alyshawang requested a review from a team as a code owner June 10, 2025 17:02
@taegyunkim
Copy link
Contributor

taegyunkim commented Jun 10, 2025

benchmarks/recursive_computation/scenario.py:2:8: F401 `os` imported but unused
  |
1 | import math
2 | import os
  |        ^^ F401
3 | import time
4 | from typing import Callable
  |
  = help: Remove unused import: `os`

you can run hatch run lint:fmt and hatch run lint:typing before git commit ... to address these issues.

@taegyunkim
Copy link
Contributor

taegyunkim commented Jun 10, 2025

Looks like it's taking a long time to run on the Gitlab, let's try to figure out why and tweak it to be run < 10 minutes. We'd need to remove a few variants from the config file.

@taegyunkim taegyunkim self-requested a review June 10, 2025 19:30
@taegyunkim taegyunkim merged commit df7393f into main Jun 10, 2025
751 checks passed
@taegyunkim taegyunkim deleted the alysha.wang/add_recursive_benchmarking branch June 10, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants