Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


It seems there is a 30-40% performance degradation of PersistentHashMap.valAt(...) in Clojure 1.4. Possibly due to references to new CPU-hungry implementation of Util.hasheq(...).

Consider the following snippet:

(println "Version: " (clojure-version))

(def mm 10000)

(def str-keys (map str (range mm)))
(def m (zipmap str-keys (range mm)))
(time (dotimes [i mm] (doseq [k str-keys] (m k))))

(def kw-keys (map #(keyword (str %)) (range mm)))
(def m (zipmap kw-keys (range mm)))
(time (dotimes [i mm] (doseq [k kw-keys] (m k))))

(def sym-keys (map #(symbol (str %)) (range mm)))
(def m (zipmap sym-keys (range mm)))
(time (dotimes [i mm] (doseq [k sym-keys] (m k))))

Running this code with Clojure 1.3 and 1.4 yields some interesting output (actual numbers depend on your machine).

$ lein run-all


Version:  1.3.0
"Elapsed time: 3549.974 msecs"
"Elapsed time: 3613.319 msecs"
"Elapsed time: 3350.744 msecs"


Version:  1.4.0
"Elapsed time: 6007.356 msecs"
"Elapsed time: 5926.243 msecs"
"Elapsed time: 5756.16 msecs"

Playing with a profiler leads to PersistentHashMap.

Clojure 1.3 image

Clojure 1.4 image

According to profiler report the new PersistentHashMap.valAt(...) from 1.4 spends more cycles on its own 3208ms --> 3917ms, plus, on further calls to Util.hasheq(...) 900ms --> 2684ms.


Copyright © 2012 Oleksandr Shyshko

Distributed under the Eclipse Public License, the same as Clojure.

You can’t perform that action at this time.