[erlang-questions] Mysterious gen_server timeouts in MIX

John R. Ashmun john.ashmun@REDACTED
Sun Nov 3 17:08:19 CET 2013


Thank you, Vance.

I have some experience with multithreaded applications and avoiding race
conditions.  I appreciate your providing examples.

I probably ought to have provided a few more details, and I would like to
stress that I see the Erlang VM/MIX emulator combination go into and come
out of the regime of failing via gen_server timeouts without my having made
any changes at all to my Erlang source files:  I haven't changed anything
in any of them since October 24.

I see or have seen this baffling behavior on two machines using werl:

HP Pavilion desktop with AMD A8-3800 APU w/8Gb RAM -- Microsoft Windows 7
Home Premium & erts5.9

Newer Dell laptop with Intel(R) Core(TM) i3-3217U w/6Gb RAM -- Microsoft
Windows 8 & erts5.10.2

At the moment, the emulator runs as intended on the desktop.  As I
mentioned, it runs Program P, and in so doing, it consumes roughly 4
seconds on a wall clock.  It has been doing this on this machine only since
October 24, which was when I commented out several io:format( ) calls which
had been announcing what instruction it was currently executing.  Before I
commented those out, it would run successfully sometimes and time out
sometimes.  It hasn't exhibited the timeouts since then.  I run it here
using -boot & -config options when starting werl.

On the laptop, when the emulation of Program P succeeds, it consumes
roughly 6 seconds on the wall clock.  It began running successfully on
October 26, without my having made any changes to sources, after having
consistently failed with timeouts for two or three days of desultory
attempts.  For no very good reason, and because I couldn't think of any
source code changes I could usefully make, I simply recompiled the sources
using +debug_info, and it subsequently succeeded.  I then took a trip to
Las Vegas, Nevada, and when I came back, seeing that the session windows
were still open, I ran the emulator again.  On that attempt, the timeouts
happened.  Again for no very good reason, I recompiled things, this time
without +debug_info, and now the emulator doesn't time out.  On the laptop
I start it using application:start( 'MIX' ). in the Erlang shell; I haven't
written the .rel file for this installation yet.

It looks to me as if the Erlang VM is starving for a resource sometimes.
Anthony Molinaro recently reported here a mysterious freeze while trying to
access a file.  The MIX emulator opens a file for each of its 20 I/O
devices.  I don't know that I am encountering something similar, not am I
certain what such a freeze would imply about the behavior of this emulator,
although it could lead to a gen_server timeout, I imagine.

Regards,
John Ashmun


On Sat, Nov 2, 2013 at 4:35 AM, Vance Shipley <vances@REDACTED> wrote:

> On Sat, Nov 02, 2013 at 03:15:11PM +0530, Vance Shipley wrote:
> }  Here is an example of a pathological program which will eventually
> }  deadlock:
> ...
> }  handle_call(N, _From, State) ->
> }       {reply, N + 1, State, 0}.
>
> Small correction, the previous example probably timed out because my
> MacBookPro went to sleep.  The small change here demonstrates the
> problem quicker and more reliably:
>
>         handle_call(N, _From, State) ->
>                 {reply, N + 1, State, random:uniform(100)}.
>
> The small random timeout greatly increases the chance of entering a race.
>
> --
>         -Vance
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131103/31f96b48/attachment.htm>


More information about the erlang-questions mailing list