[Haskell-cafe] Int is broken [Was: Different answers on different machines]

Carter Schonwald carter.schonwald at gmail.com
Mon Jun 3 09:23:25 CEST 2013


Tommy, respectfully,

I have quite a few bits of code where a bad branch predictor in a tight
inner loops makes code 10x slower.

you are welcome to do your own experimentation so that you too can learn by
branches are bad in tight loops.  (even if the branch predictor is doing
its job, there will be a measurable slow down, albeit less than 10x)

Please shift this conversation to the libraries list if you want to
actually make a concrete libraries change proposal. Otherwise I don't
understand your contentions. Int is "native register sized integer" not
"integer that i need to exception handle because I used int instead of
integer because of premature optimization in my web app or project euler
codes"

My opinions are based upon spending all of my time over the past year
working on writing robustly performant numerical codes. Some of them are
actually faster than the standard fortran ones.

My point being: as mentioned above, by others much more articulate than I,
unless you have performance related reasons, always use Integer instead of
Int. There is never a good reason to use Int instead of Integer unless it
will change the performance characteristics of your code. Asking for Int to
pretend to be Integer because you wanted to do premature optimization and
then it didn't behave like Integer is a no go.

I am happy to direct you towards further reading if you'd like to learn
about writing performance sensitive software:

the intel optimization
manual<http://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf>has
many good ideas (eg Structure of Arrays, which is essentially used by
the haskell Vector lib) that are actually realized by the more performant
haskell libraries.

 Likewise, for an informative idea of the cost models for various
operations on the CPU, the agner fog
<http://agner.org/optimize/#manuals> manuals
are actually very educational.

merry hacking
-Carter



On Mon, Jun 3, 2013 at 3:07 AM, Tommy Thorn <tt1729 at yahoo.com> wrote:

> On Jun 2, 2013, at 23:58 , Carter Schonwald <carter.schonwald at gmail.com>
> wrote:
>
> > Indeed, as Dan says, theres the safeint library and the Integer type.
> >
> > If the Int type had either of these semantics by default, many many
> performance sensitive libraries would suddenly have substantially less
> compelling performance.  Every single operation that was branchless before
> would have a branch *every* operation..... this would be BAD.
>
> I'd like to see actual data, measurements of actual wall-time impact on
> real code on modern hardware,
> not assumptions.
>
> Tommy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130603/f8a946f5/attachment.htm>


More information about the Haskell-Cafe mailing list