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

ArrayCollection/ListCollectionView performance improvements

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Apache Flex 4.14.0
    • None
    • Collections

    Description

      ListCollectionView immediatly adds a CollectionEvent listener to its source list, even though it only needs the events if sort is set, filterFunction is set, or it has a CollectionEvent listener of its own.

      ArrayList suppresses CollectionEvent creation if there is no CollectionEvent listener, so by only adding the listener when needed we can improve performance while reducing the number of CollectionEvent/Array allocations.

      Performance profiling of the patch:

      label type objectCount addItemAtStart addItemAtEnd addItemAtRandom removeItemAtStart removeItemAtEnd removeItemAtRandom
      Original ArrayCollection: original ArrayList class ArrayCollection 100000 2538.556ms 2575.138ms 3268.842ms 3095.744ms 2555.533ms 2828.339ms
      Patched ArrayCollection: original ArrayList class ArrayCollectionListenerPatch 100000 2339.321ms 2338.553ms 3080.970ms 2927.168ms 2364.032ms 2706.899ms
      Patched ArrayCollection: original ArrayList + CollectionEvent listener class ArrayCollectionListenerPatch 100000 2561.900ms 2521.983ms 3262.963ms 3149.099ms 2533.680ms 2884.201ms

      Performance profiling of the patch with the patched ArrayList from FLEX-34759:

      label type objectCount addItemAtStart addItemAtEnd addItemAtRandom removeItemAtStart removeItemAtEnd removeItemAtRandom
      Original ArrayCollection: patched ArrayList class ArrayCollection 100000 240.839ms 273.501ms 3296.476ms 926.919ms 208.949ms 2856.562ms
      Patched ArrayCollection: patched ArrayList class ArrayCollectionListenerPatch 100000 62.039ms 65.500ms 3131.238ms 706.865ms 36.314ms 2676.732ms
      Patched ArrayCollection: patched ArrayList + CollectionEvent listener class ArrayCollectionListenerPatch 100000 298.581ms 243.448ms 3282.985ms 935.452ms 228.865ms 2880.552ms

      In the above examples: when the patched ArrayCollection doesn't have a CollectionEvent listener, sort, or filter we avoid allocation of 200,000 unused CollectionEvents (2 for each add/remove - one dispatched by the array list to the ListCollectionView, one cloned by the ListCollectionView and dispatched to nobody)

      Attachments

        1. FLEX-34765.patch
          3 kB
          shane doolan

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sdoolan shane doolan
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: