ghci and ghc -threaded [slowdown]

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Dec 12 09:03:34 EST 2008


Simon Marlow <marlowsd at gmail.com> wrote:

> Malcolm Wallace wrote:
> > 
> > For the only application I tried, using the threaded RTS imposes a
> > 100% performance penalty - i.e. computation time doubles, compared
> > to the non-threaded RTS.  This was with ghc-6.8.2, and maybe the
> > overhead has improved since then?
> 
> This is a guess, but I wonder if this program is concurrent, and does
> a  lot of communication between the main thread and other threads? 

Exactly so - it hits the worst case behaviour.  This was a naive attempt
to parallelise an algorithm by shifting some work onto a spare
processor.  Unfortunately, there is a lot of communication to the main
thread, because the work that was shifted elsewhere computes a large
data structure in chunks, and passes those chunks back.  The main thread
then runs OpenGL calls using this data -- and I believe OpenGL calls must
run in a bound thread.

This all suggests that one consequence of ghc's RTS implementation
choices is that it will never be cheap to compute visualization data in
parallel with rendering it in OpenGL.  That would be a shame.  This was
exactly the parallelism I was hoping for.

Regards,
    Malcolm


More information about the Glasgow-haskell-users mailing list