[erlang-questions] Erlang shows its slow face!
Sun Nov 14 12:32:42 CET 2010
On Sun, Nov 14, 2010 at 11:55 AM, Tony Rogvall <tony@REDACTED> wrote:
> On 14 nov 2010, at 10.17, Hynek Vychodil wrote:
> Good idea but it seems that native (HiPE) compiler does this
> optimization for you when you keep staying in one module. (I also
> keeps exporting only main function. It can possibly take effect here
> also.) In BEAM it gives you 50% performance gain. Anyway Erlang is not
> right tool for this job. You should use NIF if performance matter.
> pythag4(N) when is_integer(N) -> pythag4(N,1).
> I have implemented several small Erlang programs that beat "native" C code.
> Most of the time the C programs where badly/hastily written, but that is the
> point ;-)
> You must select the algorithm and the implementation wisely, and of course
> use the golden rule "Make it work, then make it fast". I would add, if it is
> This does not imply that you should write your program unnecessary slow to
> start with!
> Any how. A couple of months ago I implemented the AKS algorithm in Erlang.
> The AKS algorithm is a deterministic primality test algorithm
> I benchmarked this implementation with an implementation in C++.
> I was shocked: The Erlang version was about 5 times faster, NOT using
> obvious parallelism.
> In this case I would suspect that garbage collection is the major
> contributor! The implementation use
> a lot of temporary polynomials intermediate results. A copy collector does
> the trick.
> "Have run Make so many times I dunno what's installed anymore"
When Erlang implementation is faster than C implementation *is* badly
written even it can be for maintainability or haste reason. C++ is
another beast. Pun intended. I have similar experience to you but when
I found that Erlang implementation is faster then I would look how is
it possible and you are right, usually it is memory issue. Anyway
every time you can do same tricks as Erlang does but you will end up
with "half and error prone implementation of Erlang". You can also do
tricks in C which you can't in Erlang. Can you write k/v store which
is able do 200 millions of look up operations per second on one 2.4GHz
i5 core? Anyway HiPE compiler does very good work here. If I count it
correctly pythag3 and pythag4 does about hundred millions checks per
seconds. Very good result I think.
--Hynek (Pichi) Vychodil
Analyze your data in minutes. Share your insights instantly. Thrill
your boss. Be a data hero!
Try GoodData now for free: www.gooddata.com
More information about the erlang-questions