[Haskell-cafe] First call to putStr takes far more time than subsequent calls
roma at ro-che.info
Thu Jul 9 23:45:21 UTC 2015
This is a nice puzzle. However, I don't think it's related to IO.
So far I've traced this to Data.Fixed methods. If you add
evaluate $ floor (2/1 :: Fixed E12)
before the loop, you'll find that the delay decreases significantly
(although doesn't vanish entirely).
How is this related to forcing a time value? Well, UTCTime represents
the time of day as Fixed E12, and when you're evaluating the result of
getCurrentTime, you're calling those methods, (/) and floor.
Using other methods of Fixed E12 before the loop, or replacing E12 with
E9, kills or at least hurts the effect.
There might be some thunks referenced directly or indirectly by those
methods, possibly involving specialization, but I don't see it so far.
I'll let someone else to take it from here.
On 10/07/15 00:07, Ben Gunton wrote:
> Here is the same thing with no console usage, just forcing the time
> value. The first-iteration-delay seems to happen at the first IO-ish
> thing being evaluated.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the Haskell-Cafe