ensure causes more contention than ref-set [Was: Ensure more concurrency]

82 views
Skip to first unread message

Herwig Hochleitner

unread,
Mar 9, 2017, 10:07:31 AM3/9/17
to clo...@googlegroups.com, cloju...@googlegroups.com
2017-03-09 12:34 GMT+01:00 'bertschi' via Clojure <clo...@googlegroups.com>:
> Thanks for your comments. As suggested I ran a small benchmark of both
> versions. Turns out that the difference between (ref-set ref @ref) and
> ensure is huge ...
> I'm running clojure 1.8.0 by the way. According to VisualVM the (ref-set ref @ref) version spends most of its time in clojure.lang.LockingTransaction$RetryEx.<init> () while ensure gets basically stuck (> 99%) at clojure.lang.LockingTransaction.tryWriteLock ().

On my machine, results don't look as bad, but ensure still has a
significantly worse bad case (the upper quantile), the best case
(lower quantile) is about on par with ref-set.
Disabling tiered compilation helps close the gap (possibly due to lock
straightening?) but ref-set still comes out ahead.

The tests run significantly faster on server compilation than on
tiered compilation and also run faster on clojure-1.9.0-alpha14, than
on -1.8.0

I'm on % java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

Here is a gist with my test program + output listings:
https://gist.github.com/bendlas/6e3b24bb639c248fdc47d192f5117c39

cc clojure-dev:
is this ready for a ticket? do we need any more information to show
what's going on?

Alex Miller

unread,
Mar 9, 2017, 10:29:41 AM3/9/17
to Clojure Dev, clo...@googlegroups.com
A ticket is fine. If someone wants to dig into it further, please feel free to add info to the ticket.
Reply all
Reply to author
Forward
0 new messages