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

Minimize lock usage in InternalLoggerRegistry #3418

Open
wants to merge 4 commits into
base: 2.24.x
Choose a base branch
from

Conversation

ppkarwasz
Copy link
Contributor

It has been reported that holding a lock on InternalLoggerRegistry during the creation of a logger can cause performance loss and deadlocks. The logger constructor can trigger property lookups and other pluggable operations, we don't entirely control. The fix to #3252 only covered one of these cases.

This change moves the instantiation of new Loggers outside the write lock. While in some cases, this will cause multiple instantiations of loggers with the same parameters, all such loggers are functionally equivalent. On the other hand, the change allows the creation of different loggers in parallel.

Closes #3399

It has been reported that holding a lock on `InternalLoggerRegistry` during the creation of a logger can cause performance loss and deadlocks. The logger constructor can trigger property lookups and other pluggable operations, we don't entirely control. The fix to #3252 only covered one of these cases.

This change moves the instantiation of new `Logger`s outside the write lock. While in some cases, this will cause multiple instantiations of loggers with the same parameters, all such loggers are functionally equivalent. On the other hand, the change allows the creation of different loggers in parallel.

Closes #3399
Copy link
Contributor Author

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

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

@vy, looks good to me!

@vy
Copy link
Member

vy commented Feb 4, 2025

Tried implementing a test1 where ILR read and write methods are stressed using multiple threads – see the attachment. Even after several different configuration attempts – increased test duration, logger name cardinality, played around with ro-vs-rw operation ratios, etc. – had no luck.

1 InternalLoggerRegistryConcurrencyTest.java.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants