Why do we put GMP allocations on GHC heaps?

Gergely Risko gergely at risko.hu
Wed Oct 23 11:44:18 UTC 2013


On Wed, 23 Oct 2013 08:57:55 +0000, Simon Peyton-Jones <simonpj at microsoft.com> writes:

> Gergely
>
> Edward has it right.  Functional programs allocate a lot of
> intermediate stuff.  ((a+b)*c-d) allocates two intermediate Integers
> and discards them pretty soon afterwards.  GHC's code generator and
> garbage collector are good at both allocation and gc of young dead
> objects.

Thanks for the confirmation.

> Using malloc/free would require a finaliser-style interface, which is
> significantly less efficient.  That might matter a lot for an
> arithmetic-intensive program, and not at all for one where Integer
> arithmetic was incidental.

Do we have benchmarks for this in nofib?  If I do some mockups, can I
believe what (specific tests from) nofib says?  Or does researching for
a replacement first includes the task of writing a benchmark suite?

> However, you could perfectly well imagine a third package (alongside
> integer-gmp and integer-simpl), let's call it integer-gmp-malloc.

Actually it's not clear to me, how would you implement the non-malloc
integer-gmp as a package?  Can haskell packages integrate with the GC
that deep?

> See also http://ghc.haskell.org/trac/ghc/wiki/ReplacingGMPNotes
>
> Please do record the information or insights you get on a GHC wiki
> page!

Yes, I've definitely read through those kind of wiki articles.  I try to
only ask stuff that is not documented there.

If I figure out anything in addition, I'll document, thanks.

Gergely



More information about the ghc-devs mailing list