[Haskell-cafe] style question: Writer monad or
unsafeIOToST?
Gregory Wright
gwright at comcast.net
Fri Aug 25 12:06:11 EDT 2006
Hi Bulat,
On Aug 25, 2006, at 3:36 AM, Bulat Ziganshin wrote:
> Hello Gregory,
>
> Friday, August 25, 2006, 3:08:09 AM, you wrote:
>
>> Some performance data: using unsafeIOToST to write log messages
>> directly to the output, the simulation does 10^7 state updates in
>> about 45 seconds
>> on my 1.5 GHz ppc G4. Using LogT, with a list of strings as the
>> monoid,
>> it takes about 7 minutes to do the same, and the system swaps heavily
>> during the last few minutes. Not surprising, given that the mappend
>> operation is not very efficient for the list monoid.
>
> are you sure that you know how monads are implemented? IO/ST monads
> just organize order of execution, without any penalty comparing
> to imperative languages. but other monads and all monad transformers
> add their data to the tuple passed between monad operations. and this
> makes their execution significantly slower. you can read more about
> this
> in http://sigfpe.blogspot.com/2006/08/you-could-have-invented-
> monads-and.html
>
No doubt my understanding of the underlying implementation could
be improved. I will read the reference. Thank you.
> about multi-threading - you can (and should!) use ghc's internal
> concurrency with forkIO. it is a perfect way - with minimal overhead
> and ability to use any Haskell features in each thread without
> fighting against multi-threading implementation
>
I will give this a try when I get to that stage in the project.
Best Wishes,
Greg
> --
> Best regards,
> Bulat mailto:Bulat.Ziganshin at gmail.com
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list