Welcome! Please see the About page for a little more info on how this works.

0 votes
in Collections by

Placeholder for unrolled small maps enhancement (companion for vectors at CLJ-1517).

3 Answers

0 votes
by

Comment made by: jafingerhut

Is there an expectation that these would perform better that PersistentArrayMap?

0 votes
by

Comment made by: ztellman

Yes, in some cases significantly so, for three reasons (in rough order of importance):

  • positional constructors, without any need for array instantiation/population
  • short-circuiting equality checks using hash comparisons
  • no iteration on any operation

There are a series of benchmarks at https://github.com/ztellman/cambrian-collections/blob/master/test/cambrian_collections/map_test.clj#L64-L148, which compare operations against maps with both keywords (which don't benefit from the hash comparisons) and symbols (which do). The 7-entry map cases cause the unrolled maps to overflow, so they only exist to test the overflow mechanism.

I've run the benchmark suite on my laptop, and the results are at https://gist.github.com/ztellman/961001e1a77e4f76ee1d. Some notable results:

The rest of the benchmarks are marginally faster due to unrolling, but most of the performance benefits are from the above behaviors. In a less synthetic benchmark, I found that Cheshire JSON decoding (which is 33% JSON lexing and 66% data structure building) was sped up roughly 30-40%.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1610 (reported by alexmiller)
...