Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-34759

ArrayList/ArrayCollection performance improvements

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Considerable performance gains can be achieved by avoiding the use of array splice when adding/removing items from the start or end of the source array in ArrayList.

      eg/ in ArrayList.addItemAt, replace this:

      source.splice(index, 0, item);
      

      with this:

       
      if (index == length)
          source.push(item);
      else if (index == 0)
          source.unshift(item);
      else
          source.splice(index, 0, item);
      

      ArrayList.addItem is 10x faster when adding non IEventDispatcher's, and 6x faster for IEventDispatcher's. There is a small trade-off when performing random access add/removes, where the extra logic slightly increases the times taken.

      Since ArrayCollection wraps an ArrayList by default and ArrayCollection.addItem is used extensively within our apps, this patch has provided considerable performance improvements.

      See profiling results below:

      Original ArrayList, adding/removing 100k ints

      • addItemAtStart = "2434ms"
      • addItemAtEnd = "2501ms"
      • addItemAtRandom = "3149ms"
      • removeItemAtStart = "3098ms"
      • removeItemAtEnd = "2401ms"
      • removeItemAtRandom = "2606ms"

      Original ArrayList, adding/removing 100k IEventDispatcher's

      • addItemAtStart = "2501ms"
      • addItemAtEnd = "2505ms"
      • addItemAtRandom = "3165ms"
      • removeItemAtStart = "3053ms"
      • removeItemAtEnd = "2453ms"
      • removeItemAtRandom = "2709ms"

      Patched ArrayList, adding/removing 100k ints

      • addItemAtStart = "226ms"
      • addItemAtEnd = "213ms"
      • addItemAtRandom = "3281ms"
      • removeItemAtStart = "803ms"
      • removeItemAtEnd = "219ms"
      • removeItemAtRandom = "2808ms"

      Patched ArrayList, adding/removing 100k IEventDispatcher's

      • addItemAtStart = "415ms"
      • addItemAtEnd = "488ms"
      • addItemAtRandom = "3662ms"
      • removeItemAtStart = "878ms"
      • removeItemAtEnd = "264ms"
      • removeItemAtRandom = "2949ms"

      Attachments

        1. FLEX-34759_v2.patch
          5 kB
          shane doolan
        2. FLEX-34759.patch
          4 kB
          shane doolan
        3. ListProfiler.zip
          76 kB
          shane doolan

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            pete21 Piotr Zarzycki
            sdoolan shane doolan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment