Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 5983 invoked from network); 3 Oct 2008 16:09:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Oct 2008 16:09:07 -0000 Received: (qmail 4070 invoked by uid 500); 3 Oct 2008 16:09:05 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 4018 invoked by uid 500); 3 Oct 2008 16:09:05 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 4007 invoked by uid 99); 3 Oct 2008 16:09:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Oct 2008 09:09:04 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Oct 2008 16:08:09 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 63942234C212 for ; Fri, 3 Oct 2008 09:08:44 -0700 (PDT) Message-ID: <794547338.1223050124406.JavaMail.jira@brutus> Date: Fri, 3 Oct 2008 09:08:44 -0700 (PDT) From: "Stevan Malesevic (JIRA)" To: dev@myfaces.apache.org Subject: [jira] Created: (TRINIDAD-1247) org.apache.myfaces.trinidadinternal.skin.RequestSkinWrapper.getStyleSheetDocumentId has very poor performance MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org org.apache.myfaces.trinidadinternal.skin.RequestSkinWrapper.getStyleSheetDocumentId has very poor performance ------------------------------------------------------------------------------------------------------------- Key: TRINIDAD-1247 URL: https://issues.apache.org/jira/browse/TRINIDAD-1247 Project: MyFaces Trinidad Issue Type: Bug Reporter: Stevan Malesevic Application we use makes a calls to org.apache.myfaces.trinidadinternal.skin.RequestSkinWrapper.getStyleSheetDocumentId for each instance of particular component. So there is a couple of calls per request. While looking at CPU and memory usage we noticed that a significant amount is spent in this call. In terms of memory for 45 invocations of this method 5802KB of memory is allocated , which means about 129K per method invocation Most of this memory is spent creating Version objects in org.apache.myfaces.trinidadinternal.style.xml.parse.StyleSheetNode.compareVariants. To fix this issue we should change StyleSheetNode._compareBrowserAndVersion method to have signature like private int _compareBrowserAndVersion(int browser, TrinidadAgent agent) and create Version object inside the method just before it is needed. This will greatly reduce the number of Version objects. The method looks like this: private int _compareBrowserAndVersion(int browser, TrinidadAgent agent) { // If we don't have a browser specified, we match anything if (_agentVersions.isEmpty()) return _BROWSER_UNKNOWN_MATCH; // On the other hand, if we do have a browser specified, but // the client browser is not known, we don't have a match if (browser == TrinidadAgent.APPLICATION_UNKNOWN) return 0; //If we have browser exact match, compare versions Integer browserNum = Integer.valueOf(browser); if (_agentVersions.containsKey(browserNum)) { Set versions = _agentVersions.get(browserNum); if (versions.isEmpty()) return _BROWSER_EXACT_MATCH | _VERSION_UNKNOWN_MATCH; Version version = new Version(agent.getAgentVersion()); for (Version av : versions) { if (av.compareTo(version) == 0) { return _BROWSER_EXACT_MATCH | _VERSION_EXACT_MATCH; } } return 0; } return 0; } In my test case memory went down to 214K -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.