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

Update NLogLoggerFactory.cs #405

Closed
wants to merge 1 commit into from
Closed

Update NLogLoggerFactory.cs #405

wants to merge 1 commit into from

Conversation

akovac35
Copy link

Added double-checked locking to minimize locking performance impact.

Added double-checked locking to minimize locking performance impact.
@304NotModified
Copy link
Member

@snakefoot looks fine to me, agree?

@304NotModified 304NotModified added this to the 1.6.2 milestone Mar 15, 2020
@codecov-io
Copy link

codecov-io commented Mar 15, 2020

Codecov Report

Merging #405 into master will decrease coverage by 0.02%.
The diff coverage is 90%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #405      +/-   ##
========================================
- Coverage   82.02%    82%   -0.03%     
========================================
  Files          12     12              
  Lines        1174   1178       +4     
  Branches      193    194       +1     
========================================
+ Hits          963    966       +3     
  Misses        141    141              
- Partials       70     71       +1
Impacted Files Coverage Δ
...og.Extensions.Logging/Logging/NLogLoggerFactory.cs 86.84% <90%> (-1.4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d78f80d...5e676ab. Read the comment docs.

@snakefoot
Copy link
Contributor

snakefoot commented Mar 16, 2020

@304NotModified looks fine to me, agree?

Not sure I understand the requirement for this change. @akovac35 Are you actually using this class? and where do you have performance issues?

Instead of racing around in an unsafe container without underwear, then I would probably do one of the following:

But I'm curious why something that works for Microsoft Extension Logging is not good enough for NLog.Extensions.Logging. So curious where you experience performance issues? (Especially since NLog LoggerFactory is not used by default)

@akovac35
Copy link
Author

Well in this case there is simply no need to do any locking for the reading part. If an object already exists, there is no need to lock anything and simply return the object, if it doesn't - then do the locking and check again if the object was inserted just before the lock occurred. The Microsoft's implementation should be fixed as well, there is much needless locking on many places in the overall .NET Core implementation.

So to promote a general practice, this pull request should be excepted.

@snakefoot
Copy link
Contributor

snakefoot commented Mar 16, 2020 via email

@akovac35
Copy link
Author

Ok, I will try with them first. I don't see what could be unsafe about the proposed change though. Is this a general concern over design ambiguity originating from MS implementation?

@snakefoot
Copy link
Contributor

snakefoot commented Mar 16, 2020 via email

@akovac35
Copy link
Author

You are correct. I will cancel this pull request.

@akovac35 akovac35 closed this Mar 16, 2020
@akovac35 akovac35 deleted the patch-1 branch March 16, 2020 13:30
@snakefoot snakefoot removed this from the 1.6.2 milestone Mar 16, 2020
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.

4 participants