How can I see the number of rollbacks in my STM in Clojure?
Asked Answered
U

3

13

How can I see the number of rollbacks in my STM in Clojure?

Unlade answered 25/1, 2011 at 10:12 Comment(0)
P
18

You can't... unless you are willing to cheat:

(defmacro spy-dosync [& body]
  `(let [retries# (atom -1)
         result# (dosync
                   (swap! retries# inc)
                   ~@body)]
     (println "retries count:" @retries#)
     result#))

and then replace your dosync by a spy-dosync.

Pheni answered 25/1, 2011 at 11:16 Comment(0)
B
5

If you're feeling frisky, you could hack the Clojure source and rebuild (it's easy to rebuild the Clojure source). Transaction retries happen in src/jvm/clojure/lang/LockingTransaction.java in the run() method. There's a big for loop there that goes until done or RETRY_LIMIT. The value of i when the loop exits should be the retry count.

Burdett answered 25/1, 2011 at 15:2 Comment(0)
W
2

There is STM-stress test written by Chris Houser which could be useful

Wind answered 26/1, 2011 at 16:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.