[Haskell-cafe] Ridiculously slow FFI, or cairo binding?

Claude Heiland-Allen claude at goto10.org
Wed Nov 2 10:31:44 CET 2011

On 02/11/11 09:17, Eugene Kirpichov wrote:
> Hello,
> I've got two very simple programs that draw a very simple picture using
> cairo, doing a couple hundred thousand of cairo calls.
> One program is in C++. The other is in Haskell and uses the cairo library
> bindings.
> The C++ program completes in a fraction of a second, the Haskell program
> takes about 7-8 seconds to run. They produce exactly the same output.
> What could be at fault here? Why are the cairo bindings working so slow? (I
> suppose there isn't too much cairo-specific stuff here, perhaps it's a
> general FFI question?)

I filed a bug report about this some months ago, having noticed similar 

gtk2hs ticket #1228 "cairo performance is very bad"

My conclusion was that it isn't FFI being slow, but some other reason, 
possibly too much redirection / high level fanciness in the 
implementation of cairo bindings that the compiler can't see through to 
optimize aggressively, or possibly some Double / CDouble / realToFrac 


More information about the Haskell-Cafe mailing list