-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Lock contention in LoggerFactory.CreateLogger #83609
Comments
Tagging subscribers to this area: @dotnet/area-extensions-logging Issue DetailsDescriptionThere's lock contention when trying to create a logger using LoggerFactory.CreateLogger. The global lock protects mutating filters and logger providers. This shows up under heavy load. Will fill in more details later, filing this as a reminder.
|
I was curious about this and did a bit of playing around (in advance of the details). ConcurrentDictionary doesn't seem to work because of the other reasons for locking the collection. I tried ReaderWriterLockSlim since, in theory, the locks would be almost entirely reader locks. While I believe this eliminated a lot of the contention (untested) in the single-threaded read path it increased time by about 40%.
Then I tried this approach using a delayed build of a FrozenDictionary: 05d5c63 The (unproven) theory here is:
Because it uses the (more expensive) path to build a read-optimized
I guess we'll see if this makes sense once the problem is explained fully. |
Description
There's lock contention when trying to create a logger using LoggerFactory.CreateLogger. The global lock protects mutating filters and logger providers. This shows up under heavy load.
Will fill in more details later, filing this as a reminder.
The text was updated successfully, but these errors were encountered: