From owner-freebsd-current@FreeBSD.ORG Thu May 18 20:26:34 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD91F16A415 for ; Thu, 18 May 2006 20:26:34 +0000 (UTC) (envelope-from steve@stevehodgson.co.uk) Received: from ghana.smallmonkey.co.uk (ghana.smallmonkey.co.uk [83.142.48.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4450643D46 for ; Thu, 18 May 2006 20:26:34 +0000 (GMT) (envelope-from steve@stevehodgson.co.uk) Received: from [192.168.7.2] (dyn-62-56-59-3.dslaccess.co.uk [62.56.59.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ghana.smallmonkey.co.uk (Postfix) with ESMTP id 38E0C6251; Thu, 18 May 2006 21:26:33 +0100 (BST) Message-ID: <446CD873.9080903@stevehodgson.co.uk> Date: Thu, 18 May 2006 21:26:27 +0100 From: Steve Hodgson User-Agent: Thunderbird 1.5.0.2 (X11/20060508) MIME-Version: 1.0 To: Ivan Voras References: <446CCE1C.1050200@fer.hr> In-Reply-To: <446CCE1C.1050200@fer.hr> Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit Cc: "current@freebsd.org" Subject: Re: (Another) simple benchmark X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 May 2006 20:26:34 -0000 Ivan Voras wrote: > Today I had the opportunity to experiment for a short time with a > 4-CPU Xeon machine with hyperthreading (-> 8 logical CPU-s) and 3GB > RAM. In absence of anything smarter to do, I installed WBEL 3 Linux > (non-RedHat version of RedHat Enterprise Linux) which was accidentally > on the table and after toying around I've run a simple benchmark - ab > (apachebench, included by default with apache server) over localhost > to a local apache2 server, on a static home-page file. The command > line was "ab -n 100000 -c 100 http://localhost/". Since I still had > time with the machine, I then downloaded and installed FreeBSD 6.1 to > try to beat the score. Unfortunately, not only I couldn't beat the > score, but the results were *extremely* bad. Since I'm still not sure > it isn't my fault, I won't post the actual results, but I wonder... > > Apache is a well known server-grade product, which doesn't use > threading (it was preforked in both systems), doesn't call > gettimeofday() constantly, uses sendfile(), and in short, is very > different from MySQL. It shouldn't behave this badly on FreeBSD. > > Some observations from the benchmark runs: > - Linux was maxed out with ~50% total idle time, each logical > processor (hyperthreading was enabled) had ~25% user + ~25% sys time. > It still delivered order-of-magnitude better results. WBEL3 uses Linux > 2.4.x kernel (i.e. old kernel) > - FreeBSD CPU time was 100% spent, with 90%-95% spent in sys time > - On FreeBSD, enabling hyperthreading got me a slowdown of *4x* over > the initial (bad) results (some slowdown is not surprising, 4x > slowdown is). > - Linux "load average" never went above 8, FreBSD's went > 60; this > could be just a difference in accounting, or it could not - I don't know. > > What is needed to reproduce this simple benchmark: > - SMP machine, the more CPUs the better > - installed software: only apache20. The "ab" benchmark is included in > it. Leave apache's default configuration as-is (i.e. preforked, max > 150 parallel clients allowed) > - A simple static HTML page (Apache's default "welcome, but this site > is not configured" should be ok). > - my invocation of "ab" was with "-n 100000 -c 100" ; the (n)umber of > requests could be modified to fit local CPU speed, but (c)oncurrency > shouldn't (100 parallel requests is not uncommon). > Apache may not use gettimeofday, but ab certainly does. here is a truss output of ab: gettimeofday({1147982776 251498},0x0) = 0 (0x0) connect(0x5f,{ AF_INET 127.0.0.1:80 },16) = 0 (0x0) gettimeofday({1147982776 253078},0x0) = 0 (0x0) write(95,0x80546e0,0) = 0 (0x0) gettimeofday({1147982776 254325},0x0) = 0 (0x0) write(95,0x80546e0,84) = 84 (0x54) gettimeofday({1147982776 256705},0x0) = 0 (0x0) read(0x60,0x80522c0,0x2000) = 0 (0x0) gettimeofday({1147982776 258209},0x0) = 0 (0x0) close(96) = 0 (0x0) socket(0x2,0x1,0x0) = 96 (0x60) fcntl(96,F_GETFL,0x0) = 2 (0x2) fcntl(96,F_SETFL,0x6) = 0 (0x0) gettimeofday({1147982776 263102},0x0) = 0 (0x0) connect(0x60,{ AF_INET 127.0.0.1:80 },16) = 0 (0x0) gettimeofday({1147982776 264622},0x0) = 0 (0x0) write(96,0x80546e0,0) = 0 (0x0) gettimeofday({1147982776 265949},0x0) = 0 (0x0) write(96,0x80546e0,84) = 84 (0x54) gettimeofday({1147982776 268711},0x0) = 0 (0x0) read(0x61,0x80522c0,0x2000) = 0 (0x0) gettimeofday({1147982776 270031},0x0) = 0 (0x0) close(97) = 0 (0x0) A fairer test would be to use ab on a second box and keep ab on the same OS - you're changing two things at once here. You're also at the mercy of how the scheduler places the processes across the different CPU's (since there is one ab process and multiple httpd processes). Why was Linux stuck at 50% utilization per CPU (surely it should reach 100% with no disk or network constraints)? Perhaps it is sleeping whilst FreeBSD spins? If you are interested in performance try Lighttpd - that is what people use if they want high transaction rates (x10 higher in tests I've done on Linux) - and it is a single process so scheduling isn't so significant. Finally, I'm using apache 2.0.X on 6.1, and ab and apache are both using poll(2). I don't know if apache 2.2 (well, apr really) supports kqueue/(epoll on linux) yet, but it could be worth investigating. Its conceivable the kernel is spinning on multiple processes hitting poll at the same time [does apache still serialize access to poll??]. Does apr use non-portable atomic ops on FreeBSD like it does on Linux 2.4+? I'd setup a second box [Though then you are bringing different network implementations into it.], and also test Lighttpd. Sorry I've got lots of questions and no answers! Steve > Since I didn't have time to reinstall Linux to check if apache's > configuration was the same in all important things all this may be > bogus, but if anyone has a spare box with several CPUs, I'd be > interested in results. > > p.s. I don't think the actual Linux kernel version matters here, any > 2.4 or newer will do. > > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to > "freebsd-current-unsubscribe@freebsd.org"