_Comment made by: gshayban_
Repro code
(def C (atom 0))
;; reextend for instrumentation
(extend-protocol clojure.core.protocols/IKVReduce
;;slow path default
clojure.lang.IPersistentMap
(kv-reduce
[amap f init]
(swap! C inc)
(reduce (fn [ret [k v]] (f ret k v)) init amap)))
(reduce-kv (fn [_ _ _]) nil (array-map 1 2 3 4))
(println "slowpaths" @C)
(reduce-kv (fn [_ _ _]) nil (hash-map 1 2 3 4))
(println "slowpaths" @C)
Repro output
➜ dev /usr/lib/jvm/java-8-openjdk/bin/java -cp $(clojure -Spath) clojure.main kvfastpath.clj
slowpaths 1
slowpaths 2
➜ dev /usr/lib/jvm/java-11-openjdk/bin/java -cp $(clojure -Spath) clojure.main kvfastpath.clj
slowpaths 0
slowpaths 0