Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

I've had good luck using VisualVM to find code bottlenecks. But now it shows that all the time is spent within a LockingTransaction. Are there any tricks for getting performance results within transactions?

profileTransaction.png gist

1 Answer

0 votes
selected by
Best answer

I'm not sure there's a good way to really see detail within a transaction. Transactions should usually be as simple as possible as they are critical sections subject to retry, so I'm usually more concerned about things like contention for ref updates and for that you probably want different profiler techniques (looking for waiting/stalled threads), etc.

If I were at this point, I think instead of a profiler I would try to use my brain tool to think about what work and/or contention is in the transaction that could either be pulled out of the critical section, or if references could be de-tangled so coordination is not required.

If you want to share any more info about the references or transaction code, that might help spark ideas along those lines.

Thanks Alex!  need to use the braintool, eh!  the easiest description i can give is that it follow Rich Hickey's ant simulation code (cf. https://github.com/ilmotta/clojure-ants-simulation/blob/master/README.org).  i have tried to keep the code within my `dosync` loops quite small, generally containing only `alter` statements.  but at least using VisualVM i can't even tell WHICH dosync's transactions (there are several) is consuming the time.