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

Vincent Hanquez tab at snarc.org
Wed Nov 2 10:58:30 CET 2011


On 11/02/2011 09:51 AM, Eugene Kirpichov wrote:
> Hi Claude,
>
> I suspected that the issue could be about unsafe foreign imports - all imports 
> in the cairo bindings are "safe".
> I compiled myself a version of cairo bindings with the "rectangle" and "fill" 
> functions marked as unsafe.
>
> Unfortunately that didn't help the case at all, even though the core changed 
> FFI calls from "__pkg_ccall_GC" to "__pkg_ccall". The performance stayed the 
> same; the overhead is elsewhere.
>
doing a ltrace, i think the reason is pretty obvious, there's a lot of GMP calls:

__gmpz_init(0x7f5043171730, 1, 0x7f5043171750, 0x7f5043171740, 0x7f50431d2508) = 
0x7f50431d2530
__gmpz_mul(0x7f5043171730, 0x7f5043171750, 0x7f5043171740, 0x7f50431d2538, 
0x7f50431d2508) = 1
__gmpz_init(0x7f5043171728, 1, 0x7f5043171748, 0x7f5043171738, 0x7f50431d2538) = 
0x7f50431d2568
__gmpz_mul(0x7f5043171728, 0x7f5043171748, 0x7f5043171738, 0x7f50431d2570, 
0x7f50431d2538) = 1
__gmpn_gcd_1(0x7f50431d2580, 1, 1, 1, 1)     = 1
<repeated thousand of time>

before each call cairo calls.

just to make sure, the C version doesn't exhibit this behavior.

-- 
Vincent



More information about the Haskell-Cafe mailing list