From owner-freebsd-current@FreeBSD.ORG Wed Jan 28 09:20:50 2004 Return-Path: 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 76CA216A4CE for ; Wed, 28 Jan 2004 09:20:50 -0800 (PST) Received: from mail.sandvine.com (sandvine.com [199.243.201.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id D322743D39 for ; Wed, 28 Jan 2004 09:20:48 -0800 (PST) (envelope-from don@sandvine.com) Received: by mail.sandvine.com with Internet Mail Service (5.5.2657.72) id ; Wed, 28 Jan 2004 12:20:47 -0500 Message-ID: From: Don Bowman To: "'freebsd-current@freebsd.org'" Date: Wed, 28 Jan 2004 12:20:46 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: text/plain; charset="iso-8859-1" Subject: system call performance 4.x vs 5.x [and UP vs MP] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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: Wed, 28 Jan 2004 17:20:50 -0000 This is a very simplistic benchmark, so don't get too hung up on the accuracy. If you run this on a given machine on 4.x vs 5.x, you will notice a dramatic difference [yes, invariants, et al are disabled]. For example, on a 2.0GHz P4-Xeon, HTT enabled, MP kernel, i can do ~1M socket/s calls on 4.7, but only ~250K/s on 5.2. syscall 4.7 5.2 write 1015036 169800 socket 1078994 223253 select 430564 155077 gettimeofday 252762 183620 As a side note, any idea why gettimeofday is so much more expensive than socket? Any suggestion on why such a difference between 4.x and 5.x? code is compiled the same on each, 'gcc -O2', no threading options chosen. For interest, you can try the same program on 4.x in UP vs MP, and the difference is very dramatic too. #include #include #include #include #include #include #include #define M(n) measure(#n, n); static void measure(char *name, void (*fp)(int,...)) { double speed; int j; unsigned long long i = 0; unsigned long long us; struct timeval tp,tp1; gettimeofday(&tp, 0); tp1 = tp; while (tp1.tv_sec - tp.tv_sec < 10) { for (j = 0; j < 1000000; j++) { fp(0,0,0,0); i++; } gettimeofday(&tp1, 0); } us = ((tp1.tv_sec - tp.tv_sec) * 1000000) + (tp1.tv_usec - tp.tv_usec); speed = (1000000.0 * i) / us; printf("{%s: %llu %llu %6.2f}\n", name, i,us, speed); } static void doGettimeofday() { double speed; unsigned long long i = 0; unsigned long long us; struct timeval tp,tp1; gettimeofday(&tp, 0); tp1 = tp; while (tp1.tv_sec - tp.tv_sec < 10) { gettimeofday(&tp1, 0); i++; } us = ((tp1.tv_sec - tp.tv_sec) * 1000000) + (tp1.tv_usec - tp.tv_usec); speed = (1000000.0 * i) / us; printf("{gettimeofday: %llu %llu %6.2f}\n", i,us, speed); } int main(int argc, char **argv) { M(write); M(socket); M(select); doGettimeofday(); return 0; }