<br><div class="gmail_quote">On Mon, Apr 28, 2008 at 6:09 PM, Daniil Elovkov <<a href="mailto:daniil.elovkov@googlemail.com">daniil.elovkov@googlemail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello<br>
<br>
Somewhat on the topic of optimistic evaluation, I've just thought of another way to evaluate thunks.<br>
<br>
When the program is about to block on some IO, what if we start a thread to evaluate (any) unevaluated thunks. We'll have additional system thread, but the blocked one will not actually consume any processor time.<br>
<br>
This would take place only when the program is compiled as threaded and run with -N k, k>1.<br>
<br>
The RTS knows at least about some operations that will block, those which IO operations are implemented with. for example. It could merely start a process of evaluating any (or something more clever) outstanding thunks right before going into one of those operations and stop it when it's back.<br>
<br>
Of course, it's not like optimistic evaluation because we don't avoid creating thunks. But in a sense it's similar. It could also be compared with incremental garbage collection :)<br>
<br>
Has something like that been done, discussed?<br>
</blockquote><div><br>This sounds like it could be helpful in certain circumstances, but in many cases it could probably lead to unpredictable (and uncontrollable!) memory usage. I could imagine a situation where my program is running along just fine, and then one day it takes a long time to do a read from the network due to latency or whatever, and suddenly memory usage shoots through the roof, due to evaluation of some infinite (or even just very large) data structure. <br>
<br>-Brent<br></div></div>