<div dir="ltr"><div>Apparently nullary void doesn't have a barricade, so you can write something like</div><div><br></div><div style> (begin (box-cas! ...) (void))</div><div style><br></div><div style>instead of what you have.</div>
<div><br></div><div>I'm not sure why the unary version is barricaded; my guess is that this is something straightforward to fix, but at least there is a workaround in the meantime.</div><div><br>Robby<br><div style><br>
</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 31, 2012 at 9:41 PM, Eric Dobson <span dir="ltr"><<a href="mailto:eric.n.dobson@gmail.com" target="_blank">eric.n.dobson@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I am playing around with futures currently, and am trying to understand how to make my programs faster. The future visualizer is wonderful in understanding whats going on, but it lead me down a track which made my program slower.<div>
<br></div><div>The issue is that void primitive needs to synchronize with the main thread. So when I was using it to provide the return value from my function it was synchronizing. I thought that not calling a function and just referencing a module-level constant would solve this synchronization issue. And it did, but it made the program slower.</div>
<div><br></div><div>What is the rule of thumb for understanding how expensive synchronization is, I assumed it was at least the cost of a couple atomic operations? Also can someone explain why void needs to synchronize with the main thread? </div>
<div><br></div><div><br></div><div>My (reduced) program:</div><div><div>#lang racket</div><div><br></div><div>(define void-t (void))</div><div>#;</div><div>(define-syntax-rule (my-void arg)</div><div> (begin</div>
<div> arg</div><div> void-t))</div><div>(define my-void void)</div><div><br></div><div><br></div><div>(define (run)</div><div> (define N 1000000)</div><div> (define v (box #f))</div><div> (define (f)</div><div> (future</div>
<div> (thunk</div><div> (for ((i (in-range N)))</div><div> (my-void (box-cas! v (unbox v) i))))))</div><div> (define f1 (f))</div><div> (define f2 (f))</div><div> (touch f1)</div><div> (touch f2)</div>
<div> (values))</div><div><br></div><div><br></div><div><br></div><div>(define (time-it)</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div>
<div> (time (run))</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div>
<div>
(time (run))</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div><div> (time (run))</div><div> (collect-garbage)</div><div>
(time (run)))</div>
<div><br></div><div>#|</div><div>(time-it)</div><div>|#</div><div><br></div><div><br></div><div>(require future-visualizer)</div><div>(visualize-futures</div><div> (run)</div><div> #f)</div><div><br></div></div></div>
<br>____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></blockquote></div><br></div>