Skip to content

[ASCII-1218] Only initialize needed configs for serverless#23006

Merged
dd-mergequeue[bot] merged 27 commits into
mainfrom
pgimalac/serverless-trim-config
May 10, 2024
Merged

[ASCII-1218] Only initialize needed configs for serverless#23006
dd-mergequeue[bot] merged 27 commits into
mainfrom
pgimalac/serverless-trim-config

Conversation

@pgimalac

@pgimalac pgimalac commented Feb 20, 2024

Copy link
Copy Markdown
Member

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 pgimalac added this to the 7.53.0 milestone Feb 20, 2024
@pr-commenter

pr-commenter Bot commented Feb 20, 2024

Copy link
Copy Markdown

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: b4dda9eb-4689-4aea-9a4a-3ca2239a3254
Baseline: 5d2a79a
Comparison: a3fcc61
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".

@pgimalac
pgimalac force-pushed the pgimalac/serverless-trim-config branch from ce234f6 to b75de07 Compare February 22, 2024 14:56
@pgimalac
pgimalac requested a review from a team February 22, 2024 15:18
@pgimalac
pgimalac force-pushed the pgimalac/serverless-trim-config branch from b75de07 to 8ce8e2f Compare February 22, 2024 16:08
@pgimalac
pgimalac marked this pull request as ready for review February 23, 2024 09:08
@pgimalac
pgimalac requested a review from a team as a code owner February 23, 2024 09:08
@pgimalac pgimalac changed the title Only initialize needed configs for serverless [ASCII-1218] Only initialize needed configs for serverless Feb 23, 2024
@pgimalac
pgimalac force-pushed the pgimalac/serverless-trim-config branch from 8ce8e2f to a3fcc61 Compare February 23, 2024 10:53
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config_test.go

@GustavoCaso GustavoCaso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Amazing work 😄

Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go
Comment thread pkg/config/setup/config.go Outdated
@pgimalac
pgimalac force-pushed the pgimalac/serverless-trim-config branch from 05a5cfc to 8b95277 Compare April 29, 2024 15:23
@pr-commenter

pr-commenter Bot commented Apr 29, 2024

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Run ID: 4bbf3c4b-e892-46ab-8266-905a0b57ef10
Baseline: ead8e6b
Comparison: d2fac51

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

@pgimalac

pgimalac commented May 7, 2024

Copy link
Copy Markdown
Member Author

/merge

@dd-devflow

dd-devflow Bot commented May 7, 2024

Copy link
Copy Markdown

🚂 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

dd-devflow Bot commented May 7, 2024

Copy link
Copy Markdown

❌ MergeQueue

This PR is rejected because it was updated

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

@pgimalac

Copy link
Copy Markdown
Member Author

/merge

@dd-devflow

dd-devflow Bot commented May 10, 2024

Copy link
Copy Markdown

🚂 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

dd-devflow Bot commented May 10, 2024

Copy link
Copy Markdown

🚂 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-mergequeue
dd-mergequeue Bot merged commit 09161cd into main May 10, 2024
@dd-mergequeue
dd-mergequeue Bot deleted the pgimalac/serverless-trim-config branch May 10, 2024 09:41
@github-actions github-actions Bot added this to the 7.55.0 milestone May 10, 2024
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.

4 participants