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

[ASCII-1081] Remove Stop method from demultiplexer interface #22069

Merged
merged 9 commits into from
Jan 26, 2024

Conversation

ogaca-dd
Copy link
Contributor

@ogaca-dd ogaca-dd commented Jan 15, 2024

What does this PR do?

This PR removes the Stop method from the demultiplexer interface in favour of using fx OnStop hook.

This PR must be merged after #22044 to make sure OnStop on the demultiplexer instance is called even when there is an error.

Motivation

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

Run the command (see below), wait 3-4 seconds (should be less than 10s) and stop the command with ctrl+c . Check Stopping aggregator is in the log of the Agent and after you press ctrl+c and there is no panic.

Agent shared component

  • cmd/agent/subcommands/run/command.go
  • pkg/cli/subcommands/check/command.go
  • cmd/dogstatsd/subcommands/start/command.go

Platform integration:

  • cmd/cluster-agent/subcommands/start/command.go
  • cmd/cluster-agent-cloudfoundry/subcommands/run/command.go

Open telemetry:

  • cmd/otel-agent/main.go

Security Agent:

  • cmd/security-agent/subcommands/start/command.go

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • A release note has been added or the changelog/no-changelog label has been applied.
  • Changed code has automated tests for its functionality.
  • Adequate QA/testing plan information is provided. Except if the qa/skip-qa label, with required either qa/done or qa/no-code-change labels, are applied.
  • At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • If applicable, the need-change/operator and need-change/helm labels have been applied.
  • If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • If applicable, the config template has been updated.

@ogaca-dd ogaca-dd added this to the 7.52.0 milestone Jan 15, 2024
@ogaca-dd ogaca-dd changed the title Remove Stop method from demultiplexer interface [ASCII-1081] Remove Stop method from demultiplexer interface Jan 15, 2024
@ogaca-dd ogaca-dd marked this pull request as ready for review January 15, 2024 17:42
@ogaca-dd ogaca-dd requested review from a team as code owners January 15, 2024 17:42
@pr-commenter
Copy link

pr-commenter bot commented Jan 15, 2024

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: 95811340-a4e4-456b-9385-076a2aefc92f
Baseline: 165e0b3
Comparison: f775c5f
Total CPUs: 7

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.

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI
file_to_blackhole % cpu utilization +0.33 [-6.23, +6.88]
idle memory utilization -0.15 [-0.20, -0.11]
file_tree memory utilization -0.76 [-0.88, -0.63]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
otel_to_otel_logs ingress throughput +0.65 [-0.07, +1.37]
uds_dogstatsd_to_api_cpu % cpu utilization +0.58 [-0.88, +2.03]
file_to_blackhole % cpu utilization +0.33 [-6.23, +6.88]
uds_dogstatsd_to_api ingress throughput +0.00 [-0.03, +0.03]
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.06, +0.06]
trace_agent_msgpack ingress throughput -0.02 [-0.04, +0.00]
trace_agent_json ingress throughput -0.03 [-0.06, +0.00]
process_agent_real_time_mode memory utilization -0.07 [-0.11, -0.02]
tcp_syslog_to_blackhole ingress throughput -0.10 [-0.15, -0.04]
idle memory utilization -0.15 [-0.20, -0.11]
process_agent_standard_check_with_stats memory utilization -0.57 [-0.63, -0.52]
process_agent_standard_check memory utilization -0.59 [-0.65, -0.53]
file_tree memory utilization -0.76 [-0.88, -0.63]

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

Copy link
Member

@pgimalac pgimalac left a comment

Choose a reason for hiding this comment

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

LGTM
FYI looks like you missed some windows files

@@ -24,12 +24,6 @@ import (
type Demultiplexer interface {
// General
// --

// Run runs all demultiplexer parts
Run()
Copy link
Member

Choose a reason for hiding this comment

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

Was the Run method used anywhere ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Run is called at https://github.com/DataDog/datadog-agent/blob/7.50.0/pkg/aggregator/demultiplexer_agent.go#L130 and doesn't need to be exported. I have created a commit to not export the function.

Comment on lines +78 to +81
deps.Lc.Append(fx.Hook{OnStop: func(ctx context.Context) error {
agentDemultiplexer.Stop(true)
return nil
}})
Copy link
Member

Choose a reason for hiding this comment

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

Could it change the order in which the components are stopped, similarly to the bug we had a few months ago ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, indeed, that is why I added QA instructions and carefully check it is OK to stop the aggregator later.

`Stop` is always called when using demultiplexer but NewNoopEventPlatformForwarder() set p.strategy to nil which was not check when calling `Stop`
Copy link
Contributor

Serverless Benchmark Results

BenchmarkStartEndInvocation comparison between 81d31a4 and b112f43.

tl;dr
  1. Skim down the vs base column in each chart. If there is a ~, then there was no statistically significant change to the benchmark. Otherwise, ensure the estimated percent change is either negative or very small.

  2. The last row of each chart is the geomean. Ensure this percentage is either negative or very small.

What is this benchmarking?

The BenchmarkStartEndInvocation compares the amount of time it takes to call the start-invocation and end-invocation endpoints. For universal instrumentation languages (Dotnet, Golang, Java, Ruby), this represents the majority of the duration overhead added by our tracing layer.

The benchmark is run using a large variety of lambda request payloads. In the charts below, there is one row for each event payload type.

How do I interpret these charts?

The charts below comes from benchstat. They represent the statistical change in duration (sec/op), memory overhead (B/op), and allocations (allocs/op).

The benchstat docs explain how to interpret these charts.

Before the comparison table, we see common file-level configuration. If there are benchmarks with different configuration (for example, from different packages), benchstat will print separate tables for each configuration.

The table then compares the two input files for each benchmark. It shows the median and 95% confidence interval summaries for each benchmark before and after the change, and an A/B comparison under "vs base". ... The p-value measures how likely it is that any differences were due to random chance (i.e., noise). The "~" means benchstat did not detect a statistically significant difference between the two inputs. ...

Note that "statistically significant" is not the same as "large": with enough low-noise data, even very small changes can be distinguished from noise and considered statistically significant. It is, of course, generally easier to distinguish large changes from noise.

Finally, the last row of the table shows the geometric mean of each column, giving an overall picture of how the benchmarks changed. Proportional changes in the geomean reflect proportional changes in the benchmarks. For example, given n benchmarks, if sec/op for one of them increases by a factor of 2, then the sec/op geomean will increase by a factor of ⁿ√2.

Benchmark stats
goos: linux
goarch: amd64
pkg: github.com/DataDog/datadog-agent/pkg/serverless/daemon
cpu: AMD EPYC 7763 64-Core Processor                
                                      │   previous    │                 current                 │
                                      │    sec/op     │     sec/op      vs base                 │
api-gateway-appsec.json                  92.93µ ±  5%   90.41µ ±  5%          ~ (p=0.143 n=10)
api-gateway-kong-appsec.json             68.20µ ±  7%   67.64µ ±  3%          ~ (p=0.631 n=10)
api-gateway-kong.json                    66.74µ ±  4%   66.36µ ±  4%          ~ (p=0.353 n=10)
api-gateway-non-proxy-async.json         107.8µ ±  3%   105.6µ ±  3%     -2.05% (p=0.043 n=10)
api-gateway-non-proxy.json               106.0µ ±  5%   104.0µ ±  2%     -1.88% (p=0.011 n=10)
api-gateway-websocket-connect.json       74.21µ ±  2%   72.64µ ±  5%          ~ (p=0.063 n=10)
api-gateway-websocket-default.json       64.03µ ±  4%   63.30µ ±  3%          ~ (p=0.579 n=10)
api-gateway-websocket-disconnect.json    64.16µ ±  4%   61.77µ ±  4%     -3.72% (p=0.015 n=10)
api-gateway.json                         128.6µ ±  5%   115.2µ ±  3%    -10.44% (p=0.000 n=10)
application-load-balancer.json           66.07µ ± 10%   60.02µ ±  6%     -9.16% (p=0.023 n=10)
cloudfront.json                          53.91µ ±  8%   48.65µ ±  7%     -9.76% (p=0.000 n=10)
cloudwatch-events.json                   41.58µ ±  9%   39.05µ ±  3%     -6.08% (p=0.029 n=10)
cloudwatch-logs.json                     59.41µ ± 28%   53.60µ ±  4%     -9.79% (p=0.019 n=10)
custom.json                              33.83µ ± 12%   30.25µ ±  4%    -10.59% (p=0.007 n=10)
dynamodb.json                           104.05µ ± 14%   96.33µ ± 13%          ~ (p=0.739 n=10)
empty.json                               36.52µ ± 10%   34.93µ ± 10%          ~ (p=0.393 n=10)
eventbridge-custom.json                  48.56µ ± 11%   47.26µ ± 15%          ~ (p=0.853 n=10)
http-api.json                            83.30µ ± 14%   87.40µ ±  3%          ~ (p=0.165 n=10)
kinesis-batch.json                      101.03µ ± 16%   92.66µ ±  9%          ~ (p=0.063 n=10)
kinesis.json                             77.88µ ± 11%   72.87µ ± 26%          ~ (p=0.247 n=10)
s3.json                                  77.44µ ± 25%   79.28µ ± 28%          ~ (p=0.739 n=10)
sns-batch.json                           124.3µ ± 23%   147.7µ ±   ∞ ¹        ~ (p=0.376 n=8+3)
geomean                                  71.67µ         69.12µ           -3.55%
¹ need >= 6 samples for confidence interval at level 0.95

                                      │   previous    │                current                 │
                                      │     B/op      │      B/op       vs base                │
api-gateway-appsec.json                 41.90Ki ±  3%   42.02Ki ± 3%         ~ (p=0.631 n=10)
api-gateway-kong-appsec.json            27.96Ki ± 10%   29.04Ki ± 8%         ~ (p=0.925 n=10)
api-gateway-kong.json                   25.29Ki ±  0%   25.29Ki ± 0%         ~ (p=0.955 n=10)
api-gateway-non-proxy-async.json        51.35Ki ±  0%   51.41Ki ± 0%    +0.10% (p=0.001 n=10)
api-gateway-non-proxy.json              49.91Ki ±  0%   49.96Ki ± 0%    +0.10% (p=0.001 n=10)
api-gateway-websocket-connect.json      29.12Ki ±  0%   29.15Ki ± 0%    +0.11% (p=0.000 n=10)
api-gateway-websocket-default.json      23.26Ki ±  0%   23.29Ki ± 0%    +0.13% (p=0.000 n=10)
api-gateway-websocket-disconnect.json   22.89Ki ±  0%   22.92Ki ± 0%    +0.14% (p=0.000 n=10)
api-gateway.json                        53.83Ki ±  0%   53.83Ki ± 0%         ~ (p=0.468 n=10)
application-load-balancer.json          22.90Ki ±  0%   23.84Ki ± 0%    +4.09% (p=0.001 n=10)
cloudfront.json                         18.43Ki ±  0%   18.45Ki ± 0%    +0.08% (p=0.001 n=10)
cloudwatch-events.json                  11.46Ki ±  0%   11.49Ki ± 0%    +0.27% (p=0.000 n=10)
cloudwatch-logs.json                    53.28Ki ±  0%   53.28Ki ± 0%         ~ (p=0.537 n=10)
custom.json                             9.217Ki ±  0%   9.232Ki ± 0%    +0.16% (p=0.001 n=10)
dynamodb.json                           43.25Ki ±  0%   43.28Ki ± 0%    +0.07% (p=0.000 n=10)
empty.json                              8.710Ki ±  0%   8.726Ki ± 0%    +0.18% (p=0.000 n=10)
eventbridge-custom.json                 13.18Ki ±  0%   13.21Ki ± 0%    +0.23% (p=0.001 n=10)
http-api.json                           24.10Ki ±  0%   24.16Ki ± 0%    +0.27% (p=0.000 n=10)
kinesis-batch.json                      28.41Ki ±  0%   28.44Ki ± 0%    +0.11% (p=0.000 n=10)
kinesis.json                            18.14Ki ±  0%   18.17Ki ± 0%    +0.17% (p=0.000 n=10)
s3.json                                 20.86Ki ±  0%   20.89Ki ± 0%    +0.16% (p=0.001 n=10)
sns-batch.json                          41.56Ki ±  0%   41.55Ki ±  ∞ ¹       ~ (p=0.642 n=8+3)
geomean                                 25.40Ki         25.52Ki         +0.47%
¹ need >= 6 samples for confidence interval at level 0.95

                                      │  previous  │                current                 │
                                      │ allocs/op  │  allocs/op    vs base                  │
api-gateway-appsec.json                 630.0 ± 0%   630.0 ± 0%         ~ (p=1.000 n=10)  ¹
api-gateway-kong-appsec.json            487.0 ± 0%   487.0 ± 0%         ~ (p=1.000 n=10)  ¹
api-gateway-kong.json                   465.0 ± 0%   465.0 ± 0%         ~ (p=1.000 n=10)  ¹
api-gateway-non-proxy-async.json        722.5 ± 0%   722.0 ± 0%         ~ (p=0.650 n=10)
api-gateway-non-proxy.json              712.0 ± 0%   712.0 ± 0%         ~ (p=1.000 n=10)
api-gateway-websocket-connect.json      452.0 ± 0%   452.0 ± 0%         ~ (p=1.000 n=10)  ¹
api-gateway-websocket-default.json      377.0 ± 0%   377.0 ± 0%         ~ (p=1.000 n=10)  ¹
api-gateway-websocket-disconnect.json   367.0 ± 0%   367.0 ± 0%         ~ (p=1.000 n=10)  ¹
api-gateway.json                        786.0 ± 0%   786.0 ± 0%         ~ (p=1.000 n=10)  ¹
application-load-balancer.json          348.0 ± 0%   349.0 ± 0%    +0.29% (p=0.000 n=10)
cloudfront.json                         280.0 ± 0%   280.0 ± 0%         ~ (p=1.000 n=10)  ¹
cloudwatch-events.json                  217.0 ± 0%   217.0 ± 0%         ~ (p=1.000 n=10)  ¹
cloudwatch-logs.json                    211.0 ± 0%   211.0 ± 0%         ~ (p=1.000 n=10)  ¹
custom.json                             165.0 ± 0%   165.0 ± 0%         ~ (p=1.000 n=10)  ¹
dynamodb.json                           584.0 ± 0%   584.0 ± 0%         ~ (p=1.000 n=10)  ¹
empty.json                              156.0 ± 0%   156.0 ± 0%         ~ (p=1.000 n=10)  ¹
eventbridge-custom.json                 249.0 ± 0%   249.0 ± 0%         ~ (p=1.000 n=10)  ¹
http-api.json                           424.0 ± 0%   424.0 ± 0%         ~ (p=0.582 n=10)
kinesis-batch.json                      384.0 ± 0%   384.0 ± 0%         ~ (p=1.000 n=10)  ¹
kinesis.json                            279.0 ± 0%   279.0 ± 0%         ~ (p=1.000 n=10)
s3.json                                 350.0 ± 0%   350.0 ± 0%         ~ (p=1.000 n=10)  ¹
sns-batch.json                          443.0 ± 0%   443.0 ±  ∞ ²       ~ (p=0.982 n=8+3)
geomean                                 375.0        375.0         +0.01%
¹ all samples are equal
² need >= 6 samples for confidence interval at level 0.95

pkg/epforwarder/epforwarder.go Show resolved Hide resolved
@ogaca-dd
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jan 24, 2024

🚂 MergeQueue

Pull request added to the queue.

This build is next! (estimated merge in less than 47m)

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented Jan 24, 2024

❌ MergeQueue

Tests failed on this commit f336052

You should fix those tests and then re-add your pull request to the queue!

Details

checks are failing:

  • appsec on arm64
  • trace on arm64

If you need support, contact us on Slack #ci-interfaces with those details!

@ogaca-dd
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jan 26, 2024

🚂 MergeQueue

Pull request added to the queue.

This build is going to start soon! (estimated merge in less than 47m)

Use /merge -c to cancel this operation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants