This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-26
Channels
- # announcements (4)
- # beginners (160)
- # boot (2)
- # calva (40)
- # cider (41)
- # clara (24)
- # cljdoc (2)
- # cljs-dev (99)
- # clojars (4)
- # clojure (71)
- # clojure-dev (9)
- # clojure-europe (4)
- # clojure-italy (2)
- # clojure-nl (19)
- # clojure-spec (97)
- # clojure-uk (103)
- # clojurescript (57)
- # core-logic (1)
- # cursive (15)
- # data-science (31)
- # datomic (24)
- # duct (1)
- # emacs (39)
- # events (7)
- # figwheel-main (14)
- # fulcro (44)
- # garden (7)
- # jobs (13)
- # juxt (1)
- # leiningen (29)
- # music (2)
- # nyc (4)
- # off-topic (37)
- # pathom (12)
- # re-frame (26)
- # ring (1)
- # ring-swagger (10)
- # shadow-cljs (35)
- # spacemacs (2)
- # specter (4)
- # test-check (67)
OK, with these changes: https://github.com/clojure/clojure/compare/master...borkdude:map-optimizations And this benchmark:
clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.11.0-master-SNAPSHOT"} criterium/criterium {:mvn/version "RELEASE"}}}'
user=> (use 'criterium.core)
nil
user=> (defn merge-benchmark [size] (let [m1 (zipmap (range size) (range size)) m2 (zipmap (range size (* 2 size)) (range size (* 2 size)))] (println (type m1) (type m2)) (quick-bench (merge m1 m2))))
#'user/merge-benchmark
It’s starting to pay off with maps > 64 kv-pairs or so. Below that the performance is roughly the same between 16-64 elements and maybe a tad slower below 16 elements.Here’s a gist with the exact numbers: https://gist.github.com/borkdude/b6e52bc1bd32512aa43015724cda46da
or we could just decide that this is not worth optimizing. chances are that Rich has already thought about this case
for PersistentArrayMap the override could be removed since those are small maps all the time