Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NLog FileTarget KeepFileOpen = false by default #1

Closed
snakefoot opened this issue Jun 11, 2018 · 10 comments

Comments

@snakefoot
Copy link

commented Jun 11, 2018

Please update the non-optimal NLog config:

https://github.com/wddpct/LoggingPerformance/blob/0df48dd36e04bf6b9631332e421d4400dd84d1a9/LoggingPerformance.NLog/Program.cs#L25-L29

So it matches Serilog configuration values (Tells NLog NOT to open/close file for each logevent, and only flush every second):

 var fileTarget = new FileTarget 
 { 
     Name = "FileTarget", 
     FileName = "Log.txt",
     KeepFileOpen = true,
     ConcurrentWrites = false,
     AutoFlush = false,
     OpenFileFlushTimeout = 1,
}; 

Also remove the usage of BufferingTargetWrapper as it is used for throttle (Ex limiting the number of http-requests or emails), and not for performance:

https://github.com/wddpct/LoggingPerformance/blob/0df48dd36e04bf6b9631332e421d4400dd84d1a9/LoggingPerformance.NLog/Program.cs#L30-L35

@snakefoot

This comment has been minimized.

Copy link
Author

commented Jun 11, 2018

@wddpct See also my comments here: https://www.darylcumbo.net/serilog-vs-nlog-benchmarks/

@snakefoot

This comment has been minimized.

Copy link
Author

commented Jun 17, 2018

NLog 4.5.7 + LibLog 5.0.2 + Serilog 2.7.1

1 Thread - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog 207781 msgs/sec 4,782mcs 7.553 MBytes 23,1 sec
NLog 273648 msgs/sec 3,621mcs 4.502 MBytes 18,3 sec
NLog Async 407117 msgs/sec 2,399mcs 4.532 MBytes 18,4 sec
2 Threads - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog 276712 msgs/sec 7,162mcs 7.597 MBytes 33,5 sec
NLog 323692 msgs/sec 6,092mcs 4.525 MBytes 30,3 sec
NLog Async 384942 msgs/sec 4,734mcs 4.555 MBytes 18,3 sec
4 Threads - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog 272994 msgs/sec 14,502mcs 7.618 MBytes 65,6 sec
NLog 322585 msgs/sec 12,116mcs 4.539 MBytes 59,0 sec
NLog Async 348736 msgs/sec 10,291mcs 4.571 MBytes 22,7 sec
8 Threads - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog 270654 msgs/sec 29,141mcs 7.656 MBytes 68,7 sec
NLog 320143 msgs/sec 24,618mcs 4.561 MBytes 61,5 sec
NLog Async 284317 msgs/sec 26,216mcs 4.596 MBytes 34,8 sec

NLog Async = AsyncTargetWrapper { TimeToSleepBetweenBatches = 0, OverflowAction = Block, BatchSize = 500 }

P.S. Update the performance tests with release of NLog 4.6: #1 (comment)

@304NotModified

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2018

bump @wddpct

@304NotModified

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2018

@snakefoot maybe we could make a PR for this?

@304NotModified

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2018

I will create a PR

@percentor

This comment has been minimized.

Copy link
Owner

commented Sep 30, 2018

@snakefoot thanks for your advise and sorry for my negligence. I'll check it soon later.

@percentor percentor closed this Sep 30, 2018

@snakefoot

This comment has been minimized.

Copy link
Author

commented Oct 10, 2018

@wddpct Should keep this issue open until the Readme.md shows the updated numbers.

@304NotModified

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2018

Another issue to update the readme is also an option

@snakefoot

This comment has been minimized.

Copy link
Author

commented Oct 10, 2018

Created #3

@snakefoot

This comment has been minimized.

Copy link
Author

commented Mar 24, 2019

NLog 4.6 + LibLog 5.0.4 + Serilog 2.8.0

<ServerGarbageCollection>true</ServerGarbageCollection>

1 Thread - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog NetCore21 191754 msgs/sec 5,180mcs 5.683 MBytes 25,3 sec
Serilog Async NetCore21 323920 msgs/sec 3,059mcs 5.683 MBytes 26,4 sec
NLog NetCore21 324633 msgs/sec 3,051mcs 3.776 MBytes 15,4 sec
NLog Async NetCore21 697145 msgs/sec 1,408mcs 3.777 MBytes 13,8 sec
2 Threads - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog NetCore21 293760 msgs/sec 6,767mcs 5.683 MBytes 28,9 sec
Serilog Async NetCore21 285316 msgs/sec 6,919mcs 5.683 MBytes 41,8 sec
NLog NetCore21 481635 msgs/sec 4,116mcs 3.776 MBytes 19,6 sec
NLog Async NetCore21 680265 msgs/sec 2,906mcs 3.777 MBytes 13,3 sec
4 Threads - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog NetCore21 240422 msgs/sec 16,533mcs 5.683 MBytes 53,6 sec
Serilog Async NetCore21 235433 msgs/sec 16,864mcs 5.683 MBytes 61,0 sec
NLog NetCore21 406490 msgs/sec 9,710mcs 3.776 MBytes 34,7 sec
NLog Async NetCore21 663800 msgs/sec 5,957mcs 3.777 MBytes 12,6 sec
8 Threads - 5.000.000 msgs Throughput Mean Latency Mem Allocated Cpu Time
Serilog NetCore21 219048 msgs/sec 36,382mcs 5.683 MBytes 58,7 sec
Serilog Async NetCore21 222894 msgs/sec 35,563mcs 5.683 MBytes 67,1 sec
NLog NetCore21 404564 msgs/sec 19,581mcs 3.776 MBytes 34,3 sec
NLog Async NetCore21 638214 msgs/sec 12,425mcs 3.777 MBytes 13,0 sec

NLog Async = AsyncTargetWrapper { TimeToSleepBetweenBatches = 0, OverflowAction = Block, BatchSize = 500 }

Serilog Async = WriteTo.Async(a => a.File("Log.txt", buffered: true, flushToDiskInterval: TimeSpan.FromMilliseconds(1000)), blockWhenFull: true);

P.S. LibLog ver. 5.0.5 (and newer) has bug that causes extra overhead for the NLog-provider. See also damianh/LibLog#233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.