openFile and threads

Simon Marlow simonmar@microsoft.com
Mon, 13 Jan 2003 17:21:43 -0000


> > Haskell Strings are a common performance bottleneck; for=20
> example when
> > serving files in the Haskell web server I avoided the conversion to
> > Haskell Strings altogether by reading/writing arrays of=20
> bytes (see the
> > paper for details).
>=20
> I was curious to see if this is also the case here. Therefore I just
> pasted the GHC implementation of openFile into Peter's suspicious
> module ('openFile' obtained from
> http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/ba
> se/GHC/Handle.hs---I
> hope this was the right one?) to be able to also profile the GHC
> internal openfile code. Here are the relevant parts of the resulting
> output of the profiler:
>=20
> COST CENTRE                    MODULE               %time %alloc
>=20
> withCString'                   MailStore             39.1   19.7

Interesting - I just looked at the code for withCString and it is being
poorly optimised.  There are several layers of FFI abstraction which
aren't being inlined/deforested away.

Thanks for the pointer, I'll take a look at this.

Cheers,
	Simon