Use transient map in zipmap

Description

#'zipmap constructs a map without transients, where transients could improve performance.

Alt 1: 0002-CLJ-1005-use-transient-map-in-zipmap.patch - straightforward impl that next's through ks and vs as seqs, uses transients to accumulate and outputs a persistent map.

Alt 2: CLJ-1005-zipmap-iterators.patch - leverage internal RT.iter() from transducer support for a lighter weight iteration, also using transients for accumulation.

Performance:

Timings collected with criterium.core/bench and Java 14:

expression

1.10.1

alt 1

alt 2

(zipmap xs xs) ;; large

3.36 ms

2.25 ms

2.30 ms

(zipmap ys ys) ;; small

2.37 us

2.11 us

2.08 us

Proposed: 0002-CLJ-1005-use-transient-map-in-zipmap.patch, doesn't use internal apis and is approximately the same as far as performance improvement.

Screened by: Alex Miller

Environment

None

Activity

Show:
Michał Marczyk
September 14, 2014, 6:48 PM

Thanks, Andy. It was straightforward to update – an automatic rebase. Here's the updated patch.

Ghadi Shayban
September 22, 2014, 3:58 PM

New patch using clojure.lang.RT/iter, criterium shows >30% more perf in the best case. Less alloc probably but I didn't measure. CLJ-1499 (better iterators) is related

Justin Spedding
November 29, 2018, 6:08 PM

4 years later, this zipmap implementation in the core namespace is still not using a transient map internally. Is there a reason why this was never applied?

Alex Miller
November 29, 2018, 6:18 PM

Multiple approaches proposed here, no consensus approach determined yet. Needs some focus time to narrow that down, and hasn’t been a priority yet.

Alex Miller
December 11, 2020, 7:09 PM

Applied for 1.10.2-rc1

Fixed

Assignee

Unassigned

Reporter

Michał Marczyk

Labels

Approval

Ok

Patch

Code

Fix versions

Affects versions

Priority

Major