U4-2037 - AsynchronousRollingFileAppender keeps a thread alive at all times, we should only have a thread run when necessary

Created by Shannon Deminick 03 Apr 2013, 02:03:57 Updated by Nicholas Westby 30 Jan 2016, 22:13:54

Relates to: U4-6063

Relates to: U4-7865

Currently the way that AsynchronousRollingFileAppender works is that we spawn a new thread to write whenenver we detect that the buffer is written to. We don't really need to have a separate dedicated thread for this and instead can do what we do with the Examine core and:

  • Add the item to the buffer
  • Call a method to ensure the buffer is written
  • This method spawns a thread to write the buffer if there's not already a thread running, if the thread is already running it will continue to process the information written to the buffer until the buffer is empty.

When running a performance profiler on Umbraco, the AppendLoggingEvents shows up as a hot spot since it is running in an infinite loop.

Comments

Andy Butland 27 Jun 2015, 08:18:25

I've posted an issue on our that might be related to this: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/66920-investigating-memory-issue-reporting-that-finalizer-thread-blocked As I say there though, not clear if this is a real problem, or just something that triggers a false report of a concern in the analysis.


Shannon Deminick 01 Jul 2015, 11:55:10

I've updated the default logging with 7.3 to use a newer async mechanism, you can see the commit here:

44943e367f76aa889a850e352dc93bc7d13712ea

Of course the old logging format still works but we'll ship with the new logging format which is based on this project: https://github.com/cjbhaines/Log4Net.Async ... which is based on the original implementation of AsynchronousRollingFileAppender, but the new way uses ParallelForwardingAppender which uses a BlockingCollection to perform the logging which is much nicer.


Priority: Minor

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.3.0

Sprint:

Story Points:

Cycle: