[logback-dev] [JIRA] Commented: (LBCLASSIC-36) Synchronization of SimpleDateFormat object in DateConverter

Joern Huxhorn (JIRA) noreply-jira at qos.ch
Wed Jun 17 14:01:10 CEST 2009


    [ http://jira.qos.ch/browse/LBCLASSIC-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11199#action_11199 ] 

Joern Huxhorn commented on LBCLASSIC-36:
----------------------------------------

Well, the above test looks like this from within IDEA:
Raw - JDK: 4992 ns Joda: 5533 ns - Difference: -10.837339%
Synchronized DateFormat: 0.4826 seconds
Unsynchronized DateFormat: 1.7025 seconds
ThreadLocal DateFormat: 0.1858 seconds
Joda DateTimeFormatter: 0.0908 seconds

And values are fluctuating quite a bit on reruns, that's why I'm asking...

Raw - JDK: 4864 ns Joda: 5348 ns - Difference: -9.950658%
Synchronized DateFormat: 0.4799 seconds
Unsynchronized DateFormat: 1.5900 seconds
ThreadLocal DateFormat: 0.1806 seconds
Joda DateTimeFormatter: 0.1252 seconds

Raw - JDK: 5030 ns Joda: 5719 ns - Difference: -13.697813%
Synchronized DateFormat: 0.4813 seconds
Unsynchronized DateFormat: 1.6982 seconds
ThreadLocal DateFormat: 0.1870 seconds
Joda DateTimeFormatter: 0.0838 seconds

...

> Synchronization of SimpleDateFormat object in DateConverter
> -----------------------------------------------------------
>
>                 Key: LBCLASSIC-36
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-36
>             Project: logback-classic
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: unspecified
>         Environment: Operating System: All
> Platform: All
>            Reporter: Anders Hammar
>            Assignee: Ceki Gulcu
>         Attachments: DateConverter_patch.java, DateFormatPerfTest.java, dateformattest.zip, DoubleCheckedLocking.patch
>
>
> According to the API documentation of SimpleDateFormat, date formats are not synchronized and it is recommended to create separate format instances for each thread.
> However, a possibly simpler (mer efficient) solution would be to synchronize on the SimpleDateFormat object in the convert() method to prevent two threads to access it concurrently.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the logback-dev mailing list