Skip to content

Commit e54044e

Browse files
ci(debugging): reduce exploration limits [backport #5600 to 1.12] (#5796)
Backport of #5600 to 1.12 We reduce the capture limits in probe installed during exploration testing to reduce the overhead introduced and allow test runs to complete more quickly. The main objective of the exploration tests is to validate the bytecode manipulations, so this does not affect the usefulness of the test runs. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) are followed. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] PR description includes explicit acknowledgement/acceptance of the performance implications of this PR as reported in the benchmarks PR comment. ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. Co-authored-by: Gabriele N. Tornetta <[email protected]>
1 parent d2dbc18 commit e54044e

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

.github/workflows/test_frameworks.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,24 @@ jobs:
5353
run: PYTHONPATH=../ddtrace/tests/debugging/exploration/ ddtrace-run pytest test --continue-on-collection-errors -v -k 'not test_simple'
5454

5555
django-testsuite-3_1:
56-
timeout-minutes: 30
5756
strategy:
5857
matrix:
59-
expl_profiler: [0, 1]
60-
expl_coverage: [0 ,1]
61-
exclude:
62-
- expl_profiler: 1
63-
expl_coverage: 1
64-
- expl_profiler: 0
58+
include:
59+
- suffix: DI profiler
60+
expl_profiler: 1
6561
expl_coverage: 0
66-
# Temporarily disabling line coverage to investigate cause of hangs
67-
- expl_profiler: 0
62+
- suffix: DI coverage
63+
expl_profiler: 0
6864
expl_coverage: 1
6965
runs-on: ubuntu-20.04
66+
name: Django 3.1 (with ${{ matrix.suffix }})
7067
env:
7168
DD_PROFILING_ENABLED: true
7269
DD_TESTING_RAISE: true
7370
DD_DEBUGGER_EXPL_ENCODE: 0 # Disabled to speed up
7471
DD_DEBUGGER_EXPL_PROFILER_ENABLED: ${{ matrix.expl_profiler }}
7572
DD_DEBUGGER_EXPL_COVERAGE_ENABLED: ${{ matrix.expl_coverage }}
73+
DD_DEBUGGER_EXPL_CONSERVATIVE: 1
7674
PYTHONPATH: ../ddtrace/tests/debugging/exploration/:.
7775
defaults:
7876
run:

tests/debugging/exploration/_config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from envier import En
66

7+
from ddtrace.debugging._probe.model import CaptureLimits
8+
79

810
def parse_venv(value):
911
# type: (str) -> t.Optional[str]
@@ -53,6 +55,23 @@ class ExplorationConfig(En):
5355
help="Whether to include elusive modules in the exploration",
5456
)
5557

58+
conservative = En.v(
59+
bool,
60+
"dd.debugger.expl.conservative",
61+
default=False,
62+
help="Use extremely low capture limits to reduce overhead",
63+
)
64+
65+
limits = En.d(
66+
CaptureLimits,
67+
lambda c: CaptureLimits(
68+
max_level=0 if c.conservative else 1,
69+
max_size=1,
70+
max_len=1 if c.conservative else 8,
71+
max_fields=1,
72+
),
73+
)
74+
5675
class ProfilerConfig(En):
5776
__item__ = "profiler"
5877
__prefix__ = "dd.debugger.expl.profiler"

tests/debugging/exploration/_coverage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from types import ModuleType
55
import typing as t
66

7+
from _config import config as expl_config
78
from debugger import COLS
89
from debugger import CWD
910
from debugger import ExplorationDebugger
@@ -35,6 +36,7 @@ def on_collect(self, discovery):
3536
source_file=origin(sys.modules[f.__module__]),
3637
line=line,
3738
rate=0.0,
39+
limits=expl_config.limits,
3840
)
3941
for line, functions in discovery.items()
4042
for f in functions

tests/debugging/exploration/_profiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from os.path import abspath
22
import typing as t
33

4+
from _config import config as expl_config
45
from debugger import COLS
56
from debugger import ExplorationDebugger
67
from debugger import ModuleCollector
@@ -35,6 +36,7 @@ def on_collect(self, discovery):
3536
module=module.__name__,
3637
func_qname=fname.replace(module.__name__, "").lstrip("."),
3738
rate=float("inf"),
39+
limits=expl_config.limits,
3840
)
3941
)
4042

tests/debugging/exploration/debugger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ def enable(cls):
235235
cls._instance._collector.on_snapshot = cls.on_snapshot
236236

237237
@classmethod
238-
def disable(cls):
239-
# type: () -> None
238+
def disable(cls, join=True):
239+
# type: (bool) -> None
240240
registry = cls._instance._probe_registry
241241

242242
nprobes = len(registry)
@@ -254,7 +254,7 @@ def disable(cls):
254254
if snapshots and snapshots[-1]:
255255
print(snapshots[-1].decode())
256256

257-
super(ExplorationDebugger, cls).disable()
257+
super(ExplorationDebugger, cls).disable(join=join)
258258

259259
@classmethod
260260
def get_snapshots(cls):

0 commit comments

Comments
 (0)