[erlang-questions] how to do faster integer operations (was: some language changes)

Paul Mineiro <>
Thu Jun 7 09:09:25 CEST 2007


On Thu, 7 Jun 2007, Matthias Lang wrote:

> Paul Mineiro writes:
>
>  > It's been a good lesson to discover that using less than the full machine
>  > width for integers leads to significant speed up.  Is there a FAQ for
>  > performance where this kind of knowledge is accumulated?
>
> I've shied away from putting optimisation tricks in the FAQ. Taking
> the current information as an example, I could write something like:
>
>   Q: I have some limited-width-integer-intensive code which I want
>      to speed up, what do I do?
>
>   A: If the integer width is within a few bits of 32 bits and you're
>      running on a 32 bit CPU, try moving to a 64 bit machine.
>
> It doesn't seem like a _frequently_ asked question, it's terribly tied
> to the state of hardware right now, and, last but not least, I find it
> hard to get excited about a radical speedup which improves things to
> "only" 10x slower than the straightforward answer, which is "do it in C".

Wrt the straightforward answer, port and linked-in driver actually had
worse performance than straight Erlang with hipe.  So it's not clear how
to do it in C while maintaining a desirable job, except maybe to write
a new BIF which I couldn't find any documentation on (and I assume is
generally discouraged).

By the way, is it expected that the port and linked-in driver versions
would be slower than native Erlang with hipe?  I was guessing it's
because the C executes in circa 100ns so communication overhead was
dominating.

>
> I'm still secretly hoping that someone will find neat improvement.
>
> Matthias
>

werd.

-- p



More information about the erlang-questions mailing list