Int64 and efficiency

Simon Marlow simonmar at
Mon Jun 6 10:24:36 EDT 2005

On 06 June 2005 12:44, Ketil Malde wrote:

> Recently, Marcin 'Qrczak' Kowalczyk posted a micro-benchmark on
> comp.lang.functional, illustrating performance with statically typed
> Int and Integer, and Kogut's dynamically typed automatically-promoted
> numbers.   (Int is fastest, Kogut second, and Integer quite a bit
> slower).
> For fun, I tried to use Int64, but to my surprise it is a lot slower
> than the others.  Marcin suggested I look at stg and hc output (which
> I did without getting much wiser) and made some guesses as to what the
> reasons were.
> I'm curious whether this is typical, and if so, whether there is a
> theoretical reason why Int64 is so slow?  (I would have expected a
> factor of 2-4 worse than Int, but in reality it was about 35x slower)
> (Code attached, replace MyInt as appropriate.)

In theory, you're right.  I haven't investigated your example, but my
guess is that some inlining isn't happening - maybe some missing INLINE
pragmas somewhere.  You might be able to shed more light by comparing
the -ddump-stg output for the Int version with the Int64 version.

Oh, also the Int64 operations are currently performed by foreign calls,
rather than primitives, IIRC.  That will affect speed, but not by a huge


More information about the Glasgow-haskell-users mailing list