Return-Path: X-Original-To: apmail-myfaces-users-archive@www.apache.org Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EC22F11976 for ; Wed, 20 Aug 2014 07:42:24 +0000 (UTC) Received: (qmail 10887 invoked by uid 500); 20 Aug 2014 07:42:24 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 10833 invoked by uid 500); 20 Aug 2014 07:42:24 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 10820 invoked by uid 99); 20 Aug 2014 07:42:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Aug 2014 07:42:24 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mhz4248@gmail.com designates 74.125.82.67 as permitted sender) Received: from [74.125.82.67] (HELO mail-wg0-f67.google.com) (74.125.82.67) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Aug 2014 07:42:18 +0000 Received: by mail-wg0-f67.google.com with SMTP id l18so2496886wgh.6 for ; Wed, 20 Aug 2014 00:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=zSyR27MHh0tEDS6W5qV2sWC857gvuhU3NGhleWePAKw=; b=db+r9XaBZprWkLGFqsf3JXrltFyk3zWaURr/oXViXg7lrIBnBPKkrBDxK6dZ4L5hYA 3FWIzdBnf4FOteoP5vnVQJSLWtUHT5fTW9cYti/TGeK7OJ91z5Gpc9ktQe+gW84O8/RW G4hpv+0NzZpuBM1V3MrLN7xbvtAIK3L5D7IxWIAonKiY8b4QfbN0gMny966P7lZ1gQBr TYACTe4k8ie5eHQwSDu3L7jONq0A5w9mxL+mEkVFPaZ8syX7E+kLmwdrDWQKr5kbmyT5 dewBCvY7nRzFsuY4wDRJSH2NxtapZaL7/SOugSfwwadJrwGCCFpoqDc60z2Iuo8Ly6BC ocUA== MIME-Version: 1.0 X-Received: by 10.180.11.177 with SMTP id r17mr12241787wib.67.1408520517381; Wed, 20 Aug 2014 00:41:57 -0700 (PDT) Received: by 10.194.173.35 with HTTP; Wed, 20 Aug 2014 00:41:57 -0700 (PDT) In-Reply-To: References: Date: Wed, 20 Aug 2014 09:41:57 +0200 Message-ID: Subject: Re: Performance issue with component bindings and Ajax requests From: Marc Heinz To: MyFaces Discussion Content-Type: multipart/alternative; boundary=001a1136b4fa18f54805010abdac X-Virus-Checked: Checked by ClamAV on apache.org --001a1136b4fa18f54805010abdac Content-Type: text/plain; charset=UTF-8 Thanks for the quick answer! We tried disabling PSS but this actually broke several other things, so we would prefer not to touch it right now. Setting the flag "org.apache.myfaces.REMOVING_COMPONENTS_BUILD" however seems to do the trick... (we though about using it before but we were unsure about the possible implications). I've created an issue as suggested: https://issues.apache.org/jira/browse/MYFACES-3918 I will report any possible regression we find there, and I will test again when a fix becomes available. Once again, thanks a lot for the reactivity. Marc On Tue, Aug 19, 2014 at 8:42 PM, Leonardo Uribe wrote: > Hi > > The problem is the call to formRoot.getChildren().clear() activates > the listener for > PreRemoveFromViewEvent and that one register the removed components. Since > you are generating over and over components, after many requests that list > becomes big. > > I can imagine two solutions: > > 1. Disable PSS on the affected views, using > javax.faces.FULL_STATE_SAVING_VIEW_IDS param > > 2. Try to use this code on formRoot.getChildren().clear(); > > > facesContext.getAttributes.put("org.apache.myfaces.REMOVING_COMPONENTS_BUILD", > Boolean.TRUE); > formRoot.getChildren().clear(); > > facesContext.getAttributes.remove("org.apache.myfaces.REMOVING_COMPONENTS_BUILD"); > > That will avoid register the ids on the list, without side effects > (that I can imagine right now, > not 100% sure). > > Anyway, It is possible to find a solution changing the code in > DefaultFaceletsStateManagementStrategy, so the list keeps stable over time, > Please create an issue on MyFaces issue tracker: > > https://issues.apache.org/jira/browse/MYFACES > > regards, > > Leonardo Uribe > > 2014-08-19 8:12 GMT-05:00 Marc Heinz : > > Hello everybody, > > > > We are currently encountering some performances issues with myfaces, and > we > > would really appreciate some help on the subject. > > > > We are generating forms to be filled by the user dynamically (through > > component binding) from a set of externally managed rules. Here is a > short > > overview: > > > > In our facelet: > > > > > > Our backing bean: > > > > @RequestScoped > > public class FormBean { > > private boolean rebuildDone = false; > > private UIPanel formRoot; > > public UIPanel getFormRoot() { > > if (!rebuildDone) { > > rebuildForm(); > > } > > return formRoot; > > } > > public void setFormRoot(UIPanel formRoot) { > > // Ignore. > > } > > // Public method to rebuild the current form content in reaction to > > updates fired from Ajax managed components. > > public void rebuildForm() { > > if (formRoot == null) { > > formRoot = new UIPanel(); > > // The whole component tree is marked as transient. > > formRoot.setTransient(true); > > formRoot.setId("formRoot"); > > } > > > > // Clear the existing tree. > > formRoot.getChildren().clear(); > > > > // Start building the new component tree with formRoot as > parent. > > [...] > > } > > } > > > > We use Ajax extensively: all updates events are processed with > > AjaxBehaviorsListeners (wired on "onchange" client events). > > > > When a change is processed (during the INVOKE_APPLICATION phase), the > value > > is validated and the GUI is refreshed by calling the "rebuildForm()" > > method. The existing component tree will then be *cleared* by calling > > getChildren().clear() on the binding root component. It will be then > > rebuilt entirely (even though only a small subset of components are > usually > > affected). This is clearly inefficient, but this is some legacy code that > > we don't want to disturb unless strictly required. > > > > What we observed (with MyFaces 2.1.12 and the 2.1.16 r1618150 in trunk): > on > > all forms (but especially on forms with all lot of components) every Ajax > > request takes more time to complete than the previous one as long as we > > stay on the same view. On a form with ~70 fields, the turnaround time > > (measured with the Net panel of Firebug) goes from ~250ms (first request) > > to more than 1 second after ~15 update. > > > > After some profiling done with VisualVM, we pinpointed the location of > the > > latency to: > > > org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.handleDynamicAddedRemovedComponents(), > > accountable for > 70% of the processing time. On further inspection, it > > appears that a data structure, the list of removed client IDs > > (clientIdsRemoved), is growing endlessly across each request. > > > > We are not too sure where the problem is right now... Should we build the > > component tree only once during the RESTORE_VIEW phase and then update > it? > > (this seems hardly doable) Are we simply doing something in the wrong > > phase? Should I raise an issue on this? > > > > Any feedback would be most appreciated, > > > > Thanks, > > Marc > --001a1136b4fa18f54805010abdac--