5 ms·
Investigating Erlang by reading its system calls
- mweibel 11y agocross posting what I wrote as a comment in the article: epmd is a separate process, yes. But an erlang node connects to epmd in order to register it's name on it. It will bind a socket to talk with epmd (probably among other things).. See also: http://erlang.org/doc/apps/erts/erl_dist_protocol.html http://erlang.org/doc/apps/erts/erl_dist_protocol.html
- jen20 11y agoA quick suggestion for the author based on the "dude I can't debug anything on OS X" line - take a look at DTrace, which is shipped with MacOS (albeit an old version). Compared with strace on Linux it is like night and day.
- jonesetc 11y ago> http://jvns.ca/blog/2016/01/14/a-few-notes-on-my-cusec-talk/ http://jvns.ca/blog/2016/01/14/a-few-notes-on-my-cusec-talk/ On debugging, second bullet. She seems to agree.
- renox 11y agoGood advice, on Windows it's really a nightmare though.. Investigating why the OS seems to 'freeze' a process for 10s once in a while (threading issue?) is really mysterious..
- sspiff 11y agoDTrace is closer to something like LTTng than to strace, though.
- masklinn 11y agodtrace is an "everything tracer", so it's a superset of strace… and a ton of other stuff.
- cm3 11y agoIn other words, you can whip up strace in a few lines with DTrace.
- astrange 11y agoDTrace comes with a syscall tracer called 'dtruss'. One serious problem - it has to run as root.
- iso-8859-1 11y agosounds kinda like SystemTap?
- masklinn 11y agoSystemTap is dtrace for linux, at least in intent (implementation and details differ)
- sigjuice 11y agoUnfortunately, dtrace does not work any more on El Capitan by default.
- yetihehe 11y agoMaybe some analogy - C is like riding a very fast bike. Python, Java - Starting a truck which will move what you want. Erlang - starting a railway system. Erlang is like another system inside your system, it's more akin to booting a system inside a vm just to echo some hello world.
- thecourier 11y agoyeah, also it would be fair to compare a running actor system with Akka (jvm, java, scala), CAF (c++), XUDD (Python), Celulloid (Ruby) vs Erlang I believe Erlang would do some interesting things there
- sspiff 11y agoBike as in motorcycle, not bicycle I presume?
- frou_dh 11y agoTerry Davis describes his TempleOS† as a motorbike, Windows a car and Linux a semi truck with a huge gearbox. In TempleOS, you'll crash if you lean over too far. The solution? Don't lean over, then! † ring-0 only, no memory protection, exploratory dev/art focused
- rdtsc 11y agoExactly. To put it another way, if you run code on a system with concurrency units sharing the memory (the heap), your code is running on DOS or Windows 3.1 which was cool in 1990s. Erlang/Elixir is like running your code on a modern OS with a process memory separation, preemptable concurrency (processes don't have to yield by hand to others). Built in tracing and monitoring facilities (tracing, observer, dbg). Built in networking (distribution, global process registration, in memory distributed db) etc.
- kazinator 11y ago$ cat hello.tl (pprinl "hello, world") $ strace txr hello.tl 2>&1 > /dev/null | wc -l 77 $ cat hello.c #include <stdio.h> int main(void) { printf("Hello, world\n"); } $ cc -O hello.c -o hello $ strace ./hello 2>&1 > /dev/null | wc -l 29 $ strace gawk 'BEGIN { print "hello") }' 2>&1 > /dev/null | wc -l 84
- nmjohn 11y ago$ strace node -e 'console.log("hello world")' 2>&1 > /dev/null | wc -l 304
- catwell 11y ago$ strace lua5.3 -e 'print("hello")' 2>&1 > /dev/null | wc -l 67
- kazinator 11y ago$ strace txr -e '(put-line "hello")' 2>&1 > /dev/null | wc -l 70 Very similar. Obviously there are those who care about reasonable startup times and, ... others. :) By the way, TXR supports setuid operation, and so it makes a few extra syscalls to check its security situation (am I running setuid? setgid?)
- jandrese 11y ago$ cat HelloWorld.java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world"); } } $ strace java HelloWorld 2>&1 > /dev/null | wc -l 122
- jaytaylor 11y ago$ strace python -c "print('hello world')" 2>&1 > /dev/null | wc -l 924 $ strace python3 -c "print('hello world')" 2>&1 > /dev/null | wc -l 543
- deleted 11y ago[deleted]
- armitron 11y agopretty much entirely content free article
- garazdawi_hn 11y agoIf you run something like: erl -noshell +sbwt none -smp disable +A 0 -mode minimal -eval 'io:format("Hello world~n").' -s init stop instead, which is much closer to what python/java et al runs, then at least I get around 2850 syscalls. The constant ppoll:ing is because erts spins looking for new work from any fd. Specifically "/sys/devices/system/node/node0" is in order to check for cpu topology updates by the operating system, i.e. if for some reason a core/cpu is taken offline of something like that. This is limited in my example above by "+sbwt none" IIRC the bind is an UDP socket to talk to the local nameserver. This is removed in my example with "-mode minimal".
- liveoneggs 11y agothis feels similar to the overhead of an escript
- ysleepy 11y agoThis comparison is rather meaningless. It is measuring the Runtime startup. - Opening jars/pyc files. Why not do a specific call before the actual code to segment the strace, or run it with repetitions and subtract+divide to get calls/repetition?
- anfroid555 11y agoErlang is a system not just a language
- al_chemist 11y ago> I wanted to debug something > I've analyzed Erlang strace > "Erlang is complicated" If you want to debug Erlang program then Erlang/OTP already includes tools to help you do that: http://www.erlang-in-anger.com/ http://www.erlang-in-anger.com/ - 92 page manual that includes: - tracing functions called with defined parameters - analyzing crash dumps, memory leaks, cpu scheduling
- toast0 11y agoThis is great, if you're planning to do many things with erlang, our you have a lot of time. If your friend has a weird problem and comes to you because you have a reputation for figuring things out that you've earned by using strace, then you use strace. Incidentally, I'm reading this because I use erlang, but it took about a minute to see the problem (tcp port exhaustion) from the strace.
- gjkood 11y agoWould it make sense to do a large number of iterations (in the millions) of the basic "Hello, World\n" print statement in all the languages to amortize the cost of the BEAM/JVM setup/initialization system calls out? Isn't it the case that in Java and Erlang we have a large VM environment that also needs to be launched before the first line of the trivial print statement is executed?
- stcredzero 11y agoOne last thing -- erlang runs bind once when it starts. Why does it need to listen on a TCP socket to run hello world? My first thought: "So this guy is investigating Erlang with strace, but he couldn't be bothered to Google articles on its design!?" Then I tried Googling this myself. Uh, yeah. I happen to know this stuff, even though I don't use Erlang, but it's not exactly easy to find packaged conveniently in one place.
- self_awareness 11y agoRust: $ cargo new --bin hello $ cd hello $ cargo build --release $ strace ./target/release/hello 2>&1 | wc -l 124