Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.3, 2.1.5
    • Fix Version/s: 2.0.13, 2.1.7
    • Component/s: None
    • Labels:
      None
    • Environment:
      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.

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

        Activity

        Hide
        jperealc_isban Jesús Pérez Alcaide (ISBAN) added a comment -

        Screenshot from JProfiler showing 'hot spot' methods when threads were blocked.
        Method java.lang.ClassLoader#getResource(String) takes 14% of the time.

        Show
        jperealc_isban Jesús Pérez Alcaide (ISBAN) added a comment - Screenshot from JProfiler showing 'hot spot' methods when threads were blocked. Method java.lang.ClassLoader#getResource(String) takes 14% of the time.
        Hide
        lu4242 Leonardo Uribe added a comment -

        Thanks to Jesús Pérez for contribute with this performance improvement.

        Show
        lu4242 Leonardo Uribe added a comment - Thanks to Jesús Pérez for contribute with this performance improvement.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development