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

[CONTP-535] optimise tagger server chunking function by processing chunks in place #31837

Conversation

adel121
Copy link
Contributor

@adel121 adel121 commented Dec 6, 2024

What does this PR do?

This PR optimises tagger server chunking logic by processing chunks in place instead of duplicating them in memory.

Motivation

Memory and CPU optimisation.

Results of benchmarks:

goos: linux
goarch: arm64
pkg: github.com/DataDog/datadog-agent/comp/core/tagger/server
                               │    old.txt    │               new.txt               │
                               │    sec/op     │    sec/op     vs base               │
ProcessChunks/100-items-10       2399.5n ± 47%   239.8n ±  4%  -90.01% (p=0.002 n=6)
ProcessChunks/1000-items-10      35.072µ ± 13%   2.344µ ± 11%  -93.32% (p=0.002 n=6)
ProcessChunks/10000-items-10     365.19µ ±  5%   22.56µ ± 18%  -93.82% (p=0.002 n=6)
ProcessChunks/100000-items-10    3435.1µ ±  7%   222.5µ ± 16%  -93.52% (p=0.002 n=6)
ProcessChunks/1000000-items-10   29.059m ±  9%   2.219m ± 31%  -92.36% (p=0.002 n=6)
geomean                           314.3µ         22.87µ        -92.72%

                               │   old.txt    │                 new.txt                  │
                               │     B/op     │     B/op      vs base                    │
ProcessChunks/100-items-10       2.969Ki ± 0%   0.000Ki ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/1000-items-10      29.02Ki ± 0%    0.00Ki ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/10000-items-10     370.7Ki ± 0%     0.0Ki ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/100000-items-10    4.165Mi ± 0%   0.000Mi ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/1000000-items-10   44.65Mi ± 0%    0.00Mi ± 0%  -100.00% (p=0.002 n=6)
geomean                          362.1Ki                      ?                      ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

                               │   old.txt   │                 new.txt                 │
                               │  allocs/op  │  allocs/op   vs base                    │
ProcessChunks/100-items-10        81.00 ± 0%     0.00 ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/1000-items-10       759.0 ± 0%      0.0 ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/10000-items-10     7.514k ± 0%   0.000k ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/100000-items-10    75.02k ± 0%    0.00k ± 0%  -100.00% (p=0.002 n=6)
ProcessChunks/1000000-items-10   750.0k ± 0%     0.0k ± 0%  -100.00% (p=0.002 n=6)
geomean                          7.638k                     ?                      ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

Describe how you validated your changes

Unit tests and E2E are sufficient.

As long as remote tagger still works, then everything is good.

Possible Drawbacks / Trade-offs

None.

Additional Notes

I have added benchmark tests and included all details in the README.md file

@adel121 adel121 added kind/enhancement component/tagger changelog/no-changelog qa/done QA done before merge and regressions are covered by tests team/container-platform The Container Platform Team labels Dec 6, 2024
@adel121 adel121 added this to the 7.61.0 milestone Dec 6, 2024
@github-actions github-actions bot added the medium review PR review might take time label Dec 6, 2024
@adel121 adel121 marked this pull request as ready for review December 6, 2024 14:43
@adel121 adel121 requested a review from a team as a code owner December 6, 2024 14:43
@adel121 adel121 changed the title optimise tagger server chunking function by processing chunks in place [CONTP-535] optimise tagger server chunking function by processing chunks in place Dec 6, 2024
@adel121 adel121 force-pushed the optimise_tagger_server_chunking_function_by_processing_chunks_in_place branch from c03406b to fa2ef3b Compare December 6, 2024 14:57
@agent-platform-auto-pr
Copy link
Contributor

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv aws.create-vm --pipeline-id=50461273 --os-family=ubuntu

Note: This applies to commit fa2ef3b

Copy link

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 48c8cd5f-aaee-4b47-886a-3b80a0056b88

Baseline: 4daa586
Comparison: fa2ef3b
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
file_to_blackhole_1000ms_latency egress throughput +0.70 [-0.09, +1.49] 1 Logs
file_to_blackhole_1000ms_latency_linear_load egress throughput +0.52 [+0.07, +0.98] 1 Logs
quality_gate_logs % cpu utilization +0.41 [-2.58, +3.40] 1 Logs
otel_to_otel_logs ingress throughput +0.34 [-0.34, +1.02] 1 Logs
file_tree memory utilization +0.29 [+0.16, +0.42] 1 Logs
quality_gate_idle_all_features memory utilization +0.27 [+0.16, +0.39] 1 Logs bounds checks dashboard
uds_dogstatsd_to_api ingress throughput +0.02 [-0.06, +0.11] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] 1 Logs
file_to_blackhole_300ms_latency egress throughput -0.01 [-0.64, +0.62] 1 Logs
file_to_blackhole_500ms_latency egress throughput -0.02 [-0.79, +0.74] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.03 [-0.91, +0.85] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.11 [-0.93, +0.71] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization -0.14 [-0.87, +0.58] 1 Logs
quality_gate_idle memory utilization -0.36 [-0.41, -0.32] 1 Logs bounds checks dashboard
tcp_syslog_to_blackhole ingress throughput -0.83 [-0.91, -0.75] 1 Logs

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency_linear_load memory_usage 10/10
file_to_blackhole_100ms_latency lost_bytes 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_300ms_latency lost_bytes 10/10
file_to_blackhole_300ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs lost_bytes 10/10
quality_gate_logs memory_usage 10/10

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

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

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

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.

@adel121
Copy link
Contributor Author

adel121 commented Dec 7, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Dec 7, 2024

Devflow running: /merge

View all feedbacks in Devflow UI.


2024-12-07 22:35:38 UTC ℹ️ MergeQueue: pull request added to the queue

The median merge time in main is 23m.

@dd-mergequeue dd-mergequeue bot merged commit 00f8f5b into main Dec 7, 2024
228 checks passed
@dd-mergequeue dd-mergequeue bot deleted the optimise_tagger_server_chunking_function_by_processing_chunks_in_place branch December 7, 2024 23:00
@github-actions github-actions bot modified the milestones: 7.61.0, 7.62.0 Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog component/tagger kind/enhancement medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/container-platform The Container Platform Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants