[jboss-jira] [JBoss JIRA] (LOGMGR-157) Provide faster alternative to SimpleDataFormat
Koen Janssens (JIRA)
issues at jboss.org
Wed May 17 04:28:00 EDT 2017
Koen Janssens created LOGMGR-157:
------------------------------------
Summary: Provide faster alternative to SimpleDataFormat
Key: LOGMGR-157
URL: https://issues.jboss.org/browse/LOGMGR-157
Project: JBoss Log Manager
Issue Type: Enhancement
Components: core
Affects Versions: 2.0.6.Final
Reporter: Koen Janssens
Whenever a data or timestamp is included in the logging pattern, SimpleDataFormat is used for formatting. Even with one instance per thread, it is still a heavy beast.
Other logging libraries (like the 15 year old log4j) have 'fast tracks' for known formats such as ISO 8601. These implementations are faster and generate less memory garbage.
During profiling, i discovered that simpledateformat is doing a lot of stuff while printing a date:
at java.lang.Thread.run(Thread.java:748)
at org.jboss.logmanager.handlers.AsyncHandler$AsyncTask.run(AsyncHandler.java:196)
at org.jboss.logmanager.ExtHandler.publish(ExtHandler.java:76)
at org.jboss.logmanager.handlers.WriterHandler.doPublish(WriterHandler.java:46)
at org.jboss.logmanager.ExtFormatter.format(ExtFormatter.java:32)
at org.jboss.logmanager.formatters.MultistepFormatter.format(MultistepFormatter.java:83)
at org.jboss.logmanager.formatters.Formatters$JustifyingFormatStep.render(Formatters.java:224)
at org.jboss.logmanager.formatters.Formatters$5.renderRaw(Formatters.java:389)
at java.text.DateFormat.format(DateFormat.java:345)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:966)
at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1125)
at java.util.Calendar.getDisplayName(Calendar.java:2110)
at java.text.DateFormatSymbols.getInstance(DateFormatSymbols.java:340)
at java.text.DateFormatSymbols.getProviderInstance(DateFormatSymbols.java:364)
at sun.util.locale.provider.DateFormatSymbolsProviderImpl.getInstance(DateFormatSymbolsProviderImpl.java:85)
at java.text.DateFormatSymbols.<init>(DateFormatSymbols.java:145)
at java.text.DateFormatSymbols.initializeData(DateFormatSymbols.java:710)
at sun.util.resources.LocaleData.getDateFormatData(LocaleData.java:127)
at sun.util.resources.LocaleData.getBundle(LocaleData.java:163)
at java.security.AccessController.doPrivileged(Native Method)
at sun.util.resources.LocaleData$1.run(LocaleData.java:163)
at sun.util.resources.LocaleData$1.run(LocaleData.java:167)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:890)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1348)
at java.util.ResourceBundle.checkList(ResourceBundle.java:1400)
at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
at java.util.AbstractCollection.isEmpty(AbstractCollection.java:86)
I have attached a small comparision between simpledateformat performance and log4j ISO formatting performance. It roughly a factor 10 'faster'
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list