You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/07/31 11:57:04 UTC

Apache, in 40 system calls

Alan Cox mentioned a while back that it should be possible to do a
webserver that took about 20 system calls per request.  Well after
applying that cleanup patch I just posted, and playing with the
server configuration, I present here, Apache in 40 system calls on
linux-2.0.31-pre2.

Tuning includes:

- use "Rule STATUS=no", otherwise there's gratuitous calls to time(0)

- use "Option FollowSymLinks" globally, assume it's a production high
    performance server and symlinks don't concern you.  Otherwise you
    pay dearly for lots of lstat() calls.

- use "AllowOverrides none" of course, same reasons, don't want to pay
    for .htaccess probes

- use "HostnameLookups off"

Note that 11 of the system calls are to alarm().  Something that we
should be able to clean up.  Also on a single socket server we could
conceivably get rid of the fcntl locking without running into the
starving sockets situation (but instead running into the all-tasks-wakeup
problem that causes load spikes, and is generally worse).

This is a pretty ideal request though... it's way worse if you ask for
something like "/dirname/" when using something like "DirectoryIndex index".

Dean

accept(15, {sin_family=AF_INET, sin_port=htons(1279), sin_addr=inet_addr("206.221.201.235")}, [16]) = 3
fcntl(18, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
sigaction(SIGUSR1, {SIG_IGN}, {0x804c3e0, [], SA_INTERRUPT}) = 0
getsockname(3, {sin_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("206.221.201.235")}, [16]) = 0
setsockopt(3, IPPROTO_TCP1, [1], 4)     = 0
alarm(300)                              = 0
oldselect(4, [3], NULL, NULL, {0, 0})   = 1 (in [3], left {0, 0})
read(3, "GET /icons/ps.gif HTTP/1.0\r\nCo"..., 4096) = 200
sigaction(SIGUSR1, {SIG_IGN}, {SIG_IGN}) = 0
time(NULL)                              = 870342669
alarm(300)                              = 300
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
alarm(0)                                = 300
sigaction(SIGUSR1, {SIG_IGN}, {SIG_IGN}) = 0
stat("/home/dgaudet/apache/apache/icons/ps.gif", {st_mode=S_IFREG|0664, st_size=244, ...}) = 0
open("/home/dgaudet/apache/apache/icons/ps.gif", O_RDONLY) = 4
mmap(0, 244, PROT_READ, MAP_PRIVATE, 4, 0) = 0x400e1000
alarm(300)                              = 0
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
alarm(0)                                = 300
alarm(300)                              = 0
alarm(300)                              = 300
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
alarm(0)                                = 300
close(4)                                = 0
time(NULL)                              = 870342669
write(16, "206.221.201.235 - - [31/Jul/1997"..., 86) = 86
alarm(30)                               = 0
write(3, "HTTP/1.1 200 OK\r\nDate: Thu, 31"..., 486) = 486
shutdown(3, 1 /* send */)               = 0
oldselect(4, [3], NULL, [3], {2, 0})    = 1 (in [3], left {1, 860000})
read(3, "", 2048)                       = 0
close(3)                                = 0
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
alarm(0)                                = 30
sigaction(SIGUSR1, {0x804c3b4, [], SA_INTERRUPT}, {SIG_IGN}) = 0
alarm(0)                                = 0
sigaction(SIGPIPE, {0x804b984, [], SA_INTERRUPT}, {0x804b984, [], SA_INTERRUPT}) = 0
munmap(0x400e1000, 244)                 = 0
fcntl(18, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
sigaction(SIGUSR1, {0x804c3e0, [], SA_INTERRUPT}, {0x804c3b4, [], SA_INTERRUPT}) = 0
accept(15,