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

use stdlib maps and slices where possible #22724

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

brycekahle
Copy link
Member

@brycekahle brycekahle commented Feb 8, 2024

What does this PR do?

use stdlib maps and slices where possible

Motivation

parts of golang.org/x/exp/maps and golang.org/x/exp/slices were moved into the stdlib in Go 1.21

Additional Notes

For some reason maps.Keys was not included. See golang/go#61900

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

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.

@brycekahle brycekahle added changelog/no-changelog team/ebpf-platform qa/done QA done before merge and regressions are covered by tests labels Feb 8, 2024
@brycekahle brycekahle added this to the 7.52.0 milestone Feb 8, 2024
@brycekahle brycekahle requested review from a team as code owners February 8, 2024 22:48
Copy link

cit-pr-commenter bot commented Feb 8, 2024

Go Package Import Differences

Baseline: a59e0c9
Comparison: d55bbd0

binaryosarchchange
agentwindowsamd64
+1, -0
+maps
agentdarwinamd64
+1, -0
+maps
agentdarwinarm64
+1, -0
+maps
cluster-agent-cloudfoundrylinuxamd64
+0, -1
-golang.org/x/exp/slices
cluster-agent-cloudfoundrylinuxarm64
+0, -1
-golang.org/x/exp/slices
dogstatsdlinuxamd64
+0, -1
-golang.org/x/exp/slices
dogstatsdlinuxarm64
+0, -1
-golang.org/x/exp/slices
process-agentlinuxamd64
+0, -1
-golang.org/x/exp/slices
process-agentlinuxarm64
+0, -1
-golang.org/x/exp/slices
process-agentwindowsamd64
+0, -1
-golang.org/x/exp/slices
process-agentdarwinamd64
+0, -1
-golang.org/x/exp/slices
process-agentdarwinarm64
+0, -1
-golang.org/x/exp/slices
heroku-process-agentlinuxamd64
+0, -1
-golang.org/x/exp/slices
security-agentlinuxamd64
+0, -1
-golang.org/x/exp/slices
security-agentlinuxarm64
+0, -1
-golang.org/x/exp/slices
system-probewindowsamd64
+0, -1
-golang.org/x/exp/slices

@pr-commenter
Copy link

pr-commenter bot commented Feb 9, 2024

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: b6cb202d-36a5-4766-ab79-3ee74489794c
Baseline: a59e0c9
Comparison: d55bbd0
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 -0.67 [-7.21, +5.87]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
process_agent_standard_check memory utilization +0.85 [+0.81, +0.90]
otel_to_otel_logs ingress throughput +0.82 [+0.17, +1.47]
uds_dogstatsd_to_api_cpu % cpu utilization +0.56 [-0.88, +1.99]
tcp_syslog_to_blackhole ingress throughput +0.45 [+0.40, +0.51]
file_tree memory utilization +0.20 [+0.10, +0.31]
process_agent_real_time_mode memory utilization +0.14 [+0.09, +0.20]
trace_agent_json ingress throughput +0.00 [-0.03, +0.03]
uds_dogstatsd_to_api ingress throughput +0.00 [-0.00, +0.00]
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.00, +0.00]
trace_agent_msgpack ingress throughput -0.01 [-0.02, -0.00]
idle memory utilization -0.05 [-0.09, -0.00]
process_agent_standard_check_with_stats memory utilization -0.28 [-0.32, -0.23]
file_to_blackhole % cpu utilization -0.67 [-7.21, +5.87]

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

@davidor davidor left a comment

Choose a reason for hiding this comment

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

👍 for container-integrations files

Copy link
Contributor

@paulcacheux paulcacheux 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-security and agent-cspm files. Thanks a lot !

Copy link
Contributor

@jeremy-hanna jeremy-hanna left a comment

Choose a reason for hiding this comment

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

🔥

@brycekahle brycekahle requested review from a team as code owners February 9, 2024 17:09
@brycekahle brycekahle requested a review from dinooliva February 9, 2024 17:09
@brycekahle brycekahle force-pushed the bryce.kahle/stdlib-maps-slices branch from 796cd56 to 2f7d585 Compare February 9, 2024 17:52
Copy link
Member

@gh123man gh123man 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 AML owned files

@brycekahle brycekahle modified the milestones: 7.52.0, 7.53.0 Feb 16, 2024
@brycekahle brycekahle force-pushed the bryce.kahle/stdlib-maps-slices branch from 2f7d585 to 5fa2be0 Compare February 26, 2024 22:50
@brycekahle brycekahle requested a review from a team as a code owner February 26, 2024 22:50
@brycekahle brycekahle force-pushed the bryce.kahle/stdlib-maps-slices branch 2 times, most recently from 76f3d2c to a395bab Compare February 26, 2024 23:32
@brycekahle brycekahle removed request for a team and dinooliva February 26, 2024 23:32
@brycekahle brycekahle force-pushed the bryce.kahle/stdlib-maps-slices branch from a395bab to d55bbd0 Compare February 28, 2024 18:45
Copy link
Contributor

Serverless Benchmark Results

BenchmarkStartEndInvocation comparison between a59e0c9 and a53eb78.

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                
                                      │ baseline/benchmark.log │        current/benchmark.log        │
                                      │         sec/op         │    sec/op     vs base               │
api-gateway-appsec.json                            86.27µ ± 7%    87.70µ ± 3%       ~ (p=0.280 n=10)
api-gateway-kong-appsec.json                       65.64µ ± 1%    65.43µ ± 1%       ~ (p=0.739 n=10)
api-gateway-kong.json                              63.44µ ± 2%    63.20µ ± 4%       ~ (p=0.393 n=10)
api-gateway-non-proxy-async.json                   100.5µ ± 2%    101.4µ ± 1%       ~ (p=0.105 n=10)
api-gateway-non-proxy.json                         100.5µ ± 1%    101.3µ ± 1%  +0.84% (p=0.019 n=10)
api-gateway-websocket-connect.json                 66.88µ ± 1%    67.42µ ± 1%       ~ (p=0.075 n=10)
api-gateway-websocket-default.json                 60.41µ ± 1%    59.94µ ± 1%       ~ (p=0.218 n=10)
api-gateway-websocket-disconnect.json              59.86µ ± 1%    60.45µ ± 2%  +1.00% (p=0.035 n=10)
api-gateway.json                                   111.1µ ± 1%    112.2µ ± 1%       ~ (p=0.165 n=10)
application-load-balancer.json                     60.25µ ± 2%    61.85µ ± 1%  +2.65% (p=0.001 n=10)
cloudfront.json                                    46.27µ ± 1%    47.27µ ± 1%  +2.16% (p=0.000 n=10)
cloudwatch-events.json                             36.91µ ± 1%    37.82µ ± 2%  +2.46% (p=0.000 n=10)
cloudwatch-logs.json                               62.88µ ± 2%    64.41µ ± 1%  +2.44% (p=0.000 n=10)
custom.json                                        29.11µ ± 2%    29.49µ ± 1%  +1.30% (p=0.015 n=10)
dynamodb.json                                      92.58µ ± 2%    93.44µ ± 1%       ~ (p=0.075 n=10)
empty.json                                         27.70µ ± 3%    27.84µ ± 1%       ~ (p=0.363 n=10)
eventbridge-custom.json                            40.72µ ± 2%    41.11µ ± 1%  +0.96% (p=0.009 n=10)
http-api.json                                      71.16µ ± 1%    72.65µ ± 1%  +2.10% (p=0.009 n=10)
kinesis-batch.json                                 70.90µ ± 2%    72.20µ ± 1%  +1.82% (p=0.002 n=10)
kinesis.json                                       52.61µ ± 2%    53.88µ ± 2%  +2.42% (p=0.000 n=10)
s3.json                                            57.72µ ± 2%    59.46µ ± 1%  +3.02% (p=0.000 n=10)
sns-batch.json                                     89.96µ ± 1%    92.48µ ± 2%  +2.80% (p=0.000 n=10)
sns.json                                           64.03µ ± 2%    64.70µ ± 1%       ~ (p=0.089 n=10)
snssqs.json                                        103.8µ ± 2%    106.5µ ± 2%  +2.62% (p=0.001 n=10)
snssqs_no_dd_context.json                          97.96µ ± 1%   100.49µ ± 2%  +2.58% (p=0.000 n=10)
sqs-aws-header.json                                54.49µ ± 1%    55.53µ ± 1%  +1.90% (p=0.000 n=10)
sqs-batch.json                                     94.84µ ± 1%    93.60µ ± 1%       ~ (p=0.075 n=10)
sqs.json                                           68.40µ ± 2%    68.09µ ± 3%       ~ (p=0.796 n=10)
sqs_no_dd_context.json                             60.03µ ± 2%    60.91µ ± 1%  +1.47% (p=0.023 n=10)
geomean                                            64.94µ         65.79µ       +1.31%

                                      │ baseline/benchmark.log │        current/benchmark.log        │
                                      │          B/op          │     B/op      vs base               │
api-gateway-appsec.json                           36.95Ki ± 0%   37.02Ki ± 0%  +0.19% (p=0.000 n=10)
api-gateway-kong-appsec.json                      26.62Ki ± 0%   26.62Ki ± 0%       ~ (p=0.868 n=10)
api-gateway-kong.json                             24.11Ki ± 0%   24.11Ki ± 0%       ~ (p=0.446 n=10)
api-gateway-non-proxy-async.json                  47.76Ki ± 0%   47.82Ki ± 0%  +0.12% (p=0.000 n=10)
api-gateway-non-proxy.json                        46.97Ki ± 0%   47.02Ki ± 0%  +0.11% (p=0.000 n=10)
api-gateway-websocket-connect.json                25.19Ki ± 0%   25.23Ki ± 0%  +0.12% (p=0.000 n=10)
api-gateway-websocket-default.json                21.09Ki ± 0%   21.13Ki ± 0%  +0.16% (p=0.000 n=10)
api-gateway-websocket-disconnect.json             20.88Ki ± 0%   20.91Ki ± 0%  +0.18% (p=0.000 n=10)
api-gateway.json                                  49.27Ki ± 0%   49.27Ki ± 0%       ~ (p=0.645 n=10)
application-load-balancer.json                    22.06Ki ± 0%   22.99Ki ± 0%  +4.24% (p=0.000 n=10)
cloudfront.json                                   17.39Ki ± 0%   17.41Ki ± 0%  +0.11% (p=0.000 n=10)
cloudwatch-events.json                            11.44Ki ± 0%   11.47Ki ± 0%  +0.26% (p=0.000 n=10)
cloudwatch-logs.json                              53.10Ki ± 0%   53.11Ki ± 0%       ~ (p=0.542 n=10)
custom.json                                       9.466Ki ± 0%   9.483Ki ± 0%  +0.18% (p=0.002 n=10)
dynamodb.json                                     40.42Ki ± 0%   40.44Ki ± 0%  +0.07% (p=0.007 n=10)
empty.json                                        9.022Ki ± 0%   9.037Ki ± 0%       ~ (p=0.171 n=10)
eventbridge-custom.json                           13.16Ki ± 0%   13.20Ki ± 0%  +0.33% (p=0.000 n=10)
http-api.json                                     23.45Ki ± 0%   23.50Ki ± 0%  +0.24% (p=0.001 n=10)
kinesis-batch.json                                26.76Ki ± 0%   26.80Ki ± 0%  +0.16% (p=0.023 n=10)
kinesis.json                                      17.53Ki ± 0%   17.59Ki ± 0%  +0.32% (p=0.024 n=10)
s3.json                                           20.06Ki ± 0%   20.11Ki ± 0%  +0.24% (p=0.000 n=10)
sns-batch.json                                    38.38Ki ± 0%   38.40Ki ± 0%       ~ (p=0.138 n=10)
sns.json                                          23.75Ki ± 0%   23.77Ki ± 0%       ~ (p=0.055 n=10)
snssqs.json                                       49.32Ki ± 0%   49.41Ki ± 0%  +0.18% (p=0.000 n=10)
snssqs_no_dd_context.json                         44.53Ki ± 0%   44.60Ki ± 0%  +0.15% (p=0.007 n=10)
sqs-aws-header.json                               18.61Ki ± 0%   18.58Ki ± 1%       ~ (p=0.631 n=10)
sqs-batch.json                                    41.41Ki ± 0%   41.36Ki ± 0%  -0.12% (p=0.034 n=10)
sqs.json                                          25.29Ki ± 0%   25.33Ki ± 0%       ~ (p=0.343 n=10)
sqs_no_dd_context.json                            20.45Ki ± 1%   20.40Ki ± 1%       ~ (p=1.000 n=10)
geomean                                           25.39Ki        25.45Ki       +0.25%

                                      │ baseline/benchmark.log │        current/benchmark.log        │
                                      │       allocs/op        │ allocs/op   vs base                 │
api-gateway-appsec.json                             628.0 ± 0%   628.5 ± 0%       ~ (p=0.650 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                    724.0 ± 0%   724.0 ± 0%       ~ (p=1.000 n=10)
api-gateway-non-proxy.json                          715.0 ± 0%   715.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                  378.0 ± 0%   378.0 ± 0%       ~ (p=1.000 n=10) ¹
api-gateway-websocket-disconnect.json               368.0 ± 0%   368.0 ± 0%       ~ (p=1.000 n=10)
api-gateway.json                                    789.0 ± 0%   789.0 ± 0%       ~ (p=1.000 n=10)
application-load-balancer.json                      350.0 ± 0%   351.0 ± 0%  +0.29% (p=0.000 n=10)
cloudfront.json                                     282.0 ± 0%   282.0 ± 0%       ~ (p=1.000 n=10)
cloudwatch-events.json                              219.0 ± 0%   219.0 ± 0%       ~ (p=1.000 n=10) ¹
cloudwatch-logs.json                                214.0 ± 0%   214.0 ± 0%       ~ (p=1.000 n=10)
custom.json                                         167.0 ± 0%   167.0 ± 0%       ~ (p=1.000 n=10) ¹
dynamodb.json                                       588.0 ± 0%   587.5 ± 0%       ~ (p=0.650 n=10)
empty.json                                          158.0 ± 0%   158.0 ± 0%       ~ (p=1.000 n=10)
eventbridge-custom.json                             252.0 ± 0%   253.0 ± 0%       ~ (p=0.370 n=10)
http-api.json                                       431.0 ± 0%   431.0 ± 0%       ~ (p=0.635 n=10)
kinesis-batch.json                                  389.0 ± 0%   389.0 ± 0%       ~ (p=0.303 n=10)
kinesis.json                                        283.5 ± 0%   284.0 ± 0%       ~ (p=0.470 n=10)
s3.json                                             356.0 ± 0%   356.0 ± 0%       ~ (p=1.000 n=10)
sns-batch.json                                      453.0 ± 0%   454.0 ± 0%       ~ (p=0.270 n=10)
sns.json                                            322.0 ± 0%   322.0 ± 0%       ~ (p=0.582 n=10)
snssqs.json                                         422.5 ± 0%   423.0 ± 0%       ~ (p=0.104 n=10)
snssqs_no_dd_context.json                           398.0 ± 0%   398.0 ± 0%       ~ (p=0.481 n=10)
sqs-aws-header.json                                 272.0 ± 0%   272.0 ± 1%       ~ (p=0.871 n=10)
sqs-batch.json                                      502.5 ± 0%   501.5 ± 0%  -0.20% (p=0.011 n=10)
sqs.json                                            349.5 ± 0%   350.0 ± 0%       ~ (p=0.378 n=10)
sqs_no_dd_context.json                              324.0 ± 1%   322.0 ± 1%       ~ (p=0.602 n=10)
geomean                                             374.4        374.5       +0.02%
¹ all samples are equal

@brycekahle
Copy link
Member Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Feb 28, 2024

🚂 MergeQueue

Pull request added to the queue.

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

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit 78805f3 into main Feb 28, 2024
221 of 222 checks passed
@dd-mergequeue dd-mergequeue bot deleted the bryce.kahle/stdlib-maps-slices branch February 28, 2024 23:31
louis-cqrl pushed a commit that referenced this pull request Mar 1, 2024
use stdlib maps and slices where possible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog component/system-probe qa/done QA done before merge and regressions are covered by tests team/ebpf-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.