Hi Claude,<div><br></div><div>I suspected that the issue could be about unsafe foreign imports - all imports in the cairo bindings are &quot;safe&quot;.</div><div>I compiled myself a version of cairo bindings with the &quot;rectangle&quot; and &quot;fill&quot; functions marked as unsafe.</div>
<div><br></div><div>Unfortunately that didn&#39;t help the case at all, even though the core changed FFI calls from &quot;__pkg_ccall_GC&quot; to &quot;__pkg_ccall&quot;. The performance stayed the same; the overhead is elsewhere.</div>
<div><br><div class="gmail_quote">On Wed, Nov 2, 2011 at 1:31 PM, Claude Heiland-Allen <span dir="ltr">&lt;<a href="mailto:claude@goto10.org">claude@goto10.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 02/11/11 09:17, Eugene Kirpichov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I&#39;ve got two very simple programs that draw a very simple picture using<br>
cairo, doing a couple hundred thousand of cairo calls.<br>
One program is in C++. The other is in Haskell and uses the cairo library<br>
bindings.<br>
<br>
The C++ program completes in a fraction of a second, the Haskell program<br>
takes about 7-8 seconds to run. They produce exactly the same output.<br>
<br>
What could be at fault here? Why are the cairo bindings working so slow? (I<br>
suppose there isn&#39;t too much cairo-specific stuff here, perhaps it&#39;s a<br>
general FFI question?)<br>
</blockquote>
<br></div>
I filed a bug report about this some months ago, having noticed similar slowness:<br>
<br>
gtk2hs ticket #1228 &quot;cairo performance is very bad&quot;<br>
<a href="http://hackage.haskell.org/trac/gtk2hs/ticket/1228" target="_blank">http://hackage.haskell.org/<u></u>trac/gtk2hs/ticket/1228</a><br>
<br>
My conclusion was that it isn&#39;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&#39;t see through to optimize aggressively, or possibly some Double / CDouble / realToFrac rubbishness.<br>

<br>
<br>
Claude<br>
<br>
______________________________<u></u>_________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Eugene Kirpichov<br>Principal Engineer, Mirantis Inc. <a href="http://www.mirantis.com/" target="_blank">http://www.mirantis.com/</a><br>Editor, <a href="http://fprog.ru/" target="_blank">http://fprog.ru/</a><br>

</div>