Thanks Rodolfo,<div><br></div><div>I did some further experiments which confirm your results.  I noticed that results vary quite a bit run to run so I ran several times from clean and took the median:</div><div><br></div><div>

prime-pi/acc 4000000 with original make-coroutine:</div><div>cpu time: 2808 real time: 2879 gc time: 1000</div><div>prime-pi/acc 4000000 w/ stream-ref precall with original make-coroutine:</div><div>cpu time: 3214 real time: 3245 gc time: 1342</div>

<div><br></div><div>prime-pi/acc 4000000 with alternate make-coroutine:</div><div>cpu time: 2886 real time: 2996 gc time: 856</div><div>prime-pi/acc 4000000 w/ stream-ref precall and with alternate make-coroutine:</div><div>

cpu time: 2901 real time: 2968 gc time: 1078</div><div><br></div><div><br></div><div>prime-pi 4000000 w/ stream-ref precall and with original make-coroutine:</div><div>cpu time: 5054 real time: 5063 gc time: 2810</div><div>

<br></div><div>It is still interesting that prime-pi performed so badly with the alternate coroutine (and without the precall cludge).  I reran it this way and had to break the process when it ran over 5 minutes.  BTW, with the cludge and the alternate make-coroutine it ran fine, yesterday&#39;s results for that case are bogus as I believe that after a bad run you need to actually bring down DrRacket (not just hit the run button) in order to clean up memory.</div>
<div>
<br></div><div>I think we also confirm that you have a better machine than I :-)</div><div>-joe</div><div><br><div class="gmail_quote">On Wed, Feb 22, 2012 at 8:40 AM, Rodolfo Carvalho <span dir="ltr">&lt;<a href="mailto:rhcarvalho@gmail.com" target="_blank">rhcarvalho@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Joe,<br>
<br><br><div class="gmail_quote"><div>2012/2/22 Joe Gilray <span dir="ltr">&lt;<a href="mailto:jgilray@gmail.com" target="_blank">jgilray@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



Hi Matthew,<div><br></div><div>Thanks for your help.  I really can&#39;t even pretend to understand the make-coroutine code but this is what I&#39;m seeing:</div><div><br></div><div>Original make-coroutine, without stream-ref pre-call =&gt; out of memory (1GB) when running (prime-pi 500000)</div>



</blockquote></div><div><br><br>I tried to run your code here and I also get out of memory in the first case.<br><br><br> </div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div>Original make-coroutine, with stream-ref pre-call =&gt; runs (prime-pi 500000) in about .4 sec</div></blockquote></div><div><br><br>Just as a reference to the other results, here it gives: cpu time: 328 real time: 328 gc time: 94.<br>



<br><br> </div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Alternate make-coroutine, with or without stream-ref pre-call =&gt; runs (prime-pi 500000) in about 28 sec<br>



<br></div></blockquote></div><div><br>With stream-ref pre-call: cpu time: 343 real time: 344 gc time: 78</div></div>Without: cpu time: 19609 real time: 19719 gc time: 9172<br><br><br><br><br>I changed `prime-pi&#39; into `prime-pi/acc&#39; as below and then I got the best results:<br>



<br>(define (prime-pi/acc n)<br>  (let loop-count ([candidate-stream primes]<br>                   [sum 0])<div><br>    (if (&gt; (stream-first candidate-stream) n) <br></div>        sum<br>        (loop-count (stream-rest candidate-stream) (add1 sum)))))<br>



<br><br>With original make-coroutine: cpu time: 234 real time: 235 gc time: 0<br>With Matthew&#39;s make-coroutine: cpu time: 187 real time: 187 gc time: 0<br><br><br><br>All measurements made from within DrRacket using (time (prime-pi 500000)) or (time (prime-pi/acc 500000)).<br>



<br>[]&#39;s<span><font color="#888888"><br><br>Rodolfo<br>
</font></span></blockquote></div><br></div>