From owner-freebsd-hackers Mon Aug 21 05:12:11 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.FreeBSD.org (8.6.11/8.6.6) id FAA16246 for hackers-outgoing; Mon, 21 Aug 1995 05:12:11 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.34]) by freefall.FreeBSD.org (8.6.11/8.6.6) with ESMTP id FAA16240 for ; Mon, 21 Aug 1995 05:12:02 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id WAA23103; Mon, 21 Aug 1995 22:09:49 +1000 Date: Mon, 21 Aug 1995 22:09:49 +1000 From: Bruce Evans Message-Id: <199508211209.WAA23103@godzilla.zeta.org.au> To: dyson@freefall.FreeBSD.org, hasty@rah.star-gate.com, rcarter@geli.com Subject: Re: Why Linux? (fwd) Cc: hackers@freebsd.org, terry@cs.weber.edu Sender: hackers-owner@freebsd.org Precedence: bulk >Curious though, I deal with low-latency networking types for a >(partial) living, and I have had more than one mention the >syscall.s in Linux as the model for syscall overhead. Shouldn't >this show up somewhere in user land? Probably not. Not many applications really need to do lots of syscalls. Anyway, Linux currently seems to have about the same syscall overhead as FreeBSD. However, vfs has much more overhead. The "null syscall" benchmark in lmbench for some reason (;-) tests only the speed of a syscall that is fast under Linux. To show that FreeBSD is better, benchmark only gettimeofday(). The FreeBSD one is faster because we needed microtime() to be fast for accurate system timing to be acceptably efficient. The Pentium version is even faster. I measured the following a few minutes ago: Machine System Benchmark Sys Time Load Av --------- ----------------------- --------------- ----- - 486DX2/66 FreeBSD-2.2-current 1e6 getpid()s 5.78 0 " Linux-1.2.13 " 6.91 4 (*) 486DX/33 FreeBSD-2.2-current " 11.16 0 " FreeBSD-2.2-current-prof" 12.93 0 486DX2/66 FreeBSD-2.2-current 1e6 setuid()s 8.03 0 " Linux-1.2.13 " 7.45 6 486DX/33 FreeBSD-2.2-current " 17.69 0 " FreeBSD-2.2-current-prof" 19.58 0 486DX2/66 FreeBSD-2.2-current 1e6 gettimeofday()s 13.18 0 " Linux-1.2.13 " 24.90 2 486DX/33 FreeBSD-2.2-current " 22.10 0 " FreeBSD-2.2-current-prof" 26.40 0 486DX2/66 FreeBSD-2.2-current 1e6 write()s (+)21.20 0 " Linux-1.2.13 " 11.69 2 486DX/33 FreeBSD-2.2-current " 41.13 0 " FreeBSD-2.2-current-prof" 51.05 0 (*) The load average was measured before the test. It shouldn't affect the system time much provided the system time is accurate. The system time is very accurate for FreeBSD but not very accurate for Linux when there are a lot of context switches. (+) The writes were of 1 byte to /dev/null. Linux doesn't actually have syscall.s. In 1.2.8 it has `_lcall7' and `_system_call' in entry.S. These have more avoidable overheads than FreeBSD's corresponding `_Xsyscall' and `_Xlinux_syscall' in exception.s. However, FreeBSD loses by calling relatively inefficent C routines syscall() and linux_syscall() to dispatch the syscall, and it often loses by having to copyin() the syscall args (Linux passes them in registers). The copyin() overhead is enough to make FreeBSD's setuid() slightly slower than Linux's although FreeBSD's getpid() is slightly faster. Profiling shows FreeBSD-2.2-current overheads on a 486DX2/33 to be about: getpid(): _Xsyscall: 2 _syscall: 6 _getpid: 4 _doreti: 3 # end of _Xsyscall Total sys time: 15 usec Total usr time: 4 usec setuid(myid): _Xsyscall: 2 _syscall: 5 _copyin: 5 _setuid: 1 _crcopy: 3 _doreti: 3 Total sys time: 19 usec Total usr time: 5 usec gettimeofday(&tv, (struct timezone *)NULL): _Xsyscall: 2 _syscall: 5 _copyin: 5 _gettimeofday: 1 _microtime: 7 _copyout: 4 _doreti: 3 Total sys time: 27 usec Total usr time: 5 usec write(1, "", 1): _Xsyscall: 2 _syscall: 8 _copyin: 6 _write: 3 _vn_write: 2 _ufsspec_write: 1 _spec_write: 1 _mmrw: 5 # too many layers _ufs_lock: 8 (2 calls) # too slow and called too much _ufs_unlock: 6 (2 calls) # too slow and called too much _doreti: 3 Total sys time: 46 usec Total usr time: 6 usec Bruce