[erlang-questions] Input too fast, shootout and very weird behaviour with binaries

Paulo Sérgio Almeida psa@REDACTED
Tue Jul 17 19:33:15 CEST 2007


Hi all.

Inspired by the discussion some time ago about using a line-oriented 
port getting data from stdin, I wrote a program for the language 
shootout's reverse complement. The first version, which I intend to 
submit, uses lists for input, and manages to finish (in my laptop) in 12 
seconds, after using about 600MB of memory. Memory consumption was 
increasing very fast, but the input file was not too large and the 
program did ok.

Then I wrote a version using binaries, thinking it would be better, and 
a very weird thing happened. Memory comsumption stayed very low, about 
80MB, but it took almost 53 MINUTES to finish, always maxing CPU usage. 
The result was correct, as for the first version.

Doing
time erl -noinput -run revcomp main 1 < ../input-2500000 > ../o

resulted, for the first version:

real    0m12.179s
user    0m9.557s
sys     0m2.160s

and for the second:

real    52m44.740s
user    51m51.432s
sys     0m3.741s

This is very weird and I cannot imagine what the erlang VM might be 
doing. It does not make sense and there must be some kind of bug either 
in the emulator or the code generated by HIPE. If someone has time to 
spare and wants to play around, I attach both versions here.

Regards,
Paulo Almeida



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: revcomp.erl-v1
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070717/b4b75356/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: revcomp.erl-v2
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070717/b4b75356/attachment-0001.ksh>


More information about the erlang-questions mailing list