It is not a deadlock, it seems to be a memory issue.<br><br>I got the same behavior. It seemed to freeze but not long after that:  mmap(size=374341632) failed (error code=12)<div>can't allocate region. </div><div><br></div>
<div>At that point it had allocated 2GB of memory and I hit the virtual memory limit. This was a 32bit emulator on Mac osx lion.</div><div><div><br></div><div>I changed vecTestLoop/3 to<div>...</div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><div>
    L2 = proc(L),</div><div>    erlang:garbage_collect(),   %% <---</div><div>    vecTestLoop( L2, Now, I ).</div></font><div><br></div><div>It ran better. </div><div><br></div><div>A vecTestList with 1000000 elements takes 33M words of memory. Four such lists takes roughly (33M * 4 * 4= ) 0.5+ GB of memory. On top of this garbage will be generated, well in this case almost everything is garbage since your list is recreated at each iteration. </div>
<div><br></div><div>The copying garbage collector needs twice the heap memory, for that process, during a collection. It is not hard to reach the virtual memory limit in this case. You say that your memory consumption was about 1 GB, I think it was a bit more.</div>
<div><br></div><div>// Björn-Egil</div><div><br></div><div><br><br><div class="gmail_quote">2011/11/25 Denis Nesterov <span dir="ltr"><<a href="mailto:copypastor@gmail.com">copypastor@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>Hello! <br></div><br> I wrote simple benchmark code to measure floating-point Erlang performance. And seems that code gets Erlang system into a deadlock :-p <br><br> The thing is that my code doing VERY simple thing - it first generates big list of pairs of Euclidian vectors, then in loop performs sequential mult-add operation on each element. <br>

 When I start one such process per CPU core and list is big enough, the Erlang systems quickly stops responding. <br><br> The code is: <br><br> -module ( bug ). <br> -export ( [start/0] ). <br><br> -record ( vec3, { x=0, y=0, z=0 } ). <br>

<br><br> vec3ma( V0, V1, K ) when is_record( V0, vec3 ) and is_record( V1, vec3 ) and is_number( K ) -> <br>   #vec3{ x = V0#vec3.x + V1#vec3.x * K, y = V0#vec3.y + V1#vec3.y * K, z = V0#vec3.z + V1#vec3.z * K }. <br>
<br>
 %create test data <br> makeVecTestList( L, 0 ) -> L; <br> makeVecTestList( L, N ) -> <br>   E = { #vec3{ x = N * 10.0, y = 20.0, z = 30.0 }, #vec3{ x=10.0, y=20.0, z=-40.0 } }, <br>   makeVecTestList( [ E|L ], N - 1 ). <br>

<br> %Test list-processing code <br> proc( L ) -> proc( L, [] ). <br> proc( [], Acc ) -> Acc; <br> proc( [ { P, V } | T ], Acc ) -> proc( T, [ { vec3ma( P, V, 0.11 ), V } | Acc ] ). <br><br> %process loop <br> vecTestLoop( L, T, I ) -> <br>

   Now = now(), <br>   DT = timer:now_diff( Now, T ) * 1.0e-3, <br>   io:format( "Step~p: ~p ms\n", [I, DT] ), <br>   vecTestLoop( proc( L ), Now, I ). <br><br> start() -> <br>   L = makeVecTestList( [], 1000000 ), <br>

   io:format( "Running test with: ~p\n", [length(L)] ), <br>   spawn( fun() -> vecTestLoop( L, now(), 1 ) end ), <br>   spawn( fun() -> vecTestLoop( L, now(), 2 ) end ), <br>   spawn( fun() -> vecTestLoop( L, now(), 3 ) end ), <br>

   spawn( fun() -> vecTestLoop( L, now(), 4 ) end ). <br><br><br> I used next test-cases: <br><br> AMD 64 2 core, 3.1 GHZ, Windows XP, Erlang R14B04: <br> - Works well with one process and any list that fits into memory <br>

 - Works well with two processes and list of 500000 elements <br> - Hangs in about 30-60 seconds with list of 750000 elements <br> - Hangs almost immediately with list of 1000000 elements <br><br> Intel Quad 2.67 GHz, Windows 7 x64, Erlang R14B04: <br>

 - Works well with one process and any list that fits into memory <br> - Hangs in about 30-60 seconds with list of 1000000 elements <br> - Hangs almost immediately with list of 1500000 elements <br><br> This looks very similar to deadlock - when normal iterations freeezes, the erl.exe cannot be stopped with Ctrl+C/Break, typing "q()." etc, and starts to load ONLY ONE CORE. Though while it still alive, it consumes all cores. <br>

<br> Memory consumption by erl.exe was about or even under 1 GB in all cases. <br><br>
<br>_______________________________________________<br>
erlang-bugs mailing list<br>
<a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
<br></blockquote></div><br></div></div></div></div>