From 5504f149895eacfbfa45a13f302379bd8fc13516 Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Tue, 27 Oct 2026 16:00:21 -0400 Subject: [PATCH 1/2] python: recalibrate python_sample_count wall-samples rate for ddtrace 4.16 --- scenarios/python_sample_count_3.12/README.md | 11 +++++++---- .../python_sample_count_3.12/expected_profile.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scenarios/python_sample_count_3.12/README.md b/scenarios/python_sample_count_3.12/README.md index dbcfc833..7d91b719 100644 --- a/scenarios/python_sample_count_3.12/README.md +++ b/scenarios/python_sample_count_3.12/README.md @@ -15,7 +15,10 @@ All coroutines are gathered in a single `asyncio.run` call. - **Task reservoir**: by default, the profiler samples at most 50 leaf tasks per cycle. This scenario intentionally exercises that default behavior. -- **wall-samples**: the total number of raw stack samples captured over the run is checked - against a reference value (`value-matching-sum` = 4000) with a wide error margin (20%). - Reservoir sampling reduces the prior count by approximately `50 / 500`; host scheduling - noise still makes this a coarse regression check rather than an exact count. +- **wall-samples**: the number of raw stack samples per second of profile + (`scale_by_duration`) is checked against a reference value (`value-matching-sum` = 4500) + with a wide error margin (20%, so 3600 to 5400 per second). + The ceiling is about 5000 per second: 100 sampling cycles per second (10 ms default interval) + times 50 reservoir tasks. Nightly CI measured 3900 to 4800 per second with ddtrace 4.15.x + and 4600 to 4930 with ddtrace 4.16.0. Host scheduling noise still makes this a coarse + regression check rather than an exact count. diff --git a/scenarios/python_sample_count_3.12/expected_profile.json b/scenarios/python_sample_count_3.12/expected_profile.json index 65e09b84..27844a02 100644 --- a/scenarios/python_sample_count_3.12/expected_profile.json +++ b/scenarios/python_sample_count_3.12/expected_profile.json @@ -8,7 +8,7 @@ "regular_expression": ".*" } ], - "value-matching-sum": 4000, + "value-matching-sum": 4500, "error-margin": 20 } ], From b97e1cf57eb8a862ea579fd0ca53143eca0e4816 Mon Sep 17 00:00:00 2001 From: Taegyun Kim Date: Wed, 28 Oct 2026 12:02:11 -0400 Subject: [PATCH 2/2] python: assert the theoretical 5000/s rate in python_sample_count --- scenarios/python_sample_count_3.12/README.md | 12 ++++++------ .../python_sample_count_3.12/expected_profile.json | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scenarios/python_sample_count_3.12/README.md b/scenarios/python_sample_count_3.12/README.md index 7d91b719..3c4dca0b 100644 --- a/scenarios/python_sample_count_3.12/README.md +++ b/scenarios/python_sample_count_3.12/README.md @@ -16,9 +16,9 @@ All coroutines are gathered in a single `asyncio.run` call. - **Task reservoir**: by default, the profiler samples at most 50 leaf tasks per cycle. This scenario intentionally exercises that default behavior. - **wall-samples**: the number of raw stack samples per second of profile - (`scale_by_duration`) is checked against a reference value (`value-matching-sum` = 4500) - with a wide error margin (20%, so 3600 to 5400 per second). - The ceiling is about 5000 per second: 100 sampling cycles per second (10 ms default interval) - times 50 reservoir tasks. Nightly CI measured 3900 to 4800 per second with ddtrace 4.15.x - and 4600 to 4930 with ddtrace 4.16.0. Host scheduling noise still makes this a coarse - regression check rather than an exact count. + (`scale_by_duration`) is checked against the theoretical rate (`value-matching-sum` = 5000): + 100 sampling cycles per second (10 ms default interval) times 50 reservoir tasks. + Real runs land below it, for example when the sampler thread wakes late on a busy host. + The error margin is wide (30%, so 3500 to 6500 per second): CI measured 3667 to 4931 per + second with ddtrace 4.15.x, 4.16.0 and dd-trace-py `main`. This is a coarse check that + catches a sampler running far too often or too rarely. diff --git a/scenarios/python_sample_count_3.12/expected_profile.json b/scenarios/python_sample_count_3.12/expected_profile.json index 27844a02..1ab08985 100644 --- a/scenarios/python_sample_count_3.12/expected_profile.json +++ b/scenarios/python_sample_count_3.12/expected_profile.json @@ -8,8 +8,8 @@ "regular_expression": ".*" } ], - "value-matching-sum": 4500, - "error-margin": 20 + "value-matching-sum": 5000, + "error-margin": 30 } ], "scale_by_duration": true