<div>Thanks Robby and Tobias.</div><div><br></div><div>Robby said:</div><div>--------------------</div><div>You&#39;re doing way more work in the timed portion of the place version than you are in the non-place one. In the places one you&#39;re creating the test-vector 3 times, once in the original place (that you don&#39;t explicitly create) and once in each of the places that you create. Your code is also copying the vector from one place to another in the places one (ignoring the one that was created when the place was created).</div>

<div>--------------------</div><div>Isn&#39;t there always going to be this kind of overhead involved when using places because of the rerequire of the original module in each place created?</div><div><br></div><div>I checked the timing of creating test-vector and its relatively small but most of the overhead appears to be in communicating test-vector to the places </div>

<div><br></div><div>Also when I change my code to include the extra place-channel-gets and place-channel-puts Tobias suggested  I get almost exactly the same timings as without these extra place-channel-gets and puts <br>

</div><div>I.e.</div><div>
test-vector-size 5000000<br>With places cpu time: 13993 real time: 9381 gc time: 763<br>Without places cpu time: 7472 real time: 7804 gc time: 4334</div><div><br></div><div>But  a lot of the overhead appears to be in the communicating of test-vector to the places.</div>

<div>When instead of: (place-channel-put ch (test-function (place-channel-get ch)))</div><div>I put: (place-channel-put ch (test-function test-vector))<br>
</div><div>then I get timings of:</div><div>test-vector-size 5000000<br>With places cpu time: 10218 real time: 5623 gc time: 0<br>Without places cpu time: 7613 real time: 7820 gc time: 4492
</div><div><br></div><div><br></div>
<div>Is this the way &quot;places&quot; work.</div><div>When a racket program executes a module that contains a place,  it:</div><div>1)executes the code in the module until it comes to the place form</div><div>2) It then creates a new racket instance (a place) containing a new module.</div>


<div>3) That new module in the new racket instance requires the original module containing the place.</div><div>4) The body of the place form is then executed in the new racket instance (the place)</div><div>5) Simultaneously the original module in the original racket instance continues executing.</div>


<div>6)The original and the new module (the two racket instances) communicate via place-channels</div><div><br></div><div>So in effect in my code I&#39;ve created 3 racket instances (3 places) executing on a 2 core machine.</div>

<div>If I change my code so I&#39;m executing 2 places instead of 3, I would have thought that would improve the timings, but that doesn&#39;t appear to be the case.</div>
<div><br></div><div>The following code (2 places only, the original Racket instance and one place) takes more real-time than my original code (3 places).  (8607 instead of 5623)</div><div><br></div><div>I&#39;m not clear why that should be the case?</div>


<div><br></div><div>The timings are:</div><div>test-vector-size 5000000<br>With places cpu time: 8097 real time: 8607 gc time: 1856<br>Without places cpu time: 7238 real time: 7476 gc time: 4024</div><div><br></div><div>

for the code:</div>
<div>-------------------------------</div><div>place-timing-test5-execute.rkt</div><div>-------------------------------</div><div>#lang racket<br>(require &quot;place-timing-test5.rkt&quot;)<br>(printf &quot;test-vector-size ~a&quot; test-vector-size)<br>


(newline)<br>(display &quot;With places &quot;)<br>(time (places-main))<br>(display &quot;Without places &quot;)<br>(time (noplaces-main))<br><br>(system &quot;PAUSE&quot;)</div><div><br></div><div>------------------------------------</div>


<div>
place-timing-test5-execute.rkt
</div><div>-------------------------------------</div><div>#lang racket<br><br>(provide places-main noplaces-main test-vector-size)<br>(define test-vector (build-vector 5000000 +))<br>(define test-vector-size (vector-length test-vector))<br>


(define (test-function vectr) (apply + (vector-&gt;list (vector-map sqrt vectr))))<br><br><br>(define (places-main)<br>      (test-function test-vector)<br>      (define place1<br>           (place ch<br>                   (begin<br>


                       (place-channel-put ch #t)<br>                        (place-channel-put ch (test-function test-vector)))))<br><br>       (place-channel-get place1)<br>       (place-channel-get place1)<br>       (place-wait place1)<br>


       (void))<br><br>(define (noplaces-main) <br>    (test-function test-vector)<br>    (test-function test-vector)<br>    (void))<br></div><div>------------------</div><div><br></div><div>VERSUS</div><div><br></div><div>

test-vector-size 5000000<br>With places cpu time: 10218 real time: 5623 gc time: 0<br>Without places cpu time: 7613 real time: 7820 gc time: 4492</div><div><br></div><div>-------------------------------------</div><div>place-timing-test-execute.rkt</div>

<div>-------------------------------------</div><div>#lang racket<br>(require &quot;place-timing-test.rkt&quot;)<br>(printf &quot;test-vector-size ~a&quot; test-vector-size)<br>(newline)<br>(display &quot;With places &quot;)<br>

(time (places-main))<br>(display &quot;Without places &quot;)<br>(time (noplaces-main))<br><br>(system &quot;PAUSE&quot;)<br></div><div><br></div><div><br></div><div>------------------------</div><div>place-timing-test.rkt</div>

<div>------------------------</div><div>#lang racket<br><br>(provide places-main noplaces-main test-vector-size)<br>(define test-vector (build-vector 5000000 +))<br>(define test-vector-size (vector-length test-vector))<br>

(define (test-function vectr) (apply + (vector-&gt;list (vector-map sqrt vectr))))<br><br><br>(define (places-main)<br>      (define place1<br>          (place ch<br>                   (begin<br>                       (place-channel-put ch #t)<br>

                       (place-channel-put ch (test-function test-vector)))))<br><br>       (define place2<br>             (place ch<br>                     (begin<br>                         (place-channel-put ch #t)<br>
                         (place-channel-put ch (test-function test-vector)))))<br>
<br>       (place-channel-get place1)<br>       (place-channel-get place2)<br><br><br>        (place-channel-get place1)<br>        (place-channel-get place2)<br><br>       (place-wait place1)<br>       (place-wait place2)<br>

       (void))<br><br>(define (noplaces-main) <br>    (test-function test-vector)<br>    (test-function test-vector)<br>    (void))<br></div><div>--------------------</div><div><br></div><div><br></div><br><div class="gmail_quote">


On Thu, Mar 14, 2013 at 8:28 AM, Tobias Hammer <span dir="ltr">&lt;<a href="mailto:tobias.hammer@dlr.de" target="_blank">tobias.hammer@dlr.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


As Robby said, the time should only include both place-channel-get and -put calls to make it comparable.<br>
But this is not enough, because the (place ...)-creation seems to be non-blocking, i.e they might not be started up yet when the codes reached the first -put.<br>
<br>
This can be solved by explicitly synchronizing the places with the main program:<div><br>
<br>
(define (places-main)<br>
    (define place1<br>
       (place ch<br></div>
              (begin<br>
                (place-channel-put ch #t)<br>
                (place-channel-put ch (test-function (place-channel-get ch))))))<br>
<br>
    (define place2<br>
        (place ch<br>
               (begin<br>
                 (place-channel-put ch #t)<br>
                 (place-channel-put ch (test-function (place-channel-get ch))))))<br>
<br>
    (place-channel-get place1)<br>
    (place-channel-get place2)<div><br>
<br>
    (display &quot;With places &quot;)<br>
    (time<br></div><div>
     (place-channel-put place1 test-vector)<br>
     (place-channel-put place2 test-vector)<br>
     (place-channel-get place1)<br></div>
     (place-channel-get place2))<div><br>
    (place-wait place1)<br>
    (place-wait place2)<br>
    (void))<br>
<br>
<br></div>
With this i get the following times<br>
<br>
With places cpu time: 5600 real time: 3199 gc time: 404<br>
Without places cpu time: 3700 real time: 3678 gc time: 2208<br>
<br>
Now its at least faster than the sequential version. But the overhead seems to be still a lot more than i had expected.<br>
<br>
Tobias<div><div><br>
<br>
<br>
<br>
On Thu, 14 Mar 2013 02:23:22 +0100, Harry Spier &lt;<a href="mailto:vasishtha.spier@gmail.com" target="_blank">vasishtha.spier@gmail.com</a>&gt; wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear members,<br>
<br>
I&#39;ve run the following racket program  (as an executable) to test the<br>
performance of places on a windows dual core pentium machine under Vista.<br>
 I&#39;ve run this with various sizes for test-vector.  Even when the amount of<br>
computation is large (test-vector-size = 5000000) the performance with the<br>
computation split over two places takes more than double the time to<br>
complete as when no places are used.<br>
<br>
I&#39;m not clear why on a dual core machine the performance wasn&#39;t better with<br>
 the computation split over two places than with no places. In fact the<br>
results are the opposite with the performance for no places always double<br>
that for two places.<br>
<br>
--------------------------------------<br>
place-timing-test-executable.rkt<br>
---------------------------------------<br>
#lang racket<br>
(require &quot;place-timing-test.rkt&quot;)<br>
(printf &quot;test-vector-size ~a&quot; test-vector-size)<br>
(newline)<br>
(display &quot;With places &quot;)<br>
(time (places-main))<br>
(display &quot;Without places &quot;)<br>
(time (noplaces-main))<br>
<br>
(system &quot;PAUSE&quot;)<br>
<br>
<br>
-----------------------<br>
place-timing-test.rkt<br>
-----------------------<br>
#lang racket<br>
(provide places-main noplaces-main test-vector-size)<br>
(define test-vector (build-vector 5000000 +))<br>
(define test-vector-size (vector-length test-vector))<br>
(define (test-function vectr) (apply + (vector-&gt;list (vector-map sqrt<br>
vectr))))<br>
<br>
(define (places-main)<br>
    (define place1<br>
       (place ch (place-channel-put ch (test-function (place-channel-get<br>
ch)))))<br>
<br>
    (define place2<br>
        (place ch (place-channel-put ch (test-function (place-channel-get<br>
ch)))))<br>
<br>
    (place-channel-put place1 test-vector)<br>
    (place-channel-put place2 test-vector)<br>
    (place-channel-get place1)<br>
    (place-channel-get place2)<br>
    (place-wait place1)<br>
    (place-wait place2)<br>
    (void))<br>
<br>
(define (noplaces-main)<br>
    (test-function test-vector)<br>
    (test-function test-vector)<br>
    (void)<br>
-------------------------------<br>
<br>
These are the results for different sizes of test-vector.  The amount of<br>
computation is linear to the size of test-vector.<br>
<br>
test-vector-size 100000<br>
With places cpu time: 1685 real time: 856 gc time: 0<br>
Without places cpu time: 187 real time: 170 gc time: 94<br>
Press any key to continue . . .<br>
-----<br>
test-vector-size 1000000<br>
With places cpu time: 3822 real time: 2637 gc time: 265<br>
Without places cpu time: 1201 real time: 1191 gc time: 452<br>
Press any key to continue . . .<br>
-------<br>
test-vector-size 5000000<br>
With places cpu time: 15787 real time: 23318 gc time: 1373<br>
Without places cpu time: 7769 real time: 9456 gc time: 4461<br>
Press any key to continue . . .<br>
------<br>
<br>
Thanks,<br>
Harry Spier<br>
</blockquote>
<br>
<br></div></div><span><font color="#888888">
-- <br>
---------------------------------------------------------<br>
Tobias Hammer<br>
DLR / Institute of Robotics and Mechatronics<br>
Muenchner Str. 20, D-82234 Wessling<br>
Tel.: 08153/28-1487<br>
Mail: <a href="mailto:tobias.hammer@dlr.de" target="_blank">tobias.hammer@dlr.de</a><br>
</font></span></blockquote></div><br>