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

Frank Muller <>
Mon Dec 19 10:37:44 CET 2016


Sorry, hit the send button too fast.

1. Stripped down escript (no connect):
~0.150ms

2. Stripped down escript (with only connect):
~0.790ms

/Frank

Le lun. 19 déc. 2016 à 10:33, Frank Muller <> a
écrit :

> Hi Richard,
>
> You're right. Dropped the "native" flag and here are the measurements:
>
> 1. Stripped down escript (no connect):
> 0.15ms
>
> 2. Stripped down escript (with only connect):
> 0.79ms
>
> These confirm your assumptions. So the "connect" is where most of the time
> is spent.
>
> Q: is there another way to make the "connect" quicker (undocumented
> calls)? Or, any another way to connect to a node?
>
> Thank you !
>
> /Frank
>
> Le lun. 19 déc. 2016 à 09:51, Richard Carlsson <>
> a écrit :
>
> 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/4eee4d9d/attachment.html>


More information about the erlang-questions mailing list