datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[ASCII-1218] Only initialize needed configs for serverless

Open pgimalac opened this issue 1 year ago • 1 comments

What does this PR do?

Uses build tags to avoid initializing all config values when building for serverless.

Motivation

Init duration is important for serverless, the setup package takes from 10 to 20ms to perform its init, performing around 24000 allocations. Removing most of the configs (which aren't used for Serverless) drops it down to around 2.5ms and 8000 allocations (and even that is still way more than actually needed).

You can run the lambda extension with GODEBUG=inittrace=1 to check how long it takes (look at the clock duration). Before (we've seen durations between 10 and 20ms for that single package):

init github.com/DataDog/datadog-agent/pkg/config/setup @232 ms, 10 ms clock, 2242160 bytes, 23883 allocs

After:

init github.com/DataDog/datadog-agent/pkg/config/setup @230 ms, 2.6 ms clock, 803552 bytes, 8175 allocs

Additional Notes

Review commit by commit if you want to make sure no config was removed or added in the process.

I considered that if any config from a "group" was reachable by the serverless agent then all configs of that group should be declared. Future work will refine this to remove some groups entirely from the serverless agent config setup.

I assumed people add new config options next to other ones they are related to, and so moving all related configs in a separate config ensures new related configs will be added in the proper place. All configs are still declared in the setup/config.go file, so you don't have to look at different files.

I enforced the number of serverless config components so that we can explicitly avoid adding entire new config group by accident. Adding a single config in eg. dogstatsd is fine and shouldn't be prevented, but adding an entire group on the in the serverless agent needs to be inspected and validated properly.

Possible Drawbacks / Trade-offs

We now don't declare all configs for all agents, so we can use a config that should be declared but isn't. It could be interesting to warn when using an unknown config ?

Describe how to test/QA your changes

Check that the serverless agent still works and isn't using any unset config.

pgimalac avatar Feb 20 '24 16:02 pgimalac

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: b4dda9eb-4689-4aea-9a4a-3ca2239a3254 Baseline: 5d2a79a61d2da5a71197cdf9e696b9b42117e874 Comparison: a3fcc619f3d088757bc0f88cd5d680dc9a302406 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

Experiments with missing or malformed data

  • basic_py_check

Usually, this warning means that there is no usable optimization goal data for that experiment, which could be a result of misconfiguration.

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 -1.73 [-8.21, +4.75]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
process_agent_standard_check_with_stats memory utilization +0.77 [+0.74, +0.81]
file_tree memory utilization +0.75 [+0.65, +0.85]
process_agent_standard_check memory utilization +0.48 [+0.42, +0.53]
idle memory utilization +0.45 [+0.40, +0.49]
process_agent_real_time_mode memory utilization +0.15 [+0.12, +0.18]
trace_agent_msgpack ingress throughput +0.02 [+0.01, +0.02]
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.00, +0.00]
uds_dogstatsd_to_api ingress throughput +0.00 [-0.00, +0.00]
trace_agent_json ingress throughput -0.00 [-0.04, +0.03]
uds_dogstatsd_to_api_cpu % cpu utilization -0.21 [-1.63, +1.21]
otel_to_otel_logs ingress throughput -0.32 [-0.95, +0.30]
tcp_syslog_to_blackhole ingress throughput -0.51 [-0.56, -0.45]
file_to_blackhole % cpu utilization -1.73 [-8.21, +4.75]

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

pr-commenter[bot] avatar Feb 20 '24 17:02 pr-commenter[bot]

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=33755517 --os-family=ubuntu

pr-commenter[bot] avatar Apr 25 '24 16:04 pr-commenter[bot]

Regression Detector

Regression Detector Results

Run ID: 4bbf3c4b-e892-46ab-8266-905a0b57ef10 Baseline: ead8e6b28195d9404ab3e8d4c8dc192d8a8d5d53 Comparison: d2fac515e80e4e2ae43f12089bd8755b07fbb553

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 -40.85 [-45.59, -36.12]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
tcp_syslog_to_blackhole ingress throughput +3.44 [-18.01, +24.88]
uds_dogstatsd_to_api_cpu % cpu utilization +1.15 [-1.71, +4.02]
basic_py_check % cpu utilization +0.33 [-2.20, +2.86]
process_agent_standard_check_with_stats memory utilization +0.21 [+0.16, +0.27]
idle memory utilization +0.11 [+0.08, +0.15]
tcp_dd_logs_filter_exclude ingress throughput +0.02 [-0.03, +0.06]
uds_dogstatsd_to_api ingress throughput +0.00 [-0.20, +0.20]
trace_agent_json ingress throughput -0.00 [-0.01, +0.01]
trace_agent_msgpack ingress throughput -0.00 [-0.00, +0.00]
process_agent_standard_check memory utilization -0.01 [-0.07, +0.05]
process_agent_real_time_mode memory utilization -0.02 [-0.06, +0.01]
otel_to_otel_logs ingress throughput -0.17 [-0.57, +0.22]
file_tree memory utilization -0.80 [-0.90, -0.71]
pycheck_1000_100byte_tags % cpu utilization -1.10 [-5.86, +3.66]
file_to_blackhole % cpu utilization -40.85 [-45.59, -36.12]

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

pr-commenter[bot] avatar Apr 29 '24 17:04 pr-commenter[bot]

/merge

pgimalac avatar May 07 '24 12:05 pgimalac

:steam_locomotive: MergeQueue

Pull request added to the queue.

There are 2 builds ahead! (estimated merge in less than 1h)

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar May 07 '24 12:05 dd-devflow[bot]

:x: MergeQueue

This PR is rejected because it was updated

If you need support, contact us on Slack #devflow with those details!

dd-devflow[bot] avatar May 07 '24 12:05 dd-devflow[bot]

/merge

pgimalac avatar May 10 '24 08:05 pgimalac

:steam_locomotive: MergeQueue

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals. Note: if you pushed new commits since the last approval, you may need additional approval. You can remove it from the waiting list with /remove command.

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar May 10 '24 08:05 dd-devflow[bot]

:steam_locomotive: MergeQueue

Pull request added to the queue.

There are 2 builds ahead! (estimated merge in less than 1h)

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar May 10 '24 08:05 dd-devflow[bot]