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

2017-03-09 Thread Alex Miller
A ticket is fine. If someone wants to dig into it further, please feel free to add info to the ticket. On Thursday, March 9, 2017 at 9:07:31 AM UTC-6, Bendlas wrote: > > 2017-03-09 12:34 GMT+01:00 'bertschi' via Clojure < > clojure@googlegroups.com>: > > Thanks for your comments. As suggested I

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

2017-03-09 Thread Herwig Hochleitner
2017-03-09 12:34 GMT+01:00 'bertschi' via Clojure : > 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

Re: Ensure more concurrency

2017-03-09 Thread 'bertschi' via Clojure
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 ... (defn write-skew [de-ref] (let [cats (ref 1) dogs (ref 1) john (future (dosync

Re: Ensure more concurrency

2017-03-08 Thread Herwig Hochleitner
2017-03-06 12:06 GMT+01:00 'bertschi' via Clojure : > From the docs it says "Allows for more concurrency than (ref-set ref @ref)". > I would read that as "runs at least as fast as (ref-set ref @ref)", but > using (ref-set dogs @dogs) instead of (ensure dogs) and the same

Re: Ensure more concurrency

2017-03-07 Thread lawrence . krubner
https://clojuredocs.org/clojure.core/ensure Must be called in a transaction. Protects the ref from modification by other transactions. Returns the in-transaction-value of ref. Allows for more concurrency than (ref-set ref @ref) This can be read in two contradictory ways. Protecting a ref

Ensure more concurrency

2017-03-06 Thread 'bertschi' via Clojure
For a lecture I have implemented the write-skew example from Mark Volkmann's article: (defn write-skew [] (let [cats (ref 1) dogs (ref 1) john (future (dosync (when (< (+ @cats @dogs) 3) (alter cats inc mary