Avoiding CAF's

Simon Marlow simonmarhaskell at gmail.com
Mon May 21 05:52:47 EDT 2007


Neil Mitchell wrote:
> Hi Ian and Simon,
> 
>> Ian said:
>> Does the boxing not get optimised out?
>> Is the FFI imported function exported from the module?
> 
> http://hpaste.org/1882 (replicated at the end of this message in case
> the hpaste is not around forever, but clearly layout and syntax
> colouring)
> 
> Thats the main branch, which is the bit I want to make go faster, if
> at all possible. The FFI call is not exported, I have module
> Main(main) at the top. From what I can see, the function is being
> called, then:
> 
>    case Main.$wccall GHC.Prim.realWorld# of wild_X28 { (# ds_d2ad,
> ds1_d2ac #) ->
> 
> i.e. it has had an artificial box put around the answer. It may be
> impossible to eliminate this, but if it is, I'd like to try.

There's no actual box here.  The ccall returns an unboxed tuple with two 
components, one of which has void type (State# RealWorld), so it has no runtime 
representation.  The other component will be stored/returned in a register. 
Make sure your ccalls are annotated with unsafe, if you're not already.

> I realise all of this trickery is against the spirit of a pure
> functional language, and is making assumptions that are not required
> to remain true. Right now I just want the fastest possible benchmarks
> though.

Ok, but suppose you get some good results - what's the point?  None of this is 
guaranteed to work tomorrow.  Why not aim for a robust translation into Core 
that preserves the semantics?  It can't be that hard to pass around a State# 
RealWorld, can it?

Cheers,
	Simon



More information about the Glasgow-haskell-users mailing list