-
Notifications
You must be signed in to change notification settings - Fork 8
chore(ddsketch, dogstatsd): allow for higher sample rates in DSD payloads #1087
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Binary Size Analysis (Agent Data Plane)Target: 53531a0 (baseline) vs 560f391 (comparison) diff
|
| Module | File Size | Symbols |
|---|---|---|
| [debug sections] | -289.37 KiB | 7 |
| prost | -18.01 KiB | 168 |
| rustls | +17.15 KiB | 11 |
| tokio_rustls | -16.13 KiB | 6 |
| figment | -12.61 KiB | 39 |
| otlp_protos::otlp_include::opentelemetry | +11.44 KiB | 116 |
| h2 | -8.06 KiB | 73 |
| saluki_components::transforms::aggregate | +8.03 KiB | 8 |
| hyper_util | +5.78 KiB | 20 |
| [Unmapped] | -5.12 KiB | 1 |
| tokio_util | +4.94 KiB | 12 |
| anon.031a1f69be40723c9e961e9fc98b02a9.0.llvm.576639265174890831 | +4.92 KiB | 1 |
| anon.8a24369cc75f65645c1607e1d511e84c.369.llvm.8512966183790337429 | -4.92 KiB | 1 |
| futures_util | -4.03 KiB | 24 |
| saluki_components::transforms::host_tags | +3.82 KiB | 1 |
| saluki_components::sources::dogstatsd | -3.73 KiB | 19 |
| saluki_components::common::datadog | +3.29 KiB | 22 |
| core | +3.10 KiB | 1563 |
| serde | +2.94 KiB | 26 |
| quick_cache | -2.93 KiB | 21 |
Detailed Symbol Changes
FILE SIZE VM SIZE
-------------- --------------
+0.1% +137Ki [ = ] 0 [section .debug_loc]
[NEW] +12.2Ki [NEW] +12.1Ki saluki_components::sources::otlp::logs::transform::transform_log_record::h663796474e3b4bce
[NEW] +9.05Ki [NEW] +8.83Ki _<saluki_components::sources::dogstatsd::DogStatsDConfiguration as saluki_core::components::sources::builder::SourceBuilder>::build::_{{closure}}::h494a110866a2997d
[NEW] +8.13Ki [NEW] +7.89Ki saluki_components::transforms::aggregate::config::_::_<impl serde_core::de::Deserialize for saluki_components::transforms::aggregate::config::HistogramConfiguration>::deserialize::haa284aece90cfde3
[NEW] +7.91Ki [NEW] +7.80Ki rustls::conn::ConnectionCore<Data>::process_new_packets::he334f777dd629005
[NEW] +7.80Ki [NEW] +7.69Ki rustls::conn::ConnectionCore<Data>::process_new_packets::h79dbc8cff7cd06be
[NEW] +5.57Ki [NEW] +5.41Ki _<serde::private::de::FlatMapDeserializer<E> as serde_core::de::Deserializer>::deserialize_struct::hd2e74a7bf9e626b0
[NEW] +5.31Ki [NEW] +5.14Ki _<serde::private::de::FlatMapDeserializer<E> as serde_core::de::Deserializer>::deserialize_struct::hb1e73cc751944c6e
[NEW] +4.92Ki [NEW] +81 anon.031a1f69be40723c9e961e9fc98b02a9.0.llvm.576639265174890831
[DEL] -4.87Ki [DEL] -4.70Ki _<serde::private::de::FlatMapDeserializer<E> as serde_core::de::Deserializer>::deserialize_struct::hc2393939d6a764b8
[DEL] -4.92Ki [DEL] -81 anon.8a24369cc75f65645c1607e1d511e84c.369.llvm.8512966183790337429
-64.8% -5.12Ki [ = ] 0 [Unmapped]
-87.6% -7.99Ki -88.6% -7.99Ki tokio_rustls::common::Stream<IO,C>::read_io::hff84ac4f60c968ea
-88.2% -8.44Ki -89.1% -8.44Ki tokio_rustls::common::Stream<IO,C>::read_io::hb24087c6c4f8882c
[DEL] -8.80Ki [DEL] -8.58Ki _<saluki_components::sources::dogstatsd::DogStatsDConfiguration as saluki_core::components::sources::builder::SourceBuilder>::build::_{{closure}}::h19f3155b19bb0e2b
-56.7% -10.5Ki -57.0% -10.5Ki figment::figment::Figment::extract::hef8645c13a353b1a
-85.1% -11.6Ki -86.2% -11.6Ki _<saluki_components::sources::otlp::logs::translator::OtlpLogsTranslator as core::iter::traits::iterator::Iterator>::next::hf976c0d95e31e00a
-0.0% -21.3Ki [ = ] 0 [section .debug_str]
-0.1% -25.7Ki -0.4% -22.0Ki [7716 Others]
-0.1% -27.6Ki [ = ] 0 [section .debug_line]
-0.3% -373Ki [ = ] 0 [section .debug_info]
-0.1% -311Ki -0.1% -18.9Ki TOTAL
Regression Detector (Agent Data Plane)Regression Detector ResultsRun ID: 6c8c59c5-d13f-4304-9b60-dbc43da53b75 Baseline: 53531a0 ❌ Experiments with retried target crashesThis is a critical error. One or more replicates failed with a non-zero exit code. These replicates may have been retried. See Replicate Execution Details for more information.
Optimization Goals: ❌ Regression(s) detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ❌ | otlp_ingest_metrics_adp | memory utilization | +6.22 | [+6.00, +6.44] | 1 | |
| ➖ | dsd_uds_500mb_3k_contexts_throughput | ingress throughput | +2.07 | [+1.93, +2.21] | 1 | (metrics) (profiles) (logs) |
| ➖ | otlp_ingest_logs_adp | memory utilization | +0.88 | [+0.42, +1.33] | 1 | (metrics) (profiles) (logs) |
| ➖ | quality_gates_rss_idle | memory utilization | +0.21 | [+0.18, +0.24] | 1 | (metrics) (profiles) (logs) |
| ➖ | quality_gates_rss_dsd_ultraheavy | ingress throughput | +0.00 | [-0.06, +0.07] | 1 | (metrics) (profiles) (logs) |
| ➖ | dsd_uds_1mb_3k_contexts_throughput | ingress throughput | +0.00 | [-0.06, +0.06] | 1 | (metrics) (profiles) (logs) |
| ➖ | dsd_uds_512kb_3k_contexts_throughput | ingress throughput | -0.00 | [-0.06, +0.05] | 1 | (metrics) (profiles) (logs) |
| ➖ | dsd_uds_100mb_3k_contexts_throughput | ingress throughput | -0.01 | [-0.05, +0.04] | 1 | (metrics) (profiles) (logs) |
| ➖ | dsd_uds_10mb_3k_contexts_throughput | ingress throughput | -0.02 | [-0.17, +0.13] | 1 | (metrics) (profiles) (logs) |
| ➖ | quality_gates_rss_dsd_medium | memory utilization | -0.08 | [-0.26, +0.10] | 1 | (metrics) (profiles) (logs) |
| ➖ | quality_gates_rss_dsd_low | memory utilization | -0.13 | [-0.27, +0.01] | 1 | (metrics) (profiles) (logs) |
| ➖ | quality_gates_rss_dsd_heavy | memory utilization | -0.21 | [-0.34, -0.08] | 1 | (metrics) (profiles) (logs) |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | links |
|---|---|---|---|---|
| ✅ | quality_gates_rss_dsd_heavy | memory_usage | 10/10 | (metrics) (profiles) (logs) |
| ✅ | quality_gates_rss_dsd_low | memory_usage | 10/10 | (metrics) (profiles) (logs) |
| ✅ | quality_gates_rss_dsd_medium | memory_usage | 10/10 | (metrics) (profiles) (logs) |
| ✅ | quality_gates_rss_dsd_ultraheavy | memory_usage | 10/10 | (metrics) (profiles) (logs) |
| ✅ | quality_gates_rss_idle | memory_usage | 10/10 | (metrics) (profiles) (logs) |
Explanation
Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%
Performance changes are noted in the perf column of each table:
- ✅ = significantly better comparison variant performance
- ❌ = significantly worse comparison variant performance
- ➖ = no significant change in performance
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
Replicate Execution Details
We run multiple replicates for each experiment/variant. However, we allow replicates to be automatically retried if there are any failures, up to 8 times, at which point the replicate is marked dead and we are unable to run analysis for the entire experiment. We call each of these attempts at running replicates a replicate execution. This section lists all replicate executions that failed due to the target crashing or being oom killed.
Note: In the below tables we bucket failures by experiment, variant, and failure type. For each of these buckets we list out the replicate indexes that failed with an annotation signifying how many times said replicate failed with the given failure mode. In the below example the baseline variant of the experiment named experiment_with_failures had two replicates that failed by oom kills. Replicate 0, which failed 8 executions, and replicate 1 which failed 6 executions, all with the same failure mode.
| Experiment | Variant | Replicates | Failure | Logs | Debug Dashboard |
|---|---|---|---|---|---|
| experiment_with_failures | baseline | 0 (x8) 1 (x6) | Oom killed | Debug Dashboard |
The debug dashboard links will take you to a debugging dashboard specifically designed to investigate replicate execution failures.
❌ Retried Normal Replicate Execution Failures (non-profiling)
| Experiment | Variant | Replicates | Failure | Debug Dashboard |
|---|---|---|---|---|
| otlp_ingest_metrics_adp | comparison | 6 | Failed to shutdown when requested | Debug Dashboard |
| quality_gates_rss_dsd_medium | baseline | 2 | Failed to shutdown when requested | Debug Dashboard |
| quality_gates_rss_dsd_ultraheavy | baseline | 3 | Failed to shutdown when requested | Debug Dashboard |
| quality_gates_rss_dsd_ultraheavy | comparison | 0, 3 | Failed to shutdown when requested | Debug Dashboard |
rayz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM

Summary
This PR fixes some suboptimal behavior with the clamped sample rate support added to the DogStatsD codec by changing the count field in
DDSketchto beu64, and updating the default minimum sample rate, as well as allowing it to be configured.In #1024, we made a change to enforce a "minimum" sample rate in DogStatsD payloads. The thinking went: when payloads send very high (small numbers) sample rates, this can lead to us trying to add a number of samples to a
DDSketchthat overflows thecountfield which tracks the total number of samples in the sketch. Very high sample rates should be rare: rare in terms of intentional usage, and more often than not related to some sort of bug, or worse, an attempted denial-of-service/resource exhaustion attack on the Agent. We felt the trade-off made sense, and diligently picked a value to try and ensure that a DogStatsD payload with default settings couldn't trigger this overflow behavior.As you might surmise, we discovered that this limit is too conservative in practice.
This PR takes a multi-faceted approach to resolving the issue: updating the default minimum sample rate and increasing the size of the
countfield (the one we wanted to protect from overflow) inDDSketch.Updating the default minimum sample rate
The value we chose was, essentially, based on what a single packet could reasonably do: if you sent a multi-value payload, where we apply the sample rate to each value in the payload, and based on the maximum allowed DSD payload size by default, and so on and so forth... you arrive at a sample rate of
0.000001, or around 1 million samples. This helps prevent overflow panics on receive, although it doesn't stop potential overflow panics when fully maxed-out sketches are merged. Anyways...In practice, the true limit is more related to the maximum number of bins allowed: if we can only ever have N bins in a sketch, and each bin can represent a maximum count of Y, then our upper bound for samples-per-sketch should be
X * Y. Given the default maximum bin count of 4096, and maximum of 65,536 samples per bin... we arrive at 268,435,456, which we trim to 260,000,000 just to be safe.. and that gives us our new default minimum sample rate of0.000000003845.We've additionally exposed the ability to change this in the DogStatsD source itself: the default value there matches the default in the codec, but it's useful to be able to potentially ratchet down for internal testing to see where a safer limit might be.
Updating the
countfield inDDSketchto beu64Increasing the sample rate doesn't help us avoid overflow if the
countfield is stillu32, so we've bumped this tou64. "Why is this safe, though? Why was itu32in the first place?" you may ask.That's a good question and in the Agent codebase, the
countfield is anint64, which is consistent with the corresponding field type in the Protocol Buffers representation for sketches. I still don't really fully know why I originally usedu32, but my best guess is that it allowed us to transparently convert tof64, without any loss of precision, when doing internal operations that worked with the count asf64.In practice, given the bin limit and max count per bin, we need something bigger than
u32and there's just no way around that. We shouldn't hit any issues withf64conversion loss until our counts are greater than 2^53, which is much higher than ~260M... at which point we'd have bigger issues because we would have been losing bins during post-insert trimming anyways.Similarly, even though we're eventually converting from
u64toi64, we'd have to have counts over 2^63 for the conversion to be clamped/invalid... and we've already lost data well before that.Change Type
How did you test this PR?
Existing unit and correctness tests.
References
AGTMETRICS-393