You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2018/01/23 15:51:00 UTC

[jira] [Comment Edited] (LOG4J2-2212) Unnecessary contention in CopyOnWriteSortedArrayThreadContextMap

    [ https://issues.apache.org/jira/browse/LOG4J2-2212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16335948#comment-16335948 ] 

Gary Gregory edited comment on LOG4J2-2212 at 1/23/18 3:50 PM:
---------------------------------------------------------------

Hello Daniel and thank you for your report.

Do you have a fix in mind? We could:
 - Pull out the call to {{getIntegerProperty()}} from {{CopyOnWriteSortedArrayThreadContextMap.createStringMap()}} into a {{static}} block. Con: this will not pick up changes during a VM run, so we could also make that an option.
 - What else?

Gary


was (Author: garydgregory):
Hello Daniel and thank you for your report.

Do you have a fix in mind? We could:
- Pull out the call to {{getIntegerProperty()}} from {{CopyOnWriteSortedArrayThreadContextMap.createStringMap()}} into a {{static}} block. Con: this will not pick up changes during a VM run.
- What else?

Gary

> Unnecessary contention in CopyOnWriteSortedArrayThreadContextMap
> ----------------------------------------------------------------
>
>                 Key: LOG4J2-2212
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2212
>             Project: Log4j 2
>          Issue Type: Improvement
>    Affects Versions: 2.10.0
>            Reporter: Daniel Feist
>            Priority: Major
>         Attachments: Screen Shot 2018-01-23 at 14.23.33.png
>
>
> The following method retrieves the value of a system property for each and every map that is created.  While maps are cached/reused where possible via thread local this method is still used a lot in runtime.
> {{protected StringMap createStringMap() {}}
> {{  return new SortedArrayStringMap(PropertiesUtil.getProperties().getIntegerProperty}}{{PROPERTY_NAME_INITIAL_CAPACITY, DEFAULT_INITIAL_CAPACITY));}}
> {{}}}
> Under concurrency, this introduces unnecessary contention due to java.util.Properties monitor in HashTable.contains when retrieving system property, as seen below.
> !Screen Shot 2018-01-23 at 14.23.33.png! 
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)