Skip to content
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

Allow checks to cache their senders to reduce blocking operations #25858

Closed
wants to merge 1 commit into from

Conversation

gh123man
Copy link
Member

@gh123man gh123man commented May 23, 2024

What does this PR do?

Allow checks to cache their senders.

GetSender and flushToSerializer both hold the same lock. So if a flush takes a very long time, it could prevent checks from starting since today checks will always call GetSender when they start. This PR allows checks to re-use their sender so they don't have acquire the senders more than once in the lifetime.

Additional context

This PR is one part of a solution to a bigger problem: Some checks that send an extremely high volume of metrics can cause other checks to block due to very long flushes. The flush mechanism several parts, but I am most interested in the aggregator check sampler flush. As a whole, these operations are blocking and prevent checks from starting until a flush finishes but with this change, we can scope the blocking behavior down to just the check sampler instead of "everything".

This PR removes the need for checks to block on the demultiplexer. On top of this, all of the interactions between the sender and check sampler are buffered - so we can tune them with various existing agent settings reducing the impact of blocking on the check sampler's channel operations

Motivation

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

This has already been deployed to a large cluster so testing should be done.
Manual steps: ensure checks still work correctly (lifecycle, and metrics)

@gh123man gh123man added this to the 7.55.0 milestone May 23, 2024
@gh123man gh123man changed the title cache check senders Cache check senders May 23, 2024
Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 44.00000% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 53.92%. Comparing base (9ae1d8b) to head (c908a38).
Report is 167 commits behind head on main.

Files Patch % Lines
pkg/collector/python/check.go 43.75% 8 Missing and 1 partial ⚠️
pkg/collector/corechecks/checkbase.go 44.44% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #25858       +/-   ##
===========================================
+ Coverage   45.03%   53.92%    +8.89%     
===========================================
  Files        2314      580     -1734     
  Lines      266564    51082   -215482     
===========================================
- Hits       120038    27547    -92491     
+ Misses     136977    22054   -114923     
+ Partials     9549     1481     -8068     
Flag Coverage Δ
amzn_aarch64 55.12% <44.00%> (+9.30%) ⬆️
centos_x86_64 54.95% <44.00%> (+9.23%) ⬆️
ubuntu_aarch64 55.13% <44.00%> (+9.31%) ⬆️
ubuntu_x86_64 55.11% <44.00%> (+9.29%) ⬆️
windows_amd64 53.93% <44.00%> (+2.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pr-commenter
Copy link

pr-commenter bot commented May 23, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=34935651 --os-family=ubuntu

@pr-commenter
Copy link

pr-commenter bot commented May 23, 2024

Regression Detector

Regression Detector Results

Run ID: d35bebed-4f39-473a-a22d-9e5646dfd8d5
Baseline: 9ae1d8b
Comparison: c908a38

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

No significant changes in experiment optimization goals

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
basic_py_check % cpu utilization +1.14 [-1.39, +3.68]
file_tree memory utilization +0.41 [+0.32, +0.50]
idle memory utilization +0.40 [+0.37, +0.44]
tcp_dd_logs_filter_exclude ingress throughput +0.01 [-0.01, +0.03]
trace_agent_msgpack ingress throughput +0.00 [-0.00, +0.00]
trace_agent_json ingress throughput +0.00 [-0.01, +0.01]
uds_dogstatsd_to_api ingress throughput -0.00 [-0.20, +0.20]
otel_to_otel_logs ingress throughput -0.02 [-0.37, +0.33]
pycheck_1000_100byte_tags % cpu utilization -1.53 [-6.28, +3.22]
uds_dogstatsd_to_api_cpu % cpu utilization -1.80 [-4.64, +1.05]
tcp_syslog_to_blackhole ingress throughput -9.59 [-29.56, +10.38]

Explanation

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:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. 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.

  3. Its configuration does not mark it "erratic".

@gh123man gh123man added the qa/done QA done before merge and regressions are covered by tests label May 28, 2024
@gh123man gh123man changed the title Cache check senders Allow checks to cache their senders to reduce blocking operations May 28, 2024
@gh123man gh123man marked this pull request as ready for review May 28, 2024 19:16
@gh123man gh123man requested review from a team as code owners May 28, 2024 19:16
Copy link
Member

@amenasria amenasria left a comment

Choose a reason for hiding this comment

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

LGTM for Agent CI Exp owned files !

Copy link
Contributor

@kkhor-datadog kkhor-datadog left a comment

Choose a reason for hiding this comment

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

Looks good for Processes files - pkg/collector/corechecks/embed/process/process_agent.go

Copy link
Contributor

@dplepage-dd dplepage-dd left a comment

Choose a reason for hiding this comment

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

LGTM for NDM files (snmp_test.go)

@gh123man
Copy link
Member Author

gh123man commented May 29, 2024

Sadly this didn't work as expected (doesn't cover python checks) so have to build out a different solution.

@gh123man gh123man closed this May 29, 2024
@dd-devflow dd-devflow bot deleted the brian/cache-check-senders branch November 23, 2024 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog qa/done QA done before merge and regressions are covered by tests team/agent-metrics-logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants