Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: None
    • Labels:
    • Patch:
      Code

      Description

      ci-reduce is a private function in cljs.core for reducing collections which are IIndexed and ICounted. It's first argument is always a collection which implements these protocols, as such, letting the compiler know that the collection is ^not-native allows for direct calls to the IIndexed.nth method of the collection.

      In particular, this improved the performance of reducing over Range types using the 2-arity form of reduce, i.e., no init form, but also reducing of the various map-entries MapEntry, RedNode and BlackNode.

      Finally, the 4-arity version of ci-reduce, where the 4th arg is an index to start at, was deleted because it is no longer called anywhere.

      Output of some naive microbenchmarks performed with simple-benchamrk are:

      V8 (6.8.0)

      Benchmark Before (msecs) After (msecs)
      [r (range 10000)], (reduce + r), 1000 runs 249 242
      [m (apply hash-map (range 100000))], (transduce cat + 0 m), 1000 runs 18907 11744
      [m (apply sorted-map (range 100000))], (transduce cat + 0 m), 1000 runs 32331 20084

      JavascriptCore

      Benchmark Before (msecs) After (msecs)
      [r (range 10000)], (reduce + r), 1000 runs 234 40
      [m (apply hash-map (range 100000))], (transduce cat + 0 m), 1000 runs 12252 8962
      [m (apply sorted-map (range 100000))], (transduce cat + 0 m), 1000 runs 16084 13233

        Attachments

          Activity

            People

            • Assignee:
              tmulvaney Thomas Mulvaney
              Reporter:
              tmulvaney Thomas Mulvaney
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: