Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-2434

Usage of Class.getMethod in TreeRenderer.retrieveGetNodeTypeMethod is a critical performance issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.0.1-core
    • 2.1.3-core
    • Components, Facelets
    • None
    • WebSphere, IBM JRE.

    Description

      We have a webapp with SWF 2.3.0, JSF 2.1 and Trinidad 2.0.1 and have done performance tests in an environment with WebSphere and IBM JRE. When we reached a number of concurrent users of around 80 we get hot spots in calls of Class.getMethod. The stack trace contains following Trinidad method which perform this call often:
      org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.TreeRenderer.getNodeType(UIXHierarchy)
      Inspecting the source of this method I detected that it calls rowClass.getMethod("getNodeType") every time it's called - without caching the method handles reached in previous calls.
      After doing a quick fix for this by caching the method handles we have solved this hot spot:

      private final Map<Class<?>, Method> getNodeTypeMethodMap = new HashMap<Class<?>, Method>();

      private Method retrieveGetNodeTypeMethod(Class rowClass) {
      try {
      synchronized (getNodeTypeMethodMap) {
      if (getNodeTypeMethodMap.containsKey(rowClass))

      { return getNodeTypeMethodMap.get(rowClass); }

      Method getNodeTypeMethod = rowClass.getMethod("getNodeType");
      getNodeTypeMethodMap.put(rowClass, getNodeTypeMethod);
      return getNodeTypeMethod;
      }
      } catch (Exception e)

      { return null; }

      }

      Could you please fix this for the next Trinidad release?

      Attachments

        Activity

          People

            deki Dennis Kieselhorst
            malzahn Volker Malzahn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: