serilog / serilog-sinks-periodicbatching

Infrastructure for Serilog sinks that process events in batches.
Apache License 2.0
70 stars 29 forks source link

High CPU usage #43

Closed mniak closed 4 years ago

mniak commented 4 years ago

When I use this sink, the CPU consumption increases significantly even without any logs being recorded.

I also found a report of a developer having the same problem: https://github.com/serilog/serilog-sinks-elasticsearch/issues/137

Framework: .NET Core 2.2

nblumhardt commented 4 years ago

Hi @mniak - thanks for reaching out.

Can you please "break" your debugger when the problem occurs, and post some details of what threads are in the Serilog assemblies at that point? Would be great to track this down, if it's a Serilog issue 👍

Your logger configuration (code and/or config) would also help identify/rule out some possibilities.

Thanks!

mniak commented 4 years ago

Hi, I finally found the problem, and it is not a bug in the Serilog code.

I will describe it here to help people that can have this same behavior: I was providing period with TimeSpan.Zero by accident.

mniak commented 4 years ago

It is also worth mention that the code in this repository already has a check for TimeSpan.Zero since PR #34. The reason that my code did not report this is because i was using Serilog.Sinks.PeriodicBatching@2.1.1 as a transitive dependency of Serilog.Sinks.AzureEventHub@4.1.0

mniak commented 4 years ago

The only thing that still does not make sense for me is why the timer is still on even while there is no remaining messages to be sent in the batch?

I will open a different issue to address this.

Thanks.