Skip to content

[9.4](backport #50019) perf: remove unnecessary allocations in hot-path processors#50197

Open
mergify[bot] wants to merge 1 commit into9.4from
mergify/bp/9.4/pr-50019
Open

[9.4](backport #50019) perf: remove unnecessary allocations in hot-path processors#50197
mergify[bot] wants to merge 1 commit into9.4from
mergify/bp/9.4/pr-50019

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify bot commented Apr 17, 2026

Remove redundant Clone() calls and deferred allocations in four hot-path processors. No behavioral changes — events produced are byte-identical to main.

  • add_docker_metadata: Remove Clone() of locally-built map that has no other references. Also fix deprecated cgroup.NewReader → cgroup.NewReaderOptions.
  • add_kubernetes_metadata: Reduce 3 full metadata Clones to 1 full + 1 container sub-clone. The removed clone was Clone().GetValue() where GetValue is read-only.
  • timestamp: Defer parseError allocation to failure path. Success path is now allocation-free.
  • publisher/processing: Remove dead event.Meta.Clone() whose return value was discarded.

Per-processor benchmarks:

Processor Δ ns/op Δ B/op Δ allocs/op
add_docker_metadata -30% -35% -26%
add_kubernetes_metadata -52% -55% -55%
timestamp (single layout) -11% -14% -17%

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None. No behavioral changes. All event output is identical to main.

How to test this PR locally

go test -bench=BenchmarkAddDockerMetadata -benchmem ./libbeat/processors/add_docker_metadata/
go test -bench=BenchmarkKubernetesAnnotatorRun -benchmem ./libbeat/processors/add_kubernetes_metadata/
go test -bench=BenchmarkTimestamp -benchmem ./libbeat/processors/timestamp/

Supersedes #49761.


This is an automatic backport of pull request #50019 done by Mergify.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 2c8f217)
@mergify mergify bot requested a review from a team as a code owner April 17, 2026 14:37
@mergify mergify bot added the backport label Apr 17, 2026
@mergify mergify bot requested review from VihasMakwana and khushijain21 and removed request for a team April 17, 2026 14:37
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@github-actions github-actions bot added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team skip-changelog labels Apr 17, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants