lots of uname syscalls on boot - patch

David N. Welton <>
Mon May 3 11:44:18 CEST 2004


[ Please CC replies to me. ]

Hi,

I'm pretty new to Erlang, so maybe there is a good reason for this
behavior, but I noticed that when starting up, erlang calls uname (2)
a lot:

:~$ strace -o output  erl ./hw.erl -noinput -s hw main
hello world
:~$ grep -c uname output
982

I had a go at reducing that in ./erts/emulator/sys/unix/sys.c:

void
os_flavor(char* namebuf, 	/* Where to return the name. */
	  unsigned size) 	/* Size of name buffer. */
{
    static int called = 0;
    static struct utsname uts;		/* Information about the system. */

    if (called != 1) {
	(void) uname(&uts);
	called = 1;
    }
    strcpy(namebuf, uts.sysname);
    for ( ; *namebuf; namebuf++)
	if (isupper((int) *namebuf))
	    *namebuf = tolower((int) *namebuf);
}

This change drammatically reduces the amount of uname syscalls:

:~$ strace -o output /home/davidw/download/erlang-9.2/bin/erl ./hw.erl -noinput -s hw main
hello world
:~$ grep -c uname output
6

It's not that big a deal I guess, but I suppose it speeds things up
just a bit.

Thankyou,
-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/



More information about the erlang-patches mailing list