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

NLogTraceListener - Reduce overhead by checking LogLevel #2137

Merged
merged 2 commits into from
May 30, 2017

Conversation

snakefoot
Copy link
Contributor

@snakefoot snakefoot commented May 27, 2017

Check the configured Trace-Filter before creating LogEventInfo object.

Check the LogLevel before creating LogEventInfo object.

@codecov
Copy link

codecov bot commented May 27, 2017

Codecov Report

Merging #2137 into master will decrease coverage by <1%.
The diff coverage is 49%.

@@           Coverage Diff           @@
##           master   #2137    +/-   ##
=======================================
- Coverage      81%     81%   -<1%     
=======================================
  Files         291     291            
  Lines       20113   20124    +11     
  Branches     2385    2392     +7     
=======================================
+ Hits        16351   16356     +5     
- Misses       3150    3152     +2     
- Partials      612     616     +4

@snakefoot
Copy link
Contributor Author

snakefoot commented May 28, 2017

Added support for TraceFilter. So resolving #799 and #798

@snakefoot snakefoot force-pushed the NLogTraceListenerCheckLevel branch 9 times, most recently from 7e779c0 to 7cb1975 Compare May 29, 2017 05:10
@304NotModified
Copy link
Member

Is this done or WIP?

@snakefoot snakefoot force-pushed the NLogTraceListenerCheckLevel branch from 7cb1975 to fbf2e8c Compare May 29, 2017 16:58
@snakefoot
Copy link
Contributor Author

Is this done or WIP?

It is done. Just trying to get the Appveyor-build working, but it is failing because of environment-issues (The network path was not found)

Just like this build after merging #2138 :

https://ci.appveyor.com/project/nlog/nlog/build/4.4.5326

@304NotModified
Copy link
Member

It's an unstable test?

@snakefoot
Copy link
Contributor Author

snakefoot commented May 29, 2017

It's an unstable test?

Then all ImpersonatingTargetWrapperTests have suddenly become very unstable, as they are now constantly failing. Or maybe they have become stable ? :)

@304NotModified
Copy link
Member

Lol

@304NotModified
Copy link
Member

Will rebuild master to be sure

@304NotModified
Copy link
Member

Failed also (same issue? - on mobile, hard to check)

https://ci.appveyor.com/project/nlog/nlog/build/4.4.5329

@snakefoot
Copy link
Contributor Author

snakefoot commented May 29, 2017

Failed also (same issue?

Yes always the same 4 tests (Because the test-constructor throws exception)

Guess something has happened with the lookup of the NLogTestUser = "NLogTestUser" on localhost machine (127.0.0.1). Maybe IPv4 vs. IPv6, or reduced rights ?

NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.ImpersonatingWrapperTest [FAIL]
   System.Runtime.InteropServices.COMException : The network path was not found.
   Stack Trace:
      at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
      at System.DirectoryServices.DirectoryEntry.Bind()
      at System.DirectoryServices.DirectoryEntry.RefreshCache()
      at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(314,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.CreateUserIfNotPresent()
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(56,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests..ctor()

NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.ImpersonatingWrapperNegativeTest2 [FAIL]
   System.Runtime.InteropServices.COMException : The network path was not found.
   Stack Trace:
      at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
      at System.DirectoryServices.DirectoryEntry.Bind()
      at System.DirectoryServices.DirectoryEntry.RefreshCache()
      at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(314,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.CreateUserIfNotPresent()
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(56,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests..ctor()

NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.RevertToSelfTest [FAIL]
   System.Runtime.InteropServices.COMException : The network path was not found.
   Stack Trace:
      at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
      at System.DirectoryServices.DirectoryEntry.Bind()
      at System.DirectoryServices.DirectoryEntry.RefreshCache()
      at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(314,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.CreateUserIfNotPresent()
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(56,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests..ctor()

NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.ImpersonatingWrapperNegativeTest [FAIL]
   System.Runtime.InteropServices.COMException : The network path was not found.
   Stack Trace:
      at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
      at System.DirectoryServices.DirectoryEntry.Bind()
      at System.DirectoryServices.DirectoryEntry.RefreshCache()
      at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(314,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests.CreateUserIfNotPresent()
   NLog.UnitTests\Targets\Wrappers\ImpersonatingTargetWrapperTests.cs(56,0): at NLog.UnitTests.Targets.Wrappers.ImpersonatingTargetWrapperTests..ctor()

@snakefoot
Copy link
Contributor Author

snakefoot commented May 29, 2017

Could you rebuild master again ? I have change the hostname from IPv4 127.0.0.1 to Environment.MachineName and now this PR builds. Just want to make sure if the fix is valid, or something has been fixed at appveyor

@304NotModified
Copy link
Member

Queued!

@snakefoot
Copy link
Contributor Author

Queued!

Master still fails, so I guess IPv4 127.0.0.1 is no longer working, and using Environment.MachineName fixes the issue.

@@ -1260,11 +1260,11 @@ private void ConfigFileChanged(object sender, EventArgs args)
/// <summary>
/// Logger cache key.
/// </summary>
internal class LoggerCacheKey : IEquatable<LoggerCacheKey>
internal struct LoggerCacheKey : IEquatable<LoggerCacheKey>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the idea of the struct? AFAIK it's not in line with https://msdn.microsoft.com/en-us/library/ms229017(v=vs.110).aspx ?

Copy link
Contributor Author

@snakefoot snakefoot May 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very much in line:

  • are commonly embedded in other objects (Dictionary key)
  • It logically represents a single value (Its a key)
  • It has an instance size under 16 bytes (check)
  • It is immutable (check)
  • It will not have to be boxed frequently (check)

The reason is to avoid garbage when doing dictionary-lookup, which is right now done for every Trace-event.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right! was reading it incorrectly! 👍

@snakefoot snakefoot force-pushed the NLogTraceListenerCheckLevel branch 2 times, most recently from b166eb4 to ff3d23e Compare May 29, 2017 21:29
@snakefoot snakefoot force-pushed the NLogTraceListenerCheckLevel branch from ff3d23e to 78e7b31 Compare May 29, 2017 21:32
@snakefoot
Copy link
Contributor Author

@304NotModified Squashed after merge with #2140

@304NotModified
Copy link
Member

thanks!

@304NotModified 304NotModified added this to the 4.4.10 milestone May 30, 2017
@304NotModified 304NotModified merged commit 482bbdd into NLog:master May 30, 2017
@snakefoot snakefoot deleted the NLogTraceListenerCheckLevel branch October 10, 2017 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants