We're updating the issue view to help you get more done. 

Records do not cache hash like normal maps

Description

Records do not cache their hash codes like normal Clojure maps, which affects their performance. This problem has been fixed in CLJS, but still affects JVM CLJ.

Approach: Cache hash values in record definitions, similar to maps.

Timings:

coll

1.9.0-master

1.9.0-master+patch

small record

90 ns

7 ns

big record

446 ns

8 ns

1 2 3 4 5 6 (defrecord R [a b]) ;; small (def r (R. (range 1e3) (range 1e3))) (bench (hash r)) (defrecord R [a b c d e f g h i j]) ;; big (def r (map->R (zipmap [:a :b :c :d :e :f :g :h :i :j] (repeat (range 1e3))))) (bench (hash r))

Patch: clj-1224-3.patch

Screened by: Alex Miller

Also see: http://dev.clojure.org/jira/browse/CLJS-281

Environment

None

Status

Assignee

Unassigned

Reporter

Brandon Bloom

Approval

Ok

Patch

Code and Test

Fix versions

Priority

Critical