myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesús Pérez Alcaide (ISBAN) (Created) (JIRA) <...@myfaces.apache.org>
Subject [jira] [Created] (MYFACES-3458) [perf] Store URL at class ResourceImpl
Date Fri, 03 Feb 2012 15:11:54 GMT
[perf] Store URL at class ResourceImpl
--------------------------------------

                 Key: MYFACES-3458
                 URL: https://issues.apache.org/jira/browse/MYFACES-3458
             Project: MyFaces Core
          Issue Type: Improvement
    Affects Versions: 2.1.5, 2.1.3
         Environment: Websphere Application Server v7
Windows 2003 Server
Double quad-core Intel Xeon CPU
            Reporter: Jesús Pérez Alcaide (ISBAN)


Doing stress tests on a JSF application we have noticed some contention.
14% of the time that the threads are blocked is due to calls to ClassLoader#getResource(String).
Such calls comes from method  org.apache.myfaces.shared.resource.ResourceImpl#getUrl(). (see
attached image)

Viewing the code of the method ResourceImpl#getURL(), it is always calculating the URL of
the resource through the ResourceLoader. This, in turn, ends up calling the method ClassLoader#getResource(String).


    public URL getURL()
    {
        return getResourceLoader().getResourceURL(_resourceMeta);
    }

Since the resulting URL will not change during the life of the resource instance, it could
be stored in an instance variable and thus prevent subsequent calls to this method end up
calling the ClassLoader.


    private URL _url;

    public URL getURL()
    {
    	if (_url == null) {
    		_url = getResourceLoader().getResourceURL(_resourceMeta);
    	}
        return _url;
    }


With this change applied we obtained a performance improvement between 14% and 119% of throughput,
depending on the complexity of the rendered view.


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

       

Mime
View raw message