[
https://issues.apache.org/jira/browse/LOG4J2-2795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051807#comment-17051807
]
Ralph Goers commented on LOG4J2-2795:
-------------------------------------
I did some profiling with YourKit. I created a class that gets a variable
number of Loggers. As the table below shows, the number of Loggers being
retrieved doesn't much matter as it is the cost of initializing Log4j the first
time that incurs the cost.
||Count||2.13.2-SNAPSHOT Elapsed||2.13.2-SNAPSHOT
CollectPlugins||3.0.0-SNAPSHOT
Elpased||3.0.0-SNAPSHOT-CollectPlugins||LOG4J2-2783 Elapsed||LOG4J2-2783
CollectPlugins||
|1|2,654|1,315 ms|864 ms|350 ms|1,414 ms|402 ms|
|100|1,927 ms|969 ms|1,206|375 ms|1,301 ms|313 ms|
|1000|2,339 ms|1,259 ms|1,703|468|1,521 ms|312 ms|
The main difference between 2.13.2 is that the majority of the CPU time in
CollectPlugins is spent in ResolverUtil while in 3.0.0 it is spent in
java.util.ServliceLoader. The change done by LOG4J2-2783 doesn't seem to have
made a large difference, probably since either way the plugin classes are still
being loaded.
As part of the profiling I also noticed that
java.net.InetAddress.getLocalHost() is taking a fair amount of time, mostly in
java.net.Inet6AddressImpl.lookupAllHostHaddr. This makes me wonder if the code
should skip ipV6 if it can.
> Make LogManager/LoggerContext creation time reasonable
> ------------------------------------------------------
>
> Key: LOG4J2-2795
> URL: https://issues.apache.org/jira/browse/LOG4J2-2795
> Project: Log4j 2
> Issue Type: Task
> Components: Core
> Affects Versions: 2.13.0
> Reporter: Romain Manni-Bucau
> Priority: Major
> Attachments: log4j2.png
>
>
> Currently (2.13), LogManager.getLogger("xxx") takes ~600ms on a cold JVM by
> itself.
> For a logging framework it is likely way too much (by comparison a CDI test
> with classpath scanning takes ~50ms).
>
> This ticket is about trying to be faster (maybe by removing java
> serialization usage and reducing registry usage + reflection of plugins by
> generating java code?).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)