[
https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280786#comment-13280786
]
Leonardo Uribe commented on MYFACES-3549:
-----------------------------------------
The problem here is in this part we are trying to balance two aspects of
performance: speed and memory.
In this line of _PropertyDescriptorHolder:
private final Method _readMethod;
The "final" modifier is critical from concurrency perspective. It means once it
is initialized it does not change but the most important part is all threads
sharing this object will have the same value.
With the SoftReference:
private Reference<Method> _readMethodRef;
If multiple threads tries to access the reference at the same time and it was
already collected by the GC, they will make many calls to get the method and
the problem described in MYFACES-3262 occurs again.
So, at the end we have a slowdown of the server in saturation point, but now
the concurrency effect is added. Which one is better? difficult to say it,
because it is an exceptional case, right?
What I know is the current solution is a lot faster in typical situations. Note
this part of the code is very sensitive to changes.
I know what you are proposing is correct from memory perspective, but the
current solution is better from both speed and memory perspective. I'll attach
a patch with the solution I'm thinking about to prevent the effect when the
server is running out of memory. In that way, you'll see how it works.
There is another problem with the previous solution. Suppose you are sharing
myfaces jars for two web application in the same container and one uses
myfavoritejsflib-1.0.jar and the other one myfavoritejsflib-1.1.jar . Between
these versions, there was a change and somebody added some properties to a
component. Then, the application running myfavoritejsflib-1.0.jar load a page
containing that component first and later the other application. Since that map
is shared by both, the first one will have the table for
myfavoritejsflib-1.0.jar, which means it will not call the method on the
component instance and it will use the attribute map. The user will not notice
anything, but that should not happen. The new code fix that, holding different
tables per ClassLoader, so two applications will not share the same table
unless they share the same ClassLoader, which means, both should have the same
dependencies.
> Alternative solution to bugs MYFACES-3262 and MYFACES-3510
> ----------------------------------------------------------
>
> Key: MYFACES-3549
> URL: https://issues.apache.org/jira/browse/MYFACES-3549
> Project: MyFaces Core
> Issue Type: Improvement
> Affects Versions: 2.1.7
> Reporter: Jesús Pérez Alcaide (ISBAN)
> Attachments: AAA_patch_PropertyDescriptor_MyFaces217.jar,
> MyFaces3262_PropertyDescriptorHolder.patch,
> MyFaces3510_AbstractFacesInitializer.patch,
> MyFaces3510_ComponentAttributesMap.patch
>
>
> I would like to propose an alternative solution to bugs MYFACES-3262 and
> MYFACES-3510, which consists in rollback the changes made in MYFACES-3510 and
> modify the solution given in MYFACES-3262 by adding a soft reference to the
> methods held in the class _PropertyDescriptorHolder.
> This alternative solution fixes MYFACES-3262 and avoids the performance loss
> caused by MYFACES-3510.
> More information in this email:
> http://markmail.org/message/xh66wlte6luqn63d
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira