Skip to content

Fill stat struct#267

Merged
florianl merged 4 commits intomainfrom
fillStatStruct
Oct 23, 2025
Merged

Fill stat struct#267
florianl merged 4 commits intomainfrom
fillStatStruct

Conversation

@florianl
Copy link
Copy Markdown
Member

@florianl florianl commented Oct 17, 2025

What does this PR do?

When looking at deployments, agentbeats and this dependency spends a significant time in reflect.

2025-10-17_09-34
goos: linux
goarch: amd64
pkg: github.com/elastic/elastic-agent-system-metrics/metric/system/cgroup/cgv2
cpu: 12th Gen Intel(R) Core(TM) i7-12700H
                  │    old.txt    │               new.txt               │
                  │    sec/op     │   sec/op     vs base                │
FillStatStruct-20   139.357µ ± 1%   7.835µ ± 2%  -94.38% (p=0.000 n=10)

                  │   old.txt    │               new.txt               │
                  │     B/op     │     B/op      vs base               │
FillStatStruct-20   7.664Ki ± 0%   7.555Ki ± 0%  -1.43% (p=0.000 n=10)

                  │  old.txt   │              new.txt               │
                  │ allocs/op  │ allocs/op   vs base                │
FillStatStruct-20   66.00 ± 0%   52.00 ± 0%  -21.21% (p=0.000 n=10)

While benchmarks show an increase in memory usage, the reduction of sec/op (~93%) overweights the additional memory requirement.

Why is it important?

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

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@florianl florianl requested a review from a team as a code owner October 17, 2025 07:46
@florianl florianl added the enhancement New feature or request label Oct 17, 2025
@florianl florianl requested review from AndersonQ and VihasMakwana and removed request for a team October 17, 2025 07:46
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
kruskall
kruskall previously approved these changes Oct 17, 2025
Copy link
Copy Markdown
Member

@kruskall kruskall left a comment

Choose a reason for hiding this comment

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

LGTM! Slight increase in allocation is a bit concerning but the change looks good

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Oct 17, 2025
VihasMakwana
VihasMakwana previously approved these changes Oct 17, 2025
@pierrehilbert pierrehilbert requested a review from rdner October 17, 2025 11:03
@florianl florianl enabled auto-merge (squash) October 17, 2025 11:10
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@florianl florianl dismissed stale reviews from VihasMakwana and kruskall via 58e187f October 17, 2025 14:16
Copy link
Copy Markdown
Member

@kruskall kruskall left a comment

Choose a reason for hiding this comment

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

Thank you! This is amazing!

@florianl florianl requested a review from VihasMakwana October 21, 2025 13:50
@florianl florianl merged commit b1968df into main Oct 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants