myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marius Petoi <marius.pe...@codebeat.ro>
Subject Re: [GSOC] State saving performance improvements in MyFaces 2.0
Date Thu, 15 Jul 2010 13:13:28 GMT
Hi Leonardo,

On Thu, Jul 15, 2010 at 8:38 AM, Leonardo Uribe <lu4242@gmail.com> wrote:

> Hi Marius
>
> 2010/7/13 Marius Petoi <marius.petoi@codebeat.ro>
>
> Hi Leonardo,
>>
>> I corrected the things you required in the JIRA issues. When you have the
>> time, please have a look over them. See inline my comments and questions:
>>
>> On Sun, Jul 11, 2010 at 3:57 AM, Leonardo Uribe <lu4242@gmail.com> wrote:
>>
>>> Hi
>>>
>>> Sorry for the late response, but I was looking other important issues (I
>>> usually review issues with JSR-314 component first). I reviewed your patches
>>> and I committed some of them, and made comments on the others.
>>>
>>>  > On the other hand, regarding serialization vs implements
>>>>> PartialStateHolder,
>>>>> > I've looked for some more externalizable objects: the
>>>>> TagMethodExpression
>>>>> > class is used in the MethodExpressionValueChangeListener, which
>>>>> implements
>>>>> > StateHolder and PartialMethodExpressionValueChangeListener, which
>>>>> implements
>>>>> > PartialStateHolder.
>>>>>
>>>>> > So maybe instead of being Externalizable,
>>>>> > TagMethodExpression should also implement PartialStateHolder. There
>>>>> is a
>>>>> > similar situation with TagValueExpression.
>>>>>
>>>>> I guess - Leonardo should clarify.
>>>>>
>>>>>
>>> To save ValueExpressions, javax.faces.component._DeltaStateHelper uses an
>>> InternalMap, but that one does not take into account PartialStateHolder
>>> interface. So in this case does not apply.
>>>
>>> In MethodExpression it is possible, but to do that, we need to solve two
>>> questions:
>>>
>>> - If we have an immutable object that implements Serializable interface
>>> and a similar one that implements PartialStateHolder, which one is saved /
>>> restored faster? which one has bigger state size? It is worth to implement
>>> PartialStateHolder or keep it as Serializable?. To solve that we need to try
>>> some simple performance tests with possible candidates.
>>>
>>
>> --> Ok. How should I do that. This meaning do you have any suggestions for
>> objects or should I create some mock objects with identical data and then
>> compare the two strategies (in time and state size)?
>>
>
> Yes, it is a simple check but the important here is to know if the
> optimization is valuable or not.
>

--> I designed two simple classes: one implementing Serializable and the
other one implementing PartialStateHolder. The first class contains an
ArrayList of Strings. The other one a _DeltaList of Strings. I serialized
one object of each type to a byte array and measured the time necessary for
the serialization as well as the size of the resulting array. I varied the
number of elements in the list to 100, 1000, 10000. In both cases, the time
and size is proportional to the number of elements. So I will present only
the results for the 10000 elements list: in case serialization is used, the
size of the byte array is 50320 bytes, while for the _DeltaList it is 50055
bytes, so approximately the same. This is when the state consists of the
entire object, so no partial state was taken into consideration. The time
taken for the serialization of the list of 10000 Strings is 47 ms, while the
saveState method of the _DeltaList took 25 ms to execute. So the time taken
for the serialization is about 2 times bigger than in the case of the same
element designed using a PartialStateHolder (_DeltaList). I don't know how
general this example is...basically I compared the serialization of a  Java
object (ArrayList) with the state saving of an object implementing
PartialStateHolder (_DeltaList) and in this case serialization is not
better.

>
>
>>
>>> - Does all methods that store MethodExpression variables (
>>> UICommand.actionExpression) should handle PartialStateHolder interfaces? In
>>> theory yes (I add this support before but then I revert it to the current
>>> behavior because there is no evidence why use PartialStateHolder in this
>>> case), but if we don't expect MethodExpression implementations implements
>>> PartialStateHolder, just let it as is.
>>>
>>
>> --> By this you mean classes with MethodExpressions that use also
>> serialization and not implements PartialStateHolder. I've found a couple of
>> such classes: EventHandler.Listener and LegacyMethodBinding.
>>
>
> Yes. Note here to implement PartialStateHolder the target property that
> will use the MethodExpression should know how to deal with it. But this is
> worth only if the first idea is also true ( implement PartialStateHolder
> instead Serializable ).
>

--> Ok.So there are two classes that do not implement PartialStateHolder,
but have a MethodExpression field, so this is not ok.

>
>
>>
>>> Look this class:
>>> org.apache.myfaces.view.facelets.tag.jsf.core.SetPropertyActionListenerHandler
>>> . It has a inner class called SetPropertyListener that implements
>>> Serializable. javax.faces.component._DeltaList is used to store
>>> FacesListeners and that one handles PartialStateHolder instances. That one
>>> is other valid case.
>>>
>>
>> --> Ok. So should I transform this class into one implementing
>> PartialStateHolder?
>>
>
> In this case you should evaluate if it is worth this class implements
> PartialStateHolder.
>

--> It has two ValueExpression fields. ValueExpressions do not implement
PartialStateHolder. I redesigned the class to implement StateHolder and
written the saveState and restoreState methods. For these two classes, I
measured the time it took to serialize it to a byte array, as well as the
length of the resulting array. Here, like in the case of the list of
Strings, the execution of saveState is slightly faster than the
serialization (15 ms compared to 18 ms). The length of the resulting byte
array is 545 bytes in the case of serialization and 442 bytes in the case of
implements StateHolder. So making this class implement StateHolder would
bring a small improvement.

Regards,
Marius


> regards,
>
> Leonardo
>
>
>>
>>> best regards,
>>>
>>> Leonardo Uribe
>>>
>>
>> Regards,
>> Marius
>>
>>
>

Mime
View raw message