[erlang-questions] escript: faster startup and connect to TargetNode

Richard Carlsson <>
Mon Dec 19 09:51:34 CET 2016


You're not doing any cpu heavy work at all, so native compilation will not
do anything for you - it might just add overhead.

Measure the run time for a stripped down escript version that doesn't
actually try to connect, to see what the actual startup time is. Most
likely, all the time is spent in the call to connect node.


        /Richard

2016-12-19 7:17 GMT+01:00 Frank Muller <>:

> Hi everyone,
>
> I’ve an escript which connects to a TargetNode using this code (snippet
> from Basho's nodetool):
> https://github.com/basho/rebar/blob/develop/priv/
> templates/simplenode.nodetool#L34-L45
>
>     %% See if the node is currently running  -- if it's not, we'll bail
>     case {net_kernel:hidden_connect_node(TargetNode),
>           net_adm:ping(TargetNode)} of
>         {true, pong} ->
>             ok;
>         {false,pong} ->
>             io:format("Failed to connect to node ~p .\n", [TargetNode]),
>             halt(1);
>         {_, pang} ->
>             io:format("Node ~p not responding to pings.\n", [TargetNode]),
>             halt(1)
>     end,
>
> It works perfectly well, but it’s kind of slow. I mean the connection is a
> bit slow to be established even it the TargetNode is running on the same
> host.
> Can we make it faster? Is there another way to connect to a TargetNoode
> without using net_kernel module?
>
> Finally, what kind of escript's options can make the startup faster in
> general?
> I found this one:
> -compile(native).
>
> Thank you
> /Frank
>
> _______________________________________________
> 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/20161219/bda043aa/attachment.html>


More information about the erlang-questions mailing list