agentgt commented on issue #1532:
URL:
https://github.com/apache/logging-log4j2/issues/1532#issuecomment-1751280547
Hey guys I have been working on my own SLF4J adapter that is for Java 21. I
was benchmarking against log4j2 and logback noticed when I load up like 10,000
vthreads log4j2 crushes in these scenarios (about half the time) and appears
because it pins the threads and thus a single writer scenario happens (which is
fast).
I made sure this was the case as I disabled ThreadLocals and set garbage
collection to epsilon etc (e.g. no gc).
However the benchmark is flawed because:
* I'm only testing System.out piped to a file
* The only IO that is happening is obviously logging
The code seems to be in `OutputStreamManager` which I'm sure @jvz is aware
of:
```
synchronized (this) {
ByteBufferDestinationHelper.writeToUnsynchronized(data, this);
}
```
As soon as I did similar my library performed similar to log4j2.
I'm just letting you know because there maybe some that actually want the
above behavior (e.g. pinning the thread)!
I'm trying to decide how to construct a more realistic test of virtual
threads hitting other IO like a database and then logging to how bad
`synchronized` is for log4j2.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]