jepsen-io / knossos

Verifies the linearizability of experimentally accessible histories.
398 stars 31 forks source link

simplify knossos.redis/log with update-in #1

Closed maxcountryman closed 10 years ago

aphyr commented 10 years ago

Assoc is actually significantly faster than update-in, so I think I'd like to keep this particular case as is.

maxcountryman commented 10 years ago

Oh interesting, is that due to destructuring and the call to get?

aphyr commented 10 years ago

Yeah, you gotta create a seq, call first, call rest, then call apply instead of assoc directly, which means boxing up args as an arraylist, then wrapping that in a seq, etc... ordinarily I wouldn't mind but this code was, if I recall, kinda performance-sensitive. We could totally drop a (defn update) in utils though!

maxcountryman commented 10 years ago

Geez yeah, quite a bit faster it turns out:

user=> (time (dotimes [_ 1e8] (assoc {} :history (conj (:history {}) :a))))
"Elapsed time: 3876.263 msecs"
nil
user=> (time (dotimes [_ 1e8] (update-in {} [:history] conj :a)))
"Elapsed time: 34815.863 msecs"
nil