Date: Wed, 28 Jan 2004 12:20:46 -0500 From: Don Bowman <don@sandvine.com> To: "'freebsd-current@freebsd.org'" <freebsd-current@freebsd.org> Subject: system call performance 4.x vs 5.x [and UP vs MP] Message-ID: <FE045D4D9F7AED4CBFF1B3B813C85337035E46FF@mail.sandvine.com>
next in thread | raw e-mail | index | archive | help
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 <sys/types.h> #include <sys/uio.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> #include <stdio.h> #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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FE045D4D9F7AED4CBFF1B3B813C85337035E46FF>