[erlang-questions] Strange performance issue - advice needed

Ulf Wiger <>
Sun Apr 15 08:40:01 CEST 2012


On 14 Apr 2012, at 21:56, Ian wrote:

> But, my goodness, so called buffered file IO is inexpressibly crap!

Well, it wasn't designed to eat large files from disk in a hurry. :)

What it shines at is distribution-transparent console I/O. You can do an RPC
to an embedded system from a shell on your workstation, and have the code
on the embedded system ask for input, without knowing that there is no 
console attached. The input and output will automatically be served by your 
shell. *

That is not crap.

BR,
Ulf W

* All this is actually default behavior, and easy to test. Start two nodes, e.g. node1
and node2, then from node1:

()2> rpc:call(, io, get_line, ['>> ']).
>> foo
"foo\n"

The function io:get_line/1 is executed on node2, but the prompt appears on node1.

To verify that nothing fishy is happening, you can run an ad-hoc trace on node2:

Eshell V5.9  (abort with ^G)
()1> dbg:tracer().
{ok,<0.44.0>}
()2> dbg:tp(io,get_line,x).
{ok,[{matched,'',2},{saved,x}]}
()3> dbg:p(new,[c]).  
{ok,[{matched,'',0}]}

()4> (<0.51.0>) call io:get_line('>> ')
(<0.51.0>) returned from io:get_line/1 -> "foo\n"

dbg:stop().
ok


Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com






More information about the erlang-questions mailing list