You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "Bryant Luk (JIRA)" <ji...@apache.org> on 2009/09/09 19:11:57 UTC

[jira] Created: (WINK-175) Change ProvidersRegistry MediaTypeMap to allow gets to be faster

Change ProvidersRegistry MediaTypeMap to allow gets to be faster
----------------------------------------------------------------

                 Key: WINK-175
                 URL: https://issues.apache.org/jira/browse/WINK-175
             Project: Wink
          Issue Type: Improvement
          Components: Common
    Affects Versions: 0.2
            Reporter: Bryant Luk
             Fix For: 0.2


Doug Larson did some more profiling and pointed out that on the ProvidersRegistry MediaTypeMap, using a ConcurrentHashMap over SimpleConcurrentMap actually improves performance by a few percentage points.

{code}
        private final SimpleMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>> providersCache =
                                                                                                                          new SimpleConcurrentMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>>(); ;
{code}

While the cache keys (Class<?>) would not be WeakReferences, the values would still be SoftReferences.

Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (WINK-175) Change ProvidersRegistry MediaTypeMap to allow gets to be faster

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryant Luk closed WINK-175.
---------------------------


> Change ProvidersRegistry MediaTypeMap to allow gets to be faster
> ----------------------------------------------------------------
>
>                 Key: WINK-175
>                 URL: https://issues.apache.org/jira/browse/WINK-175
>             Project: Wink
>          Issue Type: Improvement
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>             Fix For: 0.2
>
>
> Doug Larson did some more profiling and pointed out that on the ProvidersRegistry MediaTypeMap, using a ConcurrentHashMap over SimpleConcurrentMap actually improves performance by a few percentage points.
> {code}
>         private final SimpleMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>> providersCache =
>                                                                                                                           new SimpleConcurrentMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>>(); ;
> {code}
> While the cache keys (Class<?>) would not be WeakReferences, the values would still be SoftReferences.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-175) Change ProvidersRegistry MediaTypeMap to allow gets to be faster

Posted by "Michael Elman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753437#action_12753437 ] 

Michael Elman commented on WINK-175:
------------------------------------

If I remember correctly SimpleConcurrentMap doesn't make any cache/soft/weak/references. It simply wraps the provided map with ReentrantReadWriteLock.
It's SoftConcurrentMap that wraps WeakHashMap.

Does Doug Larson makes multi-threaded tests?
SimpleConcurrentMap should have a better performance for multiple threads, since it locks get with a read lock, which allows multiple threads to read from a map simultaneously.

> Change ProvidersRegistry MediaTypeMap to allow gets to be faster
> ----------------------------------------------------------------
>
>                 Key: WINK-175
>                 URL: https://issues.apache.org/jira/browse/WINK-175
>             Project: Wink
>          Issue Type: Improvement
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>             Fix For: 0.2
>
>
> Doug Larson did some more profiling and pointed out that on the ProvidersRegistry MediaTypeMap, using a ConcurrentHashMap over SimpleConcurrentMap actually improves performance by a few percentage points.
> {code}
>         private final SimpleMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>> providersCache =
>                                                                                                                           new SimpleConcurrentMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>>(); ;
> {code}
> While the cache keys (Class<?>) would not be WeakReferences, the values would still be SoftReferences.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WINK-175) Change ProvidersRegistry MediaTypeMap to allow gets to be faster

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryant Luk resolved WINK-175.
-----------------------------

    Resolution: Fixed
      Assignee: Bryant Luk

I made the change since the performance looked better.

Out of personal curiosity, I did some quick Googling for when ConcurrentHashMap would lock.  One of the better articles I found is: http://www.ibm.com/developerworks/java/library/j-jtp08223/index.html?S_TACT=105AGX02&S_CMP=EDU which explains that the get() operation can often proceed without locking at the Java level.  It's an apparently deep understanding of the Java memory model that makes it possible.

> Change ProvidersRegistry MediaTypeMap to allow gets to be faster
> ----------------------------------------------------------------
>
>                 Key: WINK-175
>                 URL: https://issues.apache.org/jira/browse/WINK-175
>             Project: Wink
>          Issue Type: Improvement
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>            Assignee: Bryant Luk
>             Fix For: 0.2
>
>
> Doug Larson did some more profiling and pointed out that on the ProvidersRegistry MediaTypeMap, using a ConcurrentHashMap over SimpleConcurrentMap actually improves performance by a few percentage points.
> {code}
>         private final SimpleMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>> providersCache =
>                                                                                                                           new SimpleConcurrentMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>>(); ;
> {code}
> While the cache keys (Class<?>) would not be WeakReferences, the values would still be SoftReferences.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-175) Change ProvidersRegistry MediaTypeMap to allow gets to be faster

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753607#action_12753607 ] 

Bryant Luk commented on WINK-175:
---------------------------------

Yes, Doug has multiple threads running (4-CPU machine and 15 concurrent client threads).

ConcurrentHashMap is able to perform the get()s without needing to acquire a lock.   The (what I believe) common usage scenario that we're looking at is an application that reads/writes the same type of data repeatedly.

> Change ProvidersRegistry MediaTypeMap to allow gets to be faster
> ----------------------------------------------------------------
>
>                 Key: WINK-175
>                 URL: https://issues.apache.org/jira/browse/WINK-175
>             Project: Wink
>          Issue Type: Improvement
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>             Fix For: 0.2
>
>
> Doug Larson did some more profiling and pointed out that on the ProvidersRegistry MediaTypeMap, using a ConcurrentHashMap over SimpleConcurrentMap actually improves performance by a few percentage points.
> {code}
>         private final SimpleMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>> providersCache =
>                                                                                                                           new SimpleConcurrentMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>>(); ;
> {code}
> While the cache keys (Class<?>) would not be WeakReferences, the values would still be SoftReferences.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-175) Change ProvidersRegistry MediaTypeMap to allow gets to be faster

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753948#action_12753948 ] 

Hudson commented on WINK-175:
-----------------------------

Integrated in Wink-Trunk-JDK1.5 #145 (See [http://hudson.zones.apache.org/hudson/job/Wink-Trunk-JDK1.5/145/])
    Update ProvidersRegistry with ConcurrentHashMap

See []


> Change ProvidersRegistry MediaTypeMap to allow gets to be faster
> ----------------------------------------------------------------
>
>                 Key: WINK-175
>                 URL: https://issues.apache.org/jira/browse/WINK-175
>             Project: Wink
>          Issue Type: Improvement
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>             Fix For: 0.2
>
>
> Doug Larson did some more profiling and pointed out that on the ProvidersRegistry MediaTypeMap, using a ConcurrentHashMap over SimpleConcurrentMap actually improves performance by a few percentage points.
> {code}
>         private final SimpleMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>> providersCache =
>                                                                                                                           new SimpleConcurrentMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>>(); ;
> {code}
> While the cache keys (Class<?>) would not be WeakReferences, the values would still be SoftReferences.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WINK-175) Change ProvidersRegistry MediaTypeMap to allow gets to be faster

Posted by "Michael Elman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753612#action_12753612 ] 

Michael Elman commented on WINK-175:
------------------------------------

AFAIK ConcurrentHashMap uses ReentrantLock and not ReentrantReadWriteLock.

Anyway, if you think that the tests are good and ConcurrentHashMap has better performance over SimpleConcurrentMap, feel free to change it.


> Change ProvidersRegistry MediaTypeMap to allow gets to be faster
> ----------------------------------------------------------------
>
>                 Key: WINK-175
>                 URL: https://issues.apache.org/jira/browse/WINK-175
>             Project: Wink
>          Issue Type: Improvement
>          Components: Common
>    Affects Versions: 0.2
>            Reporter: Bryant Luk
>             Fix For: 0.2
>
>
> Doug Larson did some more profiling and pointed out that on the ProvidersRegistry MediaTypeMap, using a ConcurrentHashMap over SimpleConcurrentMap actually improves performance by a few percentage points.
> {code}
>         private final SimpleMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>> providersCache =
>                                                                                                                           new SimpleConcurrentMap<Class<?>, SoftReference<SimpleMap<MediaType, List<ObjectFactory<T>>>>>(); ;
> {code}
> While the cache keys (Class<?>) would not be WeakReferences, the values would still be SoftReferences.
> Thoughts?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.