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

[Serverless] Benchmarks for start/end-invocation. #21046

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

purple4reina
Copy link
Contributor

What does this PR do?

Adds benchmarks to track overhead of calling start and end invocation.

Motivation

In the future, we can create a github action to run on pull request to track changes to benchmark time.

Additional Notes

Run benchmarks

go test -tags=test -run='^$' -bench=StartEndInvocation -count=10 -benchtime=100x ./pkg/serverless/... | tee old.txt

Compare benchmarks

benchstat -row /event old.txt new.txt

Sample output

goos: darwin
goarch: arm64
pkg: github.com/DataDog/datadog-agent/pkg/serverless/daemon
                                      │   old2.txt   │               new2.txt               │
                                      │    sec/op    │    sec/op     vs base                │
api-gateway-appsec.json                 109.5µ ±  4%   113.4µ ±  7%        ~ (p=0.190 n=10)
api-gateway-non-proxy-async.json        126.9µ ±  1%   106.0µ ±  3%  -16.49% (p=0.000 n=10)
api-gateway-non-proxy.json              126.9µ ±  2%   104.6µ ±  3%  -17.61% (p=0.000 n=10)
api-gateway-websocket-connect.json      81.45µ ±  2%   69.51µ ±  5%  -14.66% (p=0.001 n=10)
api-gateway-websocket-default.json      67.47µ ±  6%   58.54µ ± 20%  -13.23% (p=0.019 n=10)
api-gateway-websocket-disconnect.json   65.36µ ± 10%   58.11µ ± 11%  -11.10% (p=0.001 n=10)
api-gateway.json                        135.1µ ±  2%   111.6µ ±  5%  -17.41% (p=0.000 n=10)
application-load-balancer.json          54.88µ ±  4%   46.01µ ±  5%  -16.17% (p=0.000 n=10)
cloudfront.json                         36.88µ ±  4%   38.41µ ±  6%        ~ (p=0.052 n=10)
cloudwatch-events.json                  26.41µ ±  5%   26.77µ ±  5%        ~ (p=0.305 n=10)
cloudwatch-logs.json                    34.68µ ±  9%   36.99µ ± 10%        ~ (p=0.247 n=10)
custom.json                             15.98µ ±  4%   18.74µ ±  6%  +17.28% (p=0.000 n=10)
dynamodb.json                           109.2µ ±  1%   111.3µ ±  5%        ~ (p=0.353 n=10)
eventbridge-custom.json                 29.49µ ±  3%   29.71µ ± 15%        ~ (p=1.000 n=10)
http-api.json                           64.68µ ± 11%   62.58µ ± 10%   -3.25% (p=0.035 n=10)
kinesis-batch.json                      69.60µ ±  5%   69.44µ ±  4%        ~ (p=1.000 n=10)
kinesis.json                            50.33µ ±  6%   51.43µ ±  3%        ~ (p=0.353 n=10)
s3.json                                 53.15µ ±  8%   53.11µ ±  5%        ~ (p=0.739 n=10)
sns-batch.json                          95.85µ ±  1%   95.21µ ±  1%        ~ (p=0.165 n=10)
sns.json                                60.58µ ±  3%   61.72µ ±  3%        ~ (p=0.165 n=10)
snssqs.json                             103.9µ ±  4%   101.2µ ±  6%   -2.66% (p=0.011 n=10)
snssqs_no_dd_context.json               93.07µ ±  3%   96.02µ ±  3%   +3.17% (p=0.005 n=10)
sqs-batch.json                          99.56µ ±  6%   88.51µ ±  5%  -11.10% (p=0.000 n=10)
sqs.json                                67.04µ ± 26%   62.97µ ±  4%   -6.08% (p=0.011 n=10)
sqs_no_dd_context.json                  53.64µ ±  2%   55.14µ ±  3%   +2.80% (p=0.043 n=10)
api-gateway-kong-appsec.json                           67.38µ ±  3%
api-gateway-kong.json                                  63.38µ ±  4%
sqs-aws-header.json                                    55.05µ ± 11%
geomean                                 64.84µ         62.30µ         -3.81%

                                      │   old2.txt   │               new2.txt                │
                                      │     B/op     │     B/op       vs base                │
api-gateway-appsec.json                 52.33Ki ± 2%   53.77Ki ±  2%   +2.76% (p=0.000 n=10)
api-gateway-non-proxy-async.json        60.03Ki ± 5%   57.51Ki ±  0%   -4.20% (p=0.001 n=10)
api-gateway-non-proxy.json              58.58Ki ± 7%   56.01Ki ±  0%   -4.38% (p=0.002 n=10)
api-gateway-websocket-connect.json      35.96Ki ± 0%   34.81Ki ±  0%   -3.20% (p=0.000 n=10)
api-gateway-websocket-default.json      29.12Ki ± 1%   28.76Ki ±  0%   -1.26% (p=0.002 n=10)
api-gateway-websocket-disconnect.json   28.66Ki ± 0%   28.32Ki ±  0%   -1.19% (p=0.001 n=10)
api-gateway.json                        68.28Ki ± 0%   61.84Ki ±  0%   -9.43% (p=0.000 n=10)
application-load-balancer.json          26.85Ki ± 0%   23.95Ki ±  0%  -10.77% (p=0.000 n=10)
cloudfront.json                         17.93Ki ± 0%   18.65Ki ±  0%   +4.03% (p=0.001 n=10)
cloudwatch-events.json                  11.95Ki ± 0%   12.64Ki ±  1%   +5.71% (p=0.000 n=10)
cloudwatch-logs.json                    54.00Ki ± 1%   54.72Ki ±  0%   +1.33% (p=0.001 n=10)
custom.json                             9.028Ki ± 0%   9.743Ki ±  1%   +7.91% (p=0.000 n=10)
dynamodb.json                           59.04Ki ± 0%   59.75Ki ±  0%   +1.20% (p=0.001 n=10)
eventbridge-custom.json                 13.15Ki ± 1%   13.92Ki ±  2%   +5.83% (p=0.000 n=10)
http-api.json                           29.21Ki ± 0%   27.87Ki ±  1%   -4.59% (p=0.000 n=10)
kinesis-batch.json                      35.36Ki ± 0%   35.92Ki ±  0%   +1.59% (p=0.000 n=10)
kinesis.json                            25.34Ki ± 1%   25.93Ki ±  1%   +2.33% (p=0.001 n=10)
s3.json                                 21.27Ki ± 1%   21.95Ki ±  0%   +3.21% (p=0.000 n=10)
sns-batch.json                          48.51Ki ± 0%   49.16Ki ±  0%   +1.34% (p=0.000 n=10)
sns.json                                31.83Ki ± 0%   32.50Ki ±  1%   +2.11% (p=0.000 n=10)
snssqs.json                             50.66Ki ± 1%   51.84Ki ±  0%   +2.32% (p=0.002 n=10)
snssqs_no_dd_context.json               52.90Ki ± 0%   52.51Ki ±  0%   -0.73% (p=0.002 n=10)
sqs-batch.json                          46.49Ki ± 0%   47.24Ki ±  0%   +1.62% (p=0.000 n=10)
sqs.json                                29.51Ki ± 0%   30.23Ki ±  0%   +2.45% (p=0.000 n=10)
sqs_no_dd_context.json                  28.15Ki ± 0%   28.73Ki ±  0%   +2.05% (p=0.000 n=10)
api-gateway-kong-appsec.json                           30.51Ki ± 11%
api-gateway-kong.json                                  27.83Ki ± 20%
sqs-aws-header.json                                    23.92Ki ±  1%
geomean                                 32.70Ki        32.14Ki         +0.22%

                                      │  old2.txt  │              new2.txt              │
                                      │ allocs/op  │ allocs/op   vs base                │
api-gateway-appsec.json                 650.0 ± 0%   682.0 ± 0%   +4.92% (p=0.000 n=10)
api-gateway-non-proxy-async.json        739.0 ± 0%   699.0 ± 0%   -5.41% (p=0.000 n=10)
api-gateway-non-proxy.json              728.5 ± 0%   690.0 ± 0%   -5.28% (p=0.000 n=10)
api-gateway-websocket-connect.json      489.0 ± 0%   466.0 ± 0%   -4.70% (p=0.000 n=10)
api-gateway-websocket-default.json      393.0 ± 1%   378.0 ± 1%   -3.82% (p=0.000 n=10)
api-gateway-websocket-disconnect.json   384.0 ± 0%   369.0 ± 0%   -3.91% (p=0.000 n=10)
api-gateway.json                        907.0 ± 0%   793.5 ± 0%  -12.51% (p=0.000 n=10)
application-load-balancer.json          392.0 ± 1%   337.0 ± 0%  -14.03% (p=0.000 n=10)
cloudfront.json                         228.0 ± 0%   247.0 ± 0%   +8.33% (p=0.000 n=10)
cloudwatch-events.json                  209.0 ± 0%   228.0 ± 0%   +9.09% (p=0.000 n=10)
cloudwatch-logs.json                    208.0 ± 0%   227.0 ± 0%   +9.13% (p=0.000 n=10)
custom.json                             153.5 ± 0%   172.0 ± 1%  +12.05% (p=0.000 n=10)
dynamodb.json                           682.0 ± 0%   701.0 ± 0%   +2.79% (p=0.000 n=10)
eventbridge-custom.json                 224.5 ± 1%   244.0 ± 0%   +8.69% (p=0.000 n=10)
http-api.json                           446.0 ± 0%   407.5 ± 1%   -8.63% (p=0.000 n=10)
kinesis-batch.json                      395.0 ± 1%   412.5 ± 1%   +4.43% (p=0.000 n=10)
kinesis.json                            335.0 ± 0%   353.5 ± 0%   +5.52% (p=0.000 n=10)
s3.json                                 289.0 ± 0%   307.5 ± 0%   +6.40% (p=0.000 n=10)
sns-batch.json                          425.5 ± 0%   445.0 ± 0%   +4.58% (p=0.000 n=10)
sns.json                                354.0 ± 1%   373.5 ± 1%   +5.51% (p=0.000 n=10)
snssqs.json                             371.0 ± 1%   396.0 ± 1%   +6.74% (p=0.000 n=10)
snssqs_no_dd_context.json               445.0 ± 0%   461.0 ± 0%   +3.60% (p=0.000 n=10)
sqs-batch.json                          420.0 ± 0%   434.5 ± 0%   +3.45% (p=0.000 n=10)
sqs.json                                320.5 ± 0%   334.0 ± 1%   +4.21% (p=0.000 n=10)
sqs_no_dd_context.json                  346.0 ± 0%   363.0 ± 0%   +4.91% (p=0.000 n=10)
api-gateway-kong-appsec.json                         489.0 ± 0%
api-gateway-kong.json                                467.0 ± 0%
sqs-aws-header.json                                  273.0 ± 0%
geomean                                 384.6        391.4        +1.60%

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 if the qa/skip-qa label is not 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.

@purple4reina purple4reina added changelog/no-changelog [deprecated] qa/skip-qa - use other qa/ labels [DEPRECATED] Please use qa/done or qa/no-code-change to skip creating a QA card team/serverless labels Nov 22, 2023
@purple4reina purple4reina added this to the Triage milestone Nov 22, 2023
@purple4reina purple4reina requested a review from a team as a code owner November 22, 2023 20:11
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gives us a baseline benchmark.

@purple4reina purple4reina force-pushed the rey.abolofia/benchmarks branch 3 times, most recently from 66e991f to d12ee08 Compare November 27, 2023 22:04
@pr-commenter
Copy link

pr-commenter bot commented Nov 28, 2023

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: a1bc73fe-3cae-42cf-9866-b5fb7046b28b
Baseline: 63f5907
Comparison: d12ee08
Total datadog-agent CPUs: 7

Explanation

A regression test is an integrated performance test for datadog-agent in a repeatable rig, with varying configuration for datadog-agent. What follows is a statistical summary of a brief datadog-agent run for each configuration across SHAs given above. The goal of these tests are to determine quickly if datadog-agent performance is changed and to what degree by a pull request.

Because a target's optimization goal performance in each experiment will vary somewhat each time it is run, we can only estimate mean differences in optimization goal relative to the baseline target. We express these differences as a percentage change relative to the baseline target, denoted "Δ mean %". These estimates are made to a precision that balances accuracy and cost control. We represent this precision as a 90.00% confidence interval denoted "Δ mean % CI": there is a 90.00% chance that the true value of "Δ mean %" is in that interval.

We decide whether a change in performance is a "regression" -- a change worth investigating further -- if both of the following two criteria are true:

  1. The estimated |Δ mean %| ≥ 5.00%. This criterion intends to answer the question "Does the estimated change in mean optimization goal performance have a meaningful impact on your customers?". We assume that when |Δ mean %| < 5.00%, the impact on your customers is not meaningful. We also assume that a performance change in optimization goal is worth investigating whether it is an increase or decrease, so long as the magnitude of the change is sufficiently large.

  2. Zero is not in the 90.00% confidence interval "Δ mean % CI" about "Δ mean %". This statement is equivalent to saying that there is at least a 90.00% chance that the mean difference in optimization goal is not zero. This criterion intends to answer the question, "Is there a statistically significant difference in mean optimization goal performance?". It also means there is no more than a 10.00% chance this criterion reports a statistically significant difference when the true difference in mean optimization goal is zero -- a "false positive". We assume you are willing to accept a 10.00% chance of inaccurately detecting a change in performance when no true difference exists.

The table below, if present, lists those experiments that have experienced a statistically significant change in mean optimization goal performance between baseline and comparison SHAs with 90.00% confidence OR have been detected as newly erratic. Negative values of "Δ mean %" mean that baseline is faster, whereas positive values of "Δ mean %" mean that comparison is faster. Results that do not exhibit more than a ±5.00% change in their mean optimization goal are discarded. An experiment is erratic if its coefficient of variation is greater than 0.1. The abbreviated table will be omitted if no interesting change is observed.

No interesting changes in experiment optimization goals with confidence ≥ 90.00% and |Δ mean %| ≥ 5.00%.

Fine details of change detection per experiment.
experiment goal Δ mean % Δ mean % CI confidence
otel_to_otel_logs ingress throughput +0.77 [-0.82, +2.35] 57.24%
idle egress throughput +0.21 [-2.27, +2.69] 11.04%
trace_agent_msgpack ingress throughput +0.05 [-0.08, +0.17] 46.79%
file_to_blackhole egress throughput +0.03 [-0.98, +1.04] 3.58%
dogstatsd_string_interner_8MiB_50k ingress throughput +0.03 [-0.02, +0.07] 64.14%
tcp_dd_logs_filter_exclude ingress throughput +0.02 [-0.15, +0.19] 14.32%
dogstatsd_string_interner_8MiB_100k ingress throughput +0.02 [-0.04, +0.08] 32.49%
dogstatsd_string_interner_8MiB_1k ingress throughput +0.01 [-0.09, +0.11] 10.74%
dogstatsd_string_interner_8MiB_10k ingress throughput +0.01 [-0.01, +0.02] 66.50%
dogstatsd_string_interner_128MiB_100 ingress throughput +0.00 [-0.14, +0.14] 0.50%
dogstatsd_string_interner_64MiB_1k ingress throughput +0.00 [-0.13, +0.13] 0.21%
dogstatsd_string_interner_64MiB_100 ingress throughput +0.00 [-0.14, +0.14] 0.04%
uds_dogstatsd_to_api ingress throughput -0.00 [-0.15, +0.15] 0.88%
dogstatsd_string_interner_8MiB_100 ingress throughput -0.00 [-0.13, +0.12] 4.99%
dogstatsd_string_interner_128MiB_1k ingress throughput -0.01 [-0.15, +0.14] 5.43%
trace_agent_json ingress throughput -0.01 [-0.14, +0.13] 5.80%
file_tree egress throughput -0.20 [-2.03, +1.63] 14.41%
tcp_syslog_to_blackhole ingress throughput -0.38 [-0.51, -0.24] 100.00%

startBody := getEventFromFile(file.Name())
b.Run("event="+file.Name(), func(b *testing.B) {
startReq := httptest.NewRequest("GET", "/lambda/start-invocation", nil)
endReq := httptest.NewRequest("GET", "/lambda/endd-invocation", nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a typo? endd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure is! Great catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@purple4reina purple4reina force-pushed the rey.abolofia/benchmarks branch from d12ee08 to e966922 Compare November 30, 2023 17:35
@purple4reina purple4reina merged commit 8bfcefc into main Nov 30, 2023
146 of 150 checks passed
@purple4reina purple4reina deleted the rey.abolofia/benchmarks branch November 30, 2023 19:39
wdhif pushed a commit that referenced this pull request Dec 4, 2023
wdhif pushed a commit that referenced this pull request Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog [deprecated] qa/skip-qa - use other qa/ labels [DEPRECATED] Please use qa/done or qa/no-code-change to skip creating a QA card team/serverless
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants