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

Many memory allocations with multiple output plugins #15882

Open
LarsStegman opened this issue Sep 14, 2024 · 0 comments · May be fixed by #15883
Open

Many memory allocations with multiple output plugins #15882

LarsStegman opened this issue Sep 14, 2024 · 0 comments · May be fixed by #15883
Labels
bug unexpected problem or unintended behavior

Comments

@LarsStegman
Copy link
Contributor

Relevant telegraf.conf

[[outputs.influxdb_v2]]
  tagpass = {"batch"="0"}
  ...
[[outputs.influxdb_v2]]
  tagpass = {"batch"="1"}
  ...
[[outputs.influxdb_v2]]
  tagpass = {"batch"="2"}
  ...
...

# Reads and parses about 40kb of data at 50Hz
[[inputs.socket_listener]]
  ...


### Logs from Telegraf

```text
No relevant entries

System info

Telegraf 1.31.2, Ubuntu 24.02

Docker

No response

Steps to reproduce

  1. Receive 40KB of data at 50Hz
  2. Telegraf will not be able to keep up and will start dropping UDP packets

...

Expected behavior

Telegraf is able to keep up with the amount of data.

Actual behavior

Telegraf drops several of the UDP packets because it is waiting on GOGC.

I profiled Telegraf and noticed that about 28% of all allocations were done by the metric.Copy function called from agent.runOutputs at

output.AddMetric(metric.Copy())
. This seemed strange to me because each metric should only be output to 1 output plugin. Indeed, when I move the Copy call over to the runningOutput.AddMetric after the metric is filtered out by a filter, the amount of allocations drops drastically and performance increases. (this is a hack and should be implemented in a different way!)

I think it might be worth it to change this mechanism and only copy a metric when an output will accept a metric, i.e. it is not filtered by a Filter.

Additional info

heap
profile

profiles.zip

@LarsStegman LarsStegman added the bug unexpected problem or unintended behavior label Sep 14, 2024
@LarsStegman LarsStegman linked a pull request Sep 14, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant