Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3458

[perf] Store URL at class ResourceImpl

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3, 2.1.5
    • 2.0.13, 2.1.7
    • None
    • None
    • Websphere Application Server v7
      Windows 2003 Server
      Double quad-core Intel Xeon CPU

    Description

      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.

      Attachments

        1. ResourceImpl_getURL_blocked.png
          66 kB
          Jesús Pérez Alcaide (ISBAN)

        Activity

          People

            lu4242 Leonardo Uribe
            jperealc_isban Jesús Pérez Alcaide (ISBAN)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: