Skip to:
I'm seeing a performance problem with clojurescripts defmulti:
dispatch is slow when there is no match for the dispatch value
slowness increases as the method-table grows ~O
Verified with optimisations :none and :advanced.
Verified not to be an issue for Clojure on JVM.
Example 1: Dispatch and hit
Example 2: Dispatch and miss
Example 3: More methods (x10)
fixed https://github.com/clojure/clojurescript/commit/957cb8756f5a4b71bcc96d0d08943c83242dccfc
Attached patch with fix. The patch applies the same changes that were applied to Clojure in the following commit: https://github.com/clojure/clojure/commit/6d305a0959183acb75fc44f9192eed2abf33bf25. Benchmarks of before and after in my machine are shown below.
Example | Before | After1 | 2.642308 msecs | 3.099353 msecs2 | 72.614162 msecs | 7.423098 msecs3 | 212.955697 msecs | 19.691014 msecs
I think this affects a common use case: using defmulti as an extension point but rely on default behaviour most of the time.
I'm seeing a performance problem with clojurescripts defmulti:
dispatch is slow when there is no match for the dispatch value
slowness increases as the method-table grows ~O
Verified with optimisations :none and :advanced.
Verified not to be an issue for Clojure on JVM.
Example 1: Dispatch and hit
Example 2: Dispatch and miss
Example 3: More methods (x10)