MyFaces Core
  1. MyFaces Core
  2. MYFACES-3150

[perf] buildView: review usage of "facelets.FACET_NAME"

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.0-SNAPSHOT
    • Fix Version/s: 2.0.13, 2.1.7
    • Component/s: General
    • Labels:
      None
    • Environment:
      myfaces core trunk

      Description

      Consider 1000 components in view without any f:facet.

      During VDL.buildView Facelets call for each component ComponentHandler.getFacetName(FaceletContext, UIComponent) and that creates 3 calls of Map.get():

      1) _ComponentAttributesMap.getPropertyDescriptor(String)
      2) _ComponentAttributesMap.getUnderlyingMap().get()
      3) UIComponent.getValueExpression(String)

      3000 "empty" invocations in buildView withnout match.

      Suggestions:

      • do not use Component.attribute for that marker (comes from FacetHandler)
      • replace map.get calls with property for performance reasons
      • use a stack or property on AbstractFaceletContext if possible

        Activity

        Hide
        Martin Kočí added a comment -

        actually it creates 4000 "empty" invocations of Map.get, because UIComponent.getValueExpression itself calls Map.get 2x:
        1) bindings = getStateHelper(). get(PropertyKeys.bindings);
        2) return (ValueExpression) bindings.get(name);

        Show
        Martin Kočí added a comment - actually it creates 4000 "empty" invocations of Map.get, because UIComponent.getValueExpression itself calls Map.get 2x: 1) bindings = getStateHelper(). get(PropertyKeys.bindings); 2) return (ValueExpression) bindings.get(name);
        Hide
        Martin Kočí added a comment -

        This problem is probably the last one piece of code which initializes _ComponentAttributesMap to store some temporal (not component attributes) data during VDL.buildView

        Attached patch with Stack solution but brings many cast - better solution needed.

        Show
        Martin Kočí added a comment - This problem is probably the last one piece of code which initializes _ComponentAttributesMap to store some temporal (not component attributes) data during VDL.buildView Attached patch with Stack solution but brings many cast - better solution needed.
        Hide
        Leonardo Uribe added a comment -

        Unfortunately the patch will not work, because there is an association between the parent component and the facet name, and then a check for a facet name is used to decide if the component is added as a child or as a facet child. With a stack, that connection get lost and at the end the tree will not be built correctly.

        Show
        Leonardo Uribe added a comment - Unfortunately the patch will not work, because there is an association between the parent component and the facet name, and then a check for a facet name is used to decide if the component is added as a child or as a facet child. With a stack, that connection get lost and at the end the tree will not be built correctly.
        Hide
        Leonardo Uribe added a comment -

        I committed an alternative solution, following the change done in MYFACES-3488: add a field on UIComponentBase and store there that value. Since it is a transient field for facelets compiler use only, we don't need to worry about store it into the state. The solution involving use an structure on the compiler side is too complex, so after some meditation I discarded it.

        Show
        Leonardo Uribe added a comment - I committed an alternative solution, following the change done in MYFACES-3488 : add a field on UIComponentBase and store there that value. Since it is a transient field for facelets compiler use only, we don't need to worry about store it into the state. The solution involving use an structure on the compiler side is too complex, so after some meditation I discarded it.

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Martin Kočí
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development