RFR: 8307535: java.util.logging.Handlers should be more VirtualThread friendly

David M. Lloyd duke at openjdk.org
Fri May 5 14:53:17 UTC 2023


On Fri, 5 May 2023 13:43:43 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> Several Handlers class use monitors to synchronize when formatting / publishing LogRecords.
> When logging within a VirtualThread, holding this monitor can cause the carrier thread to be pinned.
> Handlers could use jdk.internal.misc.InternalLock, in a similar way to some java.io classes (such as PrintStream) to avoid pinning the carrier thread.

I'm just an author, not a reviewer, but I'm also the creator of the `jboss-logmanager` project, which is based heavily on subclassing many of the `java.util.logging` APIs.

One thing I noticed is that the setters for filter/formatter/level etc. still use synchronized; I guess that user-based subclasses could still depend on this, and handlers which use the internal lock don't care. But if this is the case, then in the internal lock case, synchronization isn't actually needed at all, so this could be tested for and optimized in this case. Otherwise it might be useful to leave a comment that explains the situation, since it's not obvious?

I didn't see anything else that looked like a red flag with this change so it's a non-binding +1 from me, for whatever it is worth, other than the above observation.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13832#issuecomment-1536377319


More information about the core-libs-dev mailing list