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

        Hide
        Martin Kočí added a comment -

        suggested patch: uses lazy creation of ArrayList (reduces ArrayList instances) and getChildrenCount() > 0 check (reduces AbstractList$Iter instances)

        Patch reduces number of instances from ~ 310 000 to ~ 170 000 - there is still a big room for improvements; please review

        Show
        Martin Kočí added a comment - suggested patch: uses lazy creation of ArrayList (reduces ArrayList instances) and getChildrenCount() > 0 check (reduces AbstractList$Iter instances) Patch reduces number of instances from ~ 310 000 to ~ 170 000 - there is still a big room for improvements; please review
        Hide
        Leonardo Uribe added a comment -

        I have checked and the patch is ok. Yes, it is true there is still a lot of room from improvement. I'll keep that in mind.

        Show
        Leonardo Uribe added a comment - I have checked and the patch is ok. Yes, it is true there is still a lot of room from improvement. I'll keep that in mind.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development