ClojureScript

Faster empty map creation, default to PersistentArrayMap when converting an obj-map whose lenght is less than cljs.core.PersistentArrayMap/HASHMAP_THRESHOLD

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code

Activity

Hide
David Nolen added a comment -

Fast empty map creation looks good, but does the PersistentArrayMap conversion also result in a performance boost?

Show
David Nolen added a comment - Fast empty map creation looks good, but does the PersistentArrayMap conversion also result in a performance boost?
Hide
Nicola Mometto added a comment - - edited

operations on small PersistentArrayMaps are faster than on PersistentHashMaps, see:

ClojureScript:cljs.user> (dotimes [_ 5] (time (dotimes [_ 1e5] (seq (assoc cljs.core.PersistentArrayMap/EMPTY :a 1)))))
"Elapsed time: 2357 msecs"
"Elapsed time: 2098 msecs"
"Elapsed time: 2044 msecs"
"Elapsed time: 2397 msecs"
"Elapsed time: 2125 msecs"
nil
ClojureScript:cljs.user> (dotimes [_ 5] (time (dotimes [_ 1e5] (seq (assoc cljs.core.PersistentHashMap/EMPTY :a 1)))))
"Elapsed time: 4501 msecs"
"Elapsed time: 4701 msecs"
"Elapsed time: 5437 msecs"
"Elapsed time: 5287 msecs"
"Elapsed time: 4732 msecs"

Show
Nicola Mometto added a comment - - edited operations on small PersistentArrayMaps are faster than on PersistentHashMaps, see: ClojureScript:cljs.user> (dotimes [_ 5] (time (dotimes [_ 1e5] (seq (assoc cljs.core.PersistentArrayMap/EMPTY :a 1))))) "Elapsed time: 2357 msecs" "Elapsed time: 2098 msecs" "Elapsed time: 2044 msecs" "Elapsed time: 2397 msecs" "Elapsed time: 2125 msecs" nil ClojureScript:cljs.user> (dotimes [_ 5] (time (dotimes [_ 1e5] (seq (assoc cljs.core.PersistentHashMap/EMPTY :a 1))))) "Elapsed time: 4501 msecs" "Elapsed time: 4701 msecs" "Elapsed time: 5437 msecs" "Elapsed time: 5287 msecs" "Elapsed time: 4732 msecs"
Hide
David Nolen added a comment -

Please report back numbers from V8, JavaScriptCore, and SpiderMonkey, preferably via jsperf.com.

We don't use Rhino for benchmarking.

I'll take the first part of the patch if you split them apart.

Show
David Nolen added a comment - Please report back numbers from V8, JavaScriptCore, and SpiderMonkey, preferably via jsperf.com. We don't use Rhino for benchmarking. I'll take the first part of the patch if you split them apart.
Hide
Nicola Mometto added a comment -

Ok, so testing with v8 and SpiderMonkey shows PersistentHashMaps to be faster, here's a patch with only the first commit

Show
Nicola Mometto added a comment - Ok, so testing with v8 and SpiderMonkey shows PersistentHashMaps to be faster, here's a patch with only the first commit

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: