Re: Performance Enhancements

1 message Options
Embed this post
Permalink
Jake Milnes

Re: Performance Enhancements

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hello,

For those interested, here is the patch for the below mentioned items.

NLog-1.0\src\NLog\Targets\Wrappers\AsyncTargetWrapper.cs
208c208
<                     } while (_flushAll);
---
>                     } while (_flushAll || RequestQueue.RequestCount > BatchSize);

NLog-1.0\src\NLog\Win32\Targets\MSMQ.cs
189a190,224

>         /// Writes the specified array of logging events to a queue specified in the Queue
>         /// parameter.
>         /// </summary>
>         /// <param name="logEvents">An array of <see cref="LogEventInfo "/> objects.</param>
>         /// <remarks>
>         /// This function override increases performance of batches by not having to
>         /// check the queues existence and connect to it for each logEvent.
>         /// </remarks>
>         protected internal override void Write(LogEventInfo[] logEvents)
>         {
>             if (_queue == null)
>                 return;
>
>             if (!MessageQueue.Exists(Queue))
>             {
>                 if (CreateQueueIfNotExists)
>                     MessageQueue.Create(Queue);
>                 else
>                     return;
>             }
>
>             using (MessageQueue mq = new MessageQueue(Queue))
>             {
>                 foreach (LogEventInfo logEvent in logEvents)
>                 {
>                     Message msg = PrepareMessage(logEvent);
>                     if (msg != null)
>                     {
>                         mq.Send(msg);
>                     }
>                 }
>             }
>         }
>
>         /// <summary>

Thanks,

Jake Milnes


----- Original Message ----
From: Jake Milnes <[hidden email]>
To: [hidden email]
Sent: Tuesday, June 3, 2008 10:24:25 AM
Subject: Performance Enhancements

Hello,

For a new project of ours, we looked at several different logging frameworks and decided on using NLog.  Thanks for making NLog great!

We made a couple of minor performance enhancements to speed up our particular usage of NLog.  I would like to find out  if others are interested in these performance enhancements or if anyone sees any problems with these:

1.  Added Write(LogEvent[]) override to the MSMQ class.  This removes the overhead of checking for the queue's existence, connecting and disconnecting for every insert if you are batching the inserts (e.g. through a buffered wrapper or async wrapper).
2.  Updated the Async wrapper class so that it doesn't go back to sleep after processing a callback if there are still enough items on the queue for a full batch.

We did some decent performance testing benchmarks before and after, and saw significant gains in the applicable test cases (by roughly a factor of 5).  I can provide more detail on the performance test if someone is truly interested (the test results currently are not written up for release).

Thanks,

Jake Milnes

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list