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

Sergey Beryozkin commented on CXF-6837:
---------------------------------------

Neal, I think this is a very complex issue, your effort so far has been 
appreciated, but it will take us a bit of time to make it right:
- first the issue we discussed about List A vs List B - the fact CXF can select 
List of A while looking for a provider for List B is a bug - no one has ever 
wanted to register both List of A and List of B providers for the same media 
type before :-), but technically it must work, i.e, the users must not be 
forced to check the list parameters inside isReadable/etc - as you had to do it 
in your custom List test providers. Not sure if RI/ReastEasy do it right, but 
in CXF we need to fix it, i.e, pass Type to handleMapper and ensure that given 
List of A the provider of List B is not selected and vice versa.
Please look at this issue first.

- next, once we have that sorted, we do need to have Type as part of the 
composite cache Key.

- the cache should not have a List of values - only single value, i.e Key - 
Value as opposed to Key - List of Values

- if the provider retrieved from the cache returns false from either isReadable 
or isWritetable - it needs to be evicted

- ProviderCache needs to be initialized at the (field) construction time to 
avoid any thread visibility issues

-  ProviderCache memory management: I'd rather not to depend on SoftReference - 
this is an academic tool really - if we have a case where JVM needs to start 
saving us from going OOM/PermGen issue - then we are already in trouble, the 
system is getting slow. As such I'd prefer a mechanism Alessio any myself 
agreed upon for managing MediaType caches - example, clear the concurrent map 
if it reached a size of 50 - that is a high enough number to support 99% cases 
and the temporary absence of the providers from the cache will be much less 
noticeable compared to a case where GC starts dealing with Soft references.

Thanks


> Add cache for MessageBodyReader/Writer
> --------------------------------------
>
>                 Key: CXF-6837
>                 URL: https://issues.apache.org/jira/browse/CXF-6837
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 3.1.5, 3.0.8
>         Environment: windows
>            Reporter: Neal Hu
>             Fix For: 3.2.0
>
>         Attachments: ListAProvider.java, ListBProvider.java, 
> ProviderCache.java, ProviderFactory.patch, Resource.java, beans.xml, web.xml
>
>
> CXF selects the msgBodyReader/writer in the reader/writer list for every 
> request, which has big impact to the performance. Jersey also has the cache 
> in 
> org.glassfish.jersey.message.internal.MessageBodyFactory._getMessageBodyReader(...).
>  I have tried add the cache for CXF in ProviderFactory and been proved that 
> it has improved 7-8% for json requests in JMeter. Please let me know if you'd 
> like me to add the enhancement for CXF. Thanks. 
> http://cxf.547215.n5.nabble.com/MessageBodyReader-Writer-cache-td5767091.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to