MyFaces Core
  1. MyFaces Core
  2. MYFACES-3111

[PERF] Review UIData.saveDescendantComponentStates and restoreDescendantComponentStates

    Details

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

      Description

      In my test case, method UIData.saveDescendantComponentStates allocates ~ 310 000 instances during one request/response. Most of them are empty List (+ Object []) and AbstractList$Itr

      Problems:

      1) The current code reminds me the old state saving style from JSF 1.X - a big table of (mostly empty) arrays.

      2) Using getChildren().iterator() creates new instance of AbstractList$Iter.

      3) Saving state of transient and state saving of EditableValueHolder: I don't see any mention of transient in setRowIndex JavaDoc.

      Suggestions:

      ad 1) JSF 2.0 and StateHelper is Map-based. Use map here or even the StateHelper directly. Create EditableValueHolderState instances only and not empty arrays and List. The saved state for a row with non-EditableValueHolder children must be null and must not allocate any objects.

      ad 2) Use the old fashion way with indices; that will avoid thousand of unnecessary iterators instances.

      ad 3) It seems that mojarra saves per-row state for every EVH, even for transients.

        Activity

        Martin Kočí created issue -
        Martin Kočí made changes -
        Field Original Value New Value
        Attachment MYFACES-3111.patch [ 12476599 ]
        Martin Kočí made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Martin Kočí made changes -
        Summary [PERF] Improve javax.faces.component.UIData.saveDescendantComponentStates [PERF] Review UIData.saveDescendantComponentStates and restoreDescendantComponentStates
        Description In my test case, method UIData.saveDescendantComponentStates allocates ~ 310 000 instances during one request/response. Most of them are empty List (+ Object []) and AbstractList$Itr In my test case, method UIData.saveDescendantComponentStates allocates ~ 310 000 instances during one request/response. Most of them are empty List (+ Object []) and AbstractList$Itr

        Problems:

        1) The current code reminds me the old state saving style from JSF 1.X - a big table of (mostly empty) arrays.

        2) Using getChildren().iterator() creates new instance of AbstractList$Iter.

        3) Saving state of transient and state saving of EditableValueHolder: I don't see any mention of transient in setRowIndex JavaDoc.

        Suggestions:

        ad 1) JSF 2.0 and StateHelper is Map-based. Use map here or even the StateHelper directly. Create EditableValueHolderState instances only and not empty arrays and List. The saved state for a row with non-EditableValueHolder children must be null and must not allocate any objects.

        ad 2) Use the old fashion way with indices; that will avoid thousand of unnecessary iterators instances.

        ad 3) It seems that mojarra saves per-row state for every EVH, even for transients.
        Priority Minor [ 4 ] Major [ 3 ]
        Leonardo Uribe made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Assignee Leonardo Uribe [ lu4242 ]
        Fix Version/s 2.0.6 [ 12316397 ]
        Fix Version/s 2.1.0 [ 12315190 ]
        Resolution Fixed [ 1 ]
        Leonardo Uribe made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development