metosin / sieppari

Small, fast, and complete interceptor library for Clojure/Script
Eclipse Public License 2.0
207 stars 21 forks source link

Too many async contexts #44

Closed dspiteself closed 3 years ago

dspiteself commented 4 years ago

The current implementation adds a lot of async contexts. The cost of these contexts can very from a Deferred or go block to a full thread for a future. Even the more lightweight cases have a possible cross thread dispatch.

One source of extra context is having separate continue and catch in the async protocol. I provided a pr for consideration here. https://github.com/metosin/sieppari/pull/43

The most interesting improvement is for future and delay

##################### sieppari: sync (sync) #####################

2.10µs -> 1.91µs ###################### sieppari: sync (async) ######################

2.14µs-> 1.99µs

########################### sieppari: core.async (sync) ###########################

77.22µs -> 73.18µs

############################ sieppari: core.async (async) ############################

79.91µs -> 70.62µs

######################## sieppari: future (async) ########################

184.27µs-> 101.52µs

####################### sieppari: delay (async) #######################

122.85µs-> 86.01µs

######################### sieppari: deferred (sync) #########################

101.52µs-> 62.06µs

########################## sieppari: deferred (async) ##########################

124.69µs -> 74.10µs

######################## sieppari: promesa (sync) ########################

5.44µs-> 4.76µs

######################### sieppari: promesa (async) #########################

5.44µs-> 4.74µs