Log4net became very slow with subscriber location information after updating Windows 10 Fall Creators (1709)

I knew that the log4net documentation indicates that recording caller location information can be very slow and should not be used unless it affects software performance.

And until the update for Windows 10 Fall Creator developers was like that. Here is a small project example.

app.config

<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" /> </configSections> <log4net> <appender name="DefaultAppender" type="log4net.Appender.RollingFileAppender"> <file value="logging.log" /> <encoding value="utf-8" /> <appendToFile value="true" /> <layout type="log4net.Layout.PatternLayout"> <!--without caller location information--> <!--<conversionPattern value="%d | %-5p | %t | %m%n" />--> <!--with caller location information--> <conversionPattern value="%d | %-5p | %t | %C.%M:%L | %m%n" /> </layout> </appender> <root> <level value="All" /> <appender-ref ref="DefaultAppender" /> </root> </log4net> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> </configuration> 

Program.cs

 using System; using System.Diagnostics; using log4net; namespace Log4Net.CSharp { class Program { private static readonly ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); static void Main(string[] args) { LoggingTest(1000); Console.ReadKey(); } private static void LoggingTest(int iterations) { Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < iterations; i++) { Log.Info("Some info logging."); } Console.WriteLine($"Logging of {iterations} iterations took: {sw.ElapsedMilliseconds} ms."); } } } 

After updating Windows (1709), performance with caller location information, such as% C% M% L, is about 100 times worse than without. The problem, of course, is related to the update, because after the rollback, the performance returns to its normal state.

Results before upgrading Windows (1709)

w / o% C% M% L: Recording 1000 iterations took: 18 ms.
w% C% M% L: Recording 1000 iterations took: 81 ms.

Results after updating Windows (1709)

w / o% C% M% L: Recording 1000 iterations took: 14 ms.
w% C% M% L: Recording 1000 iterations took: 1502 ms.

Can someone confirm this problem or have an idea what is happening?

I am grateful for any advice on debugging / fixing it. Thanks in advance!

+3
source share
1 answer

Microsoft updated the article mentioned a few days ago ( https://support.microsoft.com/en-us/help/4057154/performance-of-system-diagnostics-stackframe-degrades-in-windows-10-17 ), and, as Giza says in a comment, the new update ( https://support.microsoft.com/en-us/help/4058258 ) solves the problem regardless of the .NET Framework used.

+1
source

Source: https://habr.com/ru/post/1274760/


All Articles