metosin / jsonista

Clojure library for fast JSON encoding and decoding.
https://cljdoc.org/d/metosin/jsonista
Eclipse Public License 2.0
422 stars 30 forks source link

Keyword deserializer slower than custom cache #56

Open bsless opened 3 years ago

bsless commented 3 years ago

This is more of an observation than a concrete issue, but it looks like memoizing keyword and providing it as a decode-key-fn give better throughput than the default keyword deserializer. I tried several approaches, a concurrent hash map, thread local hash map, and Ben Mane's Caffeine cache, all give better performance. The best implementation wasn't immediately evident between them. Still, this could be an optimization worth examining. The big difference in CPU utilization was in clojure.lang.Keyword/intern being significantly slower than just a regular lookup.