MyFaces Core
  1. MyFaces Core
  2. MYFACES-3480

[perf] Use lazy init for HashMap/HastSet where possible

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.13, 2.1.7
    • Component/s: None
    • Labels:
      None

      Description

      goal: make component tree creation fast as possible and avoid unnecessary instances

      some components instantialize attributes direct in field or in constructor. In many cases it is not necessary, because those HashMap/Set instances are not used in current request/response - it depends on use case.

      Example: UIViewRoot.listenerSuccessMap: lazy init is very suitable, because many view have no phase listener.

      Check all components: candidates are "smarter" components like UIDate or UIInput

      1. UIViewRoot.patch
        3 kB
        Martin Kočí
      2. RequestViewContext.patch
        1 kB
        Martin Kočí
      3. _ComponentAttributesMap.patch
        0.9 kB
        Martin Kočí
      4. FaceletCompositionContextImpl.patch
        6 kB
        Martin Kočí
      5. TemplateContextImpl.patch
        1 kB
        Martin Kočí

        Activity

        Hide
        Leonardo Uribe added a comment -

        Thanks to Martin Koci for provide this patch

        Show
        Leonardo Uribe added a comment - Thanks to Martin Koci for provide this patch
        Hide
        Martin Kočí added a comment -

        patches for classes found by profiler. _ComponentAttributesMap patch reduces unnecessary StateHelper/HashMap initializations from:
        javax.faces.component._ComponentAttributesMap.getUnderlyingMap()
        javax.faces.component._ComponentAttributesMap.containsKey(Object)
        javax.faces.component.UIComponent.isCompositeComponent(UIComponent)
        javax.faces.component.UIComponent._isCompositeComponent()
        and

        javax.faces.component._ComponentAttributesMap.get()
        org.apache.myfaces.view.facelets.impl.FaceletCompositionContextImpl.finalizeForDeletion(UIComponent)

        There are more classes for optimalization, but complexity requires separate bugs.

        Show
        Martin Kočí added a comment - patches for classes found by profiler. _ComponentAttributesMap patch reduces unnecessary StateHelper/HashMap initializations from: javax.faces.component._ComponentAttributesMap.getUnderlyingMap() javax.faces.component._ComponentAttributesMap.containsKey(Object) javax.faces.component.UIComponent.isCompositeComponent(UIComponent) javax.faces.component.UIComponent._isCompositeComponent() and javax.faces.component._ComponentAttributesMap.get() org.apache.myfaces.view.facelets.impl.FaceletCompositionContextImpl.finalizeForDeletion(UIComponent) There are more classes for optimalization, but complexity requires separate bugs.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development