Closed
Conversation
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 apache#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 apache#3399
Author
|
Some additional info: here are the timings for running Infinispan's core testsuite on my laptop:
Any difference is just attributable to noise. |
vy
reviewed
Jan 31, 2025
| @SuppressWarnings("unchecked") | ||
| private void processQueue() { | ||
| for (WeakValue<V> v = (WeakValue<V>) queue.poll(); v != null; v = (WeakValue<V>) queue.poll()) { | ||
| map.remove(v.getKey()); |
Member
There was a problem hiding this comment.
@tristantarrant, methods accessed while holding a read-lock (e.g., getLogger()) might end up mutating the map, which is not thread-safe. Am I mistaken?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR includes and supersedes #3418
It fixes the issue of dangling
WeakReferences, which are not being replaced causing excessive write lock acquisition by introducing a (very limited)WeakValuesHashMapto store thename -> loggermappings.I've tested this successfully with Infinispan's core testsuite.
I've kept @ppkarwasz 's original commit and mine separate, but they should really be squashed together.
Closes #3399