get-in* performance

Hashmaps
Lists
Sequences
Vectors

get-in* performance improved substantially across many conditions with version 5.

See the overall summary for benchmarking details. The benchmarks displayed in this document are defined here.

Hashmaps

Version 5's get-in* performs 43‑49% faster than clojure.core/get-in for this hashmap scenario.

(fn [n] (get-in (nested-map n) (path-map n)))

Benchmark measurements for expression `(fn [n] (get-in (nested-map n) (path-map n)))`, time versus 'n' arguments, comparing different versions.

(fn [n] (get-in* (nested-map n) (path-map n)))

Benchmark measurements for expression `(fn [n] (get-in* (nested-map n) (path-map n)))`, time versus 'n' arguments, comparing different versions.

Lists

Version 5's get-in* with protocol type dispatch performs about 35% faster than version 4 on lists.

(fn [n] (get-in* (nested-list n) (path-list n)))

Benchmark measurements for expression `(fn [n] (get-in* (nested-list n) (path-list n)))`, time versus 'n' arguments, comparing different versions.

Sequences

Version 5 performs about 36% faster for sequences.

(fn [n] (get-in* (nested-seq n) (path-seq n)))

Benchmark measurements for expression `(fn [n] (get-in* (nested-seq n) (path-seq n)))`, time versus 'n' arguments, comparing different versions.

Vectors

The top two panels are curious: while the clojure.core/get implementation didn't change, the benchmarks run after the library's bump to version 5 showed up to 14% slower performance. One possible interpretation is that the performance improvements demonstrated by get-in* is understated.

Regardless, get-in* performance substantially improved for both patterns of nested vectors, improving by about 70% relative to version 4, and narrowing the performance gap with clojure.core/get-in in the worst case, and bettering it in the best case.

(fn [n] (get-in (narrow-deep-vec n) (path-narrow-deep-vec n)))

Benchmark measurements for expression `(fn [n] (get-in (narrow-deep-vec n) (path-narrow-deep-vec n)))`, time versus 'n' arguments, comparing different versions.

(fn [n] (get-in (nested-vec n) (path-nested-vec n)))

Benchmark measurements for expression `(fn [n] (get-in (nested-vec n) (path-nested-vec n)))`, time versus 'n' arguments, comparing different versions.

(fn [n] (get-in* (narrow-deep-vec n) (path-narrow-deep-vec n)))

Benchmark measurements for expression `(fn [n] (get-in* (narrow-deep-vec n) (path-narrow-deep-vec n)))`, time versus 'n' arguments, comparing different versions.

(fn [n] (get-in* (nested-vec n) (path-nested-vec n)))

Benchmark measurements for expression `(fn [n] (get-in* (nested-vec n) (path-nested-vec n)))`, time versus 'n' arguments, comparing different versions.