Sorry, forgot to attach the file.

 

Best Regards,
Alexey Polyakov 
Software Engineer




EPAM Systems
Ryazan office, Russia 
GMT+3 (Standard) / GMT+3 (Daylight)

Office phone:       +7 (4912) 935-733, ext. 46229

Mobile phone:       +7 (910) 509-96-37

E-mail:                  <mailto:alexey_polya...@epam.com>
alexey_polya...@epam.com

Skype:                  <skype:Aleksey__Polyakov?add> Aleksey__Polyakov (
<skype:Aleksey__Polyakov?chat> chat or  <skype:Aleksey__Polyakov?call> call)

 

From: Alexey Polyakov [mailto:alexey_polya...@epam.com] 
Sent: Sunday, June 01, 2014 6:49 PM
To: log4net-dev@logging.apache.org
Cc: log4net-u...@logging.apache.org
Subject: RE: log4net 1.2.13 performance issues (found the exact line that
causes the problem)

 

Hello,

 

I have encountered a heavy drop in performance after migration from log4net
1.2.10 to 1.2.13. My research pointed out to the commit #1511303 and
specifically to the line 1340:

 
eventProperties[UserNameProperty] = UserName;

 

I attach the test harness I was using - without this line the logging is
done in about 2 seconds, and after this line is added - it takes 24 seconds.

 

Can you please give any comment on what is going on? (is it safe to just
remove this line and use patched version in production environment, or may
be there is already a work in progress and a better solution)/

 

Best Regards,
Alexey Polyakov 
Software Engineer


EPAM Systems
Ryazan office, Russia 
GMT+3 (Standard) / GMT+3 (Daylight)

Office phone:       +7 (4912) 935-733, ext. 46229

Mobile phone:       +7 (910) 509-96-37

E-mail:                  <mailto:alexey_polya...@epam.com>
alexey_polya...@epam.com

Skype:                  <skype:Aleksey__Polyakov?add> Aleksey__Polyakov (
<skype:Aleksey__Polyakov?chat> chat or  <skype:Aleksey__Polyakov?call> call)

 

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Layout;
using log4net.Repository.Hierarchy;

namespace LoadTestApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Setup();
            
            var logger = LogManager.GetLogger(typeof(Program));

            const int requests = 100000;
            const int times = 1;

            log4net.LogicalThreadContext.Properties["callId"] = Guid.NewGuid();
            for (var j = 0; j < times; j++)
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                Parallel.For(0, requests, (i, state) =>
                                          {
                                              logger.DebugFormat("logging 
request {0}", i);
                                          });

                stopwatch.Stop();
                Console.WriteLine("Processing {0} requests took {1}", requests, 
stopwatch.Elapsed);
            }
        }
        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();
            patternLayout.ConversionPattern = "%date [%thread, 
%property{callId}] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();
            roller.AppendToFile = true;
            roller.CountDirection = 0;
            roller.DatePattern = "yyyyMMdd";
            roller.Encoding = new UTF8Encoding();
            roller.File = @"Logs\EventLog.txt";
            roller.Layout = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize = "1GB";
            roller.RollingStyle = RollingFileAppender.RollingMode.Composite;
            roller.StaticLogFileName = false;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;
        }
    }
}

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to