On Sat, Aug 6, 2011 at 8:11 PM, Michael Snoyman <span dir="ltr">&lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Without having delved into the issue in any great depth, I had a<br>
possible idea on this point. How about storing an IORef containing a<br>
time and the text representations you need. Whenever you need to get<br>
the time, compare the time in the IORef with the current time, and if<br>
they&#39;re different, update appropriately. Bonus points: store in an<br>
unpacked datatype and use a Builder instead of String. Would this (in<br>
theory) work?<br></blockquote><div><br>We do something similar to this, except we get the thread to recompute the date -- otherwise every second you have a race condition possibility where multiple threads compete to write the new thread into the IORef. If there&#39;s no activity, the date thread goes to sleep, the code to get the current date notices that the date is stale, and then it wakes the thread and recomputes the new date itself. Again, I&#39;m not sure if it&#39;s worth it in the general case, but during periods of high load I think it helps to get as much stuff out of the processing threads as possible.<br>
<br>G<br></div></div>-- <br>Gregory Collins &lt;<a href="mailto:greg@gregorycollins.net" target="_blank">greg@gregorycollins.net</a>&gt;<br>