Return-Path: X-Original-To: apmail-myfaces-dev-archive@www.apache.org Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 56F5EDBBD for ; Fri, 21 Dec 2012 22:17:13 +0000 (UTC) Received: (qmail 28304 invoked by uid 500); 21 Dec 2012 22:17:13 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 28262 invoked by uid 500); 21 Dec 2012 22:17:13 -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 28251 invoked by uid 99); 21 Dec 2012 22:17:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Dec 2012 22:17:12 +0000 Date: Fri, 21 Dec 2012 22:17:12 +0000 (UTC) From: "Leonardo Uribe (JIRA)" To: dev@myfaces.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MYFACES-3586) Performance improvement in Resource loading - HIGH CPU inflating bytes in ResourceHandlerImpl.handleResourceRequest MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MYFACES-3586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13538469#comment-13538469 ] Leonardo Uribe commented on MYFACES-3586: ----------------------------------------- I have attached a patch ( MYFACES-3586-1.patch ) using a web config param to enable disable it. It only use a temporal folder to store the files, but does not apply the solution using a memory cache, which still sounds overkill because and the end it will be just a bad copy of the module in apache server. I think it is better to implement the memory cache only if more information is provided about the real benefit of it. > Performance improvement in Resource loading - HIGH CPU inflating bytes in ResourceHandlerImpl.handleResourceRequest > ------------------------------------------------------------------------------------------------------------------- > > Key: MYFACES-3586 > URL: https://issues.apache.org/jira/browse/MYFACES-3586 > Project: MyFaces Core > Issue Type: Improvement > Environment: ALL > Reporter: Rohit Dilip Kelapure > Attachments: MYFACES-3586-1.patch, MYFACES-3586.patch > > Original Estimate: 48h > Remaining Estimate: 48h > > In a high concurrency load test with Apache MyFaces + RichFaces component library we found that under peak load majority of our web container threads were stuck in this call stack > at java/util/zip/Inflater.inflateBytes(Native Method) > at java/util/zip/Inflater.inflate(Inflater.java:249(Compiled Code)) > at java/util/zip/InflaterInputStream.read(InflaterInputStream.java:146(Compiled Code)) > at java/util/zip/InflaterInputStream.read(InflaterInputStream.java:116(Compiled Code)) > at java/io/FilterInputStream.read(FilterInputStream.java:77(Compiled Code)) > at java/io/FilterInputStream.read(FilterInputStream.java:77(Compiled Code)) > at java/io/PushbackInputStream.read(PushbackInputStream.java:133(Compiled Code)) > at org/apache/myfaces/shared_impl/resource/ResourceImpl$ValueExpressionFilterInputStream.read(ResourceImpl.java:117(Compiled Code)) > at java/io/InputStream.read(InputStream.java:175(Compiled Code)) > at java/io/InputStream.read(InputStream.java:97(Compiled Code)) > at org/apache/myfaces/application/ResourceHandlerImpl.pipeBytes(ResourceHandlerImpl.java:402(Compiled Code)) > at org/apache/myfaces/application/ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:357(Compiled Code)) > at org/richfaces/resource/ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:257(Compiled Code)) > at javax/faces/webapp/FacesServlet.service(FacesServlet.java:183(Compiled Code)) > at org/richfaces/webapp/ResourceServlet.httpService(ResourceServlet.java:110(Compiled Code)) > at org/richfaces/webapp/ResourceServlet.service(ResourceServlet.java:105(Compiled Code)) > After looking at the src code of org.apache.myfaces.application.ResourceHandlerImpl.handleResourceRequest(FacesContext) I can see that the ResourceHandlerCache caches the Resource metadata ; however the actual output of the resource which is written to the outputstream in ResourceHandlerImpl.pipeBytes is NEVER cached. > This causes a scalability problem in our case because each access to the resource involves cracking open a jar, inflating the bytes and parsing a stream of bytes. This is done multiple times for the same resource(say a css file) inside the richfaces jar inspite of the resource not changing. > I propose a much needed performance optimization wherein we cache the output of the Resource handled and stash the output byte[] it as softReference in the ResourceHandlerCache.ResourceValue. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira