Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Apache Flex 4.10.0
    • Fix Version/s: Apache Flex 4.12.0
    • Component/s: Collections
    • Labels:
    • Environment:
      Macos, Mobile (Air)

      Description

      Arraylist creation is a performance pb when deserializing amf response.
      On mobile the uid creation in the constructor is the bottleneck source

      With this patch the uid is lazily created in the getter

      Profiling was done with Adobe Scout

      1. TestUIDPerf.fxp
        15 kB
        Maurice Amsellem
      2. flex.png
        26 kB
        Benoit Wiart
      3. 0001-ArrayList-creation-optimization.patch
        1 kB
        Benoit Wiart

        Activity

        Benoit Wiart created issue -
        Hide
        Benoit Wiart added a comment -

        The patch

        Show
        Benoit Wiart added a comment - The patch
        Benoit Wiart made changes -
        Field Original Value New Value
        Attachment 0001-ArrayList-creation-optimization.patch [ 12608937 ]
        Hide
        Benoit Wiart added a comment -

        profiling screenshot

        Show
        Benoit Wiart added a comment - profiling screenshot
        Benoit Wiart made changes -
        Attachment flex.png [ 12608938 ]
        Benoit Wiart made changes -
        Priority Critical [ 2 ] Major [ 3 ]
        Hide
        Alex Harui added a comment -

        Can you provide a test case where this makes a difference. This will save time on each ArrayList instance, but how many ArrayLists are being created per AMF response? Does your data have a lot of child arrays?

        For those that don't have data with a lot of child arrays and are just getting a lot of data items per response, if you can write your data class to implement mx.core.IUID because there is already a unique identifier in the data (customer account #, employee id, etc) that should also save on UID generation per-item. Or you can try lazy generation of the UID in your data item as well.

        -Alex

        Show
        Alex Harui added a comment - Can you provide a test case where this makes a difference. This will save time on each ArrayList instance, but how many ArrayLists are being created per AMF response? Does your data have a lot of child arrays? For those that don't have data with a lot of child arrays and are just getting a lot of data items per response, if you can write your data class to implement mx.core.IUID because there is already a unique identifier in the data (customer account #, employee id, etc) that should also save on UID generation per-item. Or you can try lazy generation of the UID in your data item as well. -Alex
        Hide
        Benoit Wiart added a comment -

        Alex

        the arraylist were created by the mapping AMF<->ActionScript classes NOT by the amf deserailization code by itself
        So the performance improvements depend on the data

        In our case, a cross plateform Air application (desktop, mobile) this patch was a real improvement (20% of the deserialization)
        To test it you can do something like
        var list:ArrayList;
        var start:Number = new Date().time;
        var nr:Number = 10000;
        for (var i:Number = 0; i < nr; i++)

        { list = new ArrayList(); }

        var end:Number = new Date().time;
        Before and after the patch

        You should see a difference on desktop, and much more on mobile

        Show
        Benoit Wiart added a comment - Alex the arraylist were created by the mapping AMF<->ActionScript classes NOT by the amf deserailization code by itself So the performance improvements depend on the data In our case, a cross plateform Air application (desktop, mobile) this patch was a real improvement (20% of the deserialization) To test it you can do something like var list:ArrayList; var start:Number = new Date().time; var nr:Number = 10000; for (var i:Number = 0; i < nr; i++) { list = new ArrayList(); } var end:Number = new Date().time; Before and after the patch You should see a difference on desktop, and much more on mobile
        Show
        Benoit Wiart added a comment - see also http://mail-archives.apache.org/mod_mbox/flex-users/201310.mbox/%3cCALo+euP=wR3At6k5dXGa9MmmwW5=P-vG=ue3qrqpJmCG4qcQNA@mail.gmail.com%3e
        Hide
        Justin Mclean added a comment - - edited

        I can see how this improves performance at creation time but is it just postponing works that needs to be done later? (not 100% sure on that btw)

        Show
        Justin Mclean added a comment - - edited I can see how this improves performance at creation time but is it just postponing works that needs to be done later? (not 100% sure on that btw)
        Hide
        Alex Harui added a comment -

        It postpones work that may need to be done later. It is worth taking, IMO.

        Show
        Alex Harui added a comment - It postpones work that may need to be done later. It is worth taking, IMO.
        Hide
        Benoit Wiart added a comment -

        In our applications
        For most of the arraylist created during the amf deserialization : the uid will never be used / generated.

        Show
        Benoit Wiart added a comment - In our applications For most of the arraylist created during the amf deserialization : the uid will never be used / generated.
        Hide
        Justin Mclean added a comment -

        Thanks, your suggested patch has been checked in so you should see an improvement if you use the next nightly build.

        Show
        Justin Mclean added a comment - Thanks, your suggested patch has been checked in so you should see an improvement if you use the next nightly build.
        Hide
        Justin Mclean added a comment -

        Checked into develop branch

        Show
        Justin Mclean added a comment - Checked into develop branch
        Justin Mclean made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s Apache Flex 4.12.0 [ 12325291 ]
        Resolution Fixed [ 1 ]
        Maurice Amsellem made changes -
        Attachment TestUIDPerf.fxp [ 12609329 ]
        Maurice Amsellem made changes -
        Comment [ checked new ByteArray based algorithm to develop branch
        and attached FB test project ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Benoit Wiart
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development