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

Martin Kočí commented on MYFACES-3435:
--------------------------------------

> because we can't assume the parent is implemented in some specific way ...
I don't understand that fully: current code uses delegation pattern with 
ArrayList : it already assumes, that ArrayList implements methods in fashion we 
need. But I agree, that delegation pattern is elegant, but inheritance is 
sometimes worth too.

Ad performance improvement: small if views are small and concurrency low. But 
consider this example:

a view with 500 component + 500 concurrent request:
500 component=
with for example 200 leafs = 300 ComponentChildrenList instances + 300 
ArrayList instances
200 leafs (for example UIInput with a validator): 200 _DeltaList instances + 
200 ArrayList instances
= 1000 instances

1000 x 500 concurrent request = 500 000 instances, very short lived, normally 
under 500 ms. Those instances come only from VLD.buildView "pseudo" phase and 
represent very short lived memory representation of components tree (other part 
of code like state saving produce other amount of short lived instances)

Garbage collector must for each instance compute if it is GCable or not (or 
something like that) : it takes very small time in modern JVM but this time is 
noticeable if the amout of object is enormous. 

Then, if user will perform a simple ajax request/response in such view with 500 
components like:
<h:inputText value="#{someBean}" >
<f:ajax render="@this" execute="@this" />

takes the garbage collecting more time that the render response phase. Yes, it 
depends on GC algorithm and normally does not block the http request/response 
thread. I tested it on HotSpot from JVM 6.0.30 with all server-side suitable 
GCs and with JRockit 4.1 Generational Parallel Mark & Sweep. 

But this issue is clearly not very important right now: the performace gain is 
not so big  as in other improvement which I'm going to propose (as String's id 
caching in ComponentTagHandler or isRenderedSet() method)
                
> [perf] _DeltaList: use ArrayList as parent
> ------------------------------------------
>
>                 Key: MYFACES-3435
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3435
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: General
>    Affects Versions: 2.0.12-SNAPSHOT, 2.1.6-SNAPSHOT
>            Reporter: Martin Kočí
>            Assignee: Martin Kočí
>            Priority: Minor
>         Attachments: MYFACES-3435.patch, _ComponentChildrenList2.java
>
>
> Two internal classes _DeltaList in API:
> 1) now use delegation pattern, but are always initialized with an ArrayList 
> instance -> use inheritance and  ArrayList as parent -> improvement in memory 
> area, reduces number of GCed object in one request/response of (_DeltaList 
> instances/2) 
> 2) initialize expected size of _DeltaList (for example, number of validators 
> per one component is perhaps never 10, use: new _DeltaList(5))
> 3) use indexes in 'for' instead of iterator (java.util.RandomAccess) ->  
> improvement in performance

--
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


Reply via email to