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

[debugPrintProcessor]: exit directly when log doesn't have debug level enabled #40081

Conversation

pkoutsovasilis
Copy link
Contributor

@pkoutsovasilis pkoutsovasilis commented Jul 2, 2024

Proposed commit message

This PR is the aftermath of profiling the netflow integration test of this PR (PS: the pcap I used as input is ~25MB thus I won't include it in beats repo)

So this is the cpu profile flamegraph before the commit of this PR

Screenshot 2024-07-02 at 10 38 54 PM

As we can see debugPrintProcessor is invoked and we pay the "performance" price of encoding every event in json even when our log isn't set up with DEBUG level.

The respective cpu profile flamegraph after this PR with debugPrintProcessor still being there but exiting directly when log DEBUG is not enabled

Screenshot 2024-07-02 at 10 42 16 PM

Extracting the average EPS of the aformentioned netflow integration tested on my local macbook with a local ES inside a container

Before this PR With this PR
18490 33760

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

N/A

Author's Checklist

N/A

How to test this PR locally

Help get this PR merged or clone it and apply this small commit there 🙂

cd x-pack/filebeat
mage docker:composeUp

run go profiler against TestNetFlowIntegration

Related issues

Use cases

N/A

Screenshots

Look at description

Logs

N/A

@pkoutsovasilis pkoutsovasilis added bug backport-skip Skip notification from the automated backport with mergify labels Jul 2, 2024
@pkoutsovasilis pkoutsovasilis self-assigned this Jul 2, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 2, 2024
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Good find!

IIUC this issue has been affecting agent since 8.7.0? (I stand corrected, I missed this conditional)

@pkoutsovasilis
Copy link
Contributor Author

pkoutsovasilis commented Jul 2, 2024

Good find!

IIUC this issue has been affecting agent since 8.7.0?

after looking around the git history, I think that the PR which caused this is this one as the older implementation had the encoding part under an if which was checking the log level. So only 8.15.0 is affected?!

@pkoutsovasilis pkoutsovasilis marked this pull request as ready for review July 2, 2024 20:16
@pkoutsovasilis pkoutsovasilis requested a review from a team as a code owner July 2, 2024 20:16
@cmacknz cmacknz requested a review from belimawr July 2, 2024 20:20
@cmacknz cmacknz added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jul 2, 2024
@elasticmachine
Copy link
Collaborator

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 Jul 2, 2024
@pierrehilbert
Copy link
Collaborator

Thanks for catching that @pkoutsovasilis.
@belimawr could you please have a look here as this is related to your change?

@cmacknz
Copy link
Member

cmacknz commented Jul 2, 2024

For Elastic Agent this is 8.15.0 only, for standalone Beats this has been there since the beginning when it was first implemented: 83dfb2f

When under agent it was gated by: https:/elastic/beats/blob/cef7b39ee75b369eaaa9c1f992d151731c6da6d3/libbeat/management/agent.go#L50-L62

@cmacknz
Copy link
Member

cmacknz commented Jul 2, 2024

CC @alexsapran I would expect this to show up in the Filebeat benchmarks.

@alexsapran
Copy link
Contributor

CC @alexsapran I would expect this to show up in the Filebeat benchmarks.

You would be right to expect that.
Indeed, once I could run the elastic-agent benchmark again and review the generated diagnostics, the frame debugPrintProcessor was shown.

Unfortunately, this work is not yet complete. Running elastic-agent benchmarks was just unblocked from @pkoutsovasilis some days ago.
The end goal is to integrate this into CI.
So, looking at the future, it is possible to catch them.

Screenshot 2024-07-03 at 10 49 08 AM

@pkoutsovasilis
Copy link
Contributor Author

pkoutsovasilis commented Jul 3, 2024

with the opportunity of this PR I think it is a good idea to investigate if we can help in adding support to benchmark Filebeat inputs owned by @elastic/sec-deployment-and-devices

@pierrehilbert @cmacknz should we wait for a review from @belimawr ?

@pierrehilbert
Copy link
Collaborator

@belimawr will soon start his day so we can wait and get this merged today after his review if this is okay for you?

@pierrehilbert pierrehilbert added the backport-8.15 Automated backport to the 8.15 branch with mergify label Jul 4, 2024
@pierrehilbert pierrehilbert merged commit 58f4fc8 into elastic:main Jul 5, 2024
121 checks passed
mergify bot pushed a commit that referenced this pull request Jul 5, 2024
@pkoutsovasilis pkoutsovasilis deleted the pkoutsovasilis/debug_print_processor branch July 5, 2024 15:52
@cmacknz cmacknz added backport-v8.14.0 Automated backport with mergify and removed backport-skip Skip notification from the automated backport with mergify labels Jul 5, 2024
cmacknz pushed a commit that referenced this pull request Jul 5, 2024
… level enabled (#40081) (#40124)

(cherry picked from commit 58f4fc8)

Co-authored-by: Panos Koutsovasilis <[email protected]>
mergify bot pushed a commit that referenced this pull request Jul 5, 2024
… level enabled (#40081)

(cherry picked from commit 58f4fc8)

# Conflicts:
#	libbeat/publisher/processing/processors.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.15 Automated backport to the 8.15 branch with mergify backport-v8.14.0 Automated backport with mergify bug 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.

7 participants