[erlang-questions] Maze alternate example for Rosetta Code

Felix Gallo <>
Fri Feb 12 17:33:18 CET 2016


my suspicion (without having run that code yet) is that you're running out
of memory somehow, and your computer's becoming slow as programs are
getting paged in and out.  You might try starting the program while
windows' process monitor is running and watching the CPU and memory graphs
to see if there are any unnatural or explosive spikes.  If you've compiled
with wx in your otp installation, then you could also start observer (type
o() in the shell before kicking off your program) and watch the pretty
lights while it runs.

10,000 erlang processes is not a heck of a lot, unless each of those
processes, say, recurses over a megabyte of local state or, unbeknownst to
you, starts another 100 processes each or tries to send every other process
a message.

epmd is, as you guess, super unlikely to be the root cause of any problems;
it's just a name service.

F.

On Fri, Feb 12, 2016 at 7:31 AM, Bill Durksen <> wrote:

> Hi there,
>
> To learn Erlang, I have recently switched from "learn you some Erlang" (
> http://learnyousomeerlang.com) to building actual programs.
>
> My first real Erlang program was a multi-process, multi-host,
> wxWidgets-based file-transfer application with 768 lines of Erlang code.
> I was surprised how simple it is to get this distributed functionality
> built, cleanly, in Erlang.
> Much appreciation goes to [erlang-questions]-subscribers, who guided me to
> various solutions when I needed an Erlang implementation of the Singleton
> design pattern.
> The 'ets' dictionary solution worked for me, after I figured it out.
>
> Currently, I am finishing a Maze-generation program (114 lines of packed
> Erlang code), and have put the final version up on the Rosetta Code
> web-site.
> (see the http://rosettacode.org/wiki/Maze_generation#Erlang
> ...Alternative example (implemented with 2 diagraphs)).
>
> From doing this experiment, I have a few questions:
>
> 1. The original Erlang maze-generation code (same Rosetta web-site page)
> used a light-weight process for each vertex in the maze.
>     This is a very good example of how the Erlang process architecture can
> support many light-weight processes.
>     I was surprised that it actually worked, until I tried generating a
> bigger maze.
>     When I used the original Erlang maze example to generate a maze of 25
> columns x 4000 rows, it brought my PC down to a crawl.
>     I couldn't do anything (I am running Windows 7 64-bit on 9 GB of RAM)
> until I killed EPMD from Task Manager.
>     Even after killing EPMD, it took quite a while for the computer to get
> back to normal again, which indicates that it may not have been EPMD
> causing the problem.
>
>     Here is the question (part a): should I expect EPMD (or the WERL
> process) to slow to a crawl with 100,000 Erlang processes running on a
> single machine?
>                                        (part b): If yes, what would be the
> Erlang programmer's defence tactic against this scenario?
>
> 2. 114 packed lines of Erlang code just seems to over-coded for such a
> powerful language.
>     Not being an expert, yet, in all the nuances of Erlang, can someone
> suggest ways I can decrease maze.erl code down to 99 lines or less, without
> cheating (removing too many newlines)?
>
> Thanks,
> Bill
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160212/a1e991fb/attachment.html>


More information about the erlang-questions mailing list