Re: syscall cost freebsd vs linux ?
On Tuesday, November 27, 2012 01:41:46 AM Andrey Zonov wrote: On 11/19/12 11:32 PM, Luigi Rizzo wrote: today i was comparing the performance of some netmap-related code on FreeBSD and Linux (RELENG_9 vs 3.2) and i was surprised to see that our system calls are significantly slower. On comparable hardware (i7-2600k vs E5-1650) the syscall getppid() takes about 95ns on FreeBSD and 38ns on linux. (i make sure not to use gettimeofday(), which in linux is through vdso, and getpid(), which is cached by glibc). Any idea on why there is this difference and whether/how we can reduce it ? This is the cost of blocking mutexes. Linux uses RCU instead [1]. Here are the numbers on current: $ time ./getppid 1 real 0m22.926s user 0m2.252s sys 0m20.669s After locking removing (patch below): $ time ./getppid 1 real 0m15.224s user 0m2.355s sys 0m12.868s Unfortunately, RCU can be used only in GPL code, but we can use passive serialization for simple deref. And even more, it's already implemented in NetBSD. Of course, that is specific to getppid(). Micro-optimizing getppid() is probably not all that useful, and I suspect Luigi is more concerned about syscall overhead as it impacts other system calls. Perhaps compare getppid() on Linux with getpid() on FreeBSD. -- John Baldwin ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: syscall cost freebsd vs linux ?
On 11/19/12 20:32, Luigi Rizzo wrote: today i was comparing the performance of some netmap-related code on FreeBSD and Linux (RELENG_9 vs 3.2) and i was surprised to see that our system calls are significantly slower. On comparable hardware (i7-2600k vs E5-1650) the syscall getppid() takes about 95ns on FreeBSD and 38ns on linux. (i make sure not to use gettimeofday(), which in linux is through vdso, and getpid(), which is cached by glibc). Any idea on why there is this difference and whether/how we can reduce it ? I'm curious about how did you measure that ? Could you write some more about your methodology ? -LW cheers luigi ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: syscall cost freebsd vs linux ?
a quick and easy way is to run the syscall in a tight loop for a sufficient long time (1s or more) and use time to measure it. At 100ns per call you need about 10M cycles to do one second. cheers luigi On Mon, Nov 26, 2012 at 3:39 AM, Lukasz Wojcik lukasz.woj...@zoho.comwrote: On 11/19/12 20:32, Luigi Rizzo wrote: today i was comparing the performance of some netmap-related code on FreeBSD and Linux (RELENG_9 vs 3.2) and i was surprised to see that our system calls are significantly slower. On comparable hardware (i7-2600k vs E5-1650) the syscall getppid() takes about 95ns on FreeBSD and 38ns on linux. (i make sure not to use gettimeofday(), which in linux is through vdso, and getpid(), which is cached by glibc). Any idea on why there is this difference and whether/how we can reduce it ? I'm curious about how did you measure that ? Could you write some more about your methodology ? -LW cheers luigi __**_ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/**mailman/listinfo/freebsd-**currenthttp://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscribe@** freebsd.org freebsd-current-unsubscr...@freebsd.org -- -+--- Prof. Luigi RIZZO, ri...@iet.unipi.it . Dip. di Ing. dell'Informazione http://www.iet.unipi.it/~luigi/. Universita` di Pisa TEL +39-050-2211611 . via Diotisalvi 2 Mobile +39-338-6809875 . 56122 PISA (Italy) -+--- ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: syscall cost freebsd vs linux ?
On 26 November 2012 15:39, Lukasz Wojcik lukasz.woj...@zoho.com wrote: On 11/19/12 20:32, Luigi Rizzo wrote: today i was comparing the performance of some netmap-related code on FreeBSD and Linux (RELENG_9 vs 3.2) and i was surprised to see that our system calls are significantly slower. On comparable hardware (i7-2600k vs E5-1650) the syscall getppid() takes about 95ns on FreeBSD and 38ns on linux. (i make sure not to use gettimeofday(), which in linux is through vdso, and getpid(), which is cached by glibc). Any idea on why there is this difference and whether/how we can reduce it ? I'm curious about how did you measure that ? Could you write some more about your methodology ? There is a nice tool at /usr/src/tools/tools/syscall_timing -- wbr, pluknet ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: syscall cost freebsd vs linux ?
On 11/19/12 11:32 PM, Luigi Rizzo wrote: today i was comparing the performance of some netmap-related code on FreeBSD and Linux (RELENG_9 vs 3.2) and i was surprised to see that our system calls are significantly slower. On comparable hardware (i7-2600k vs E5-1650) the syscall getppid() takes about 95ns on FreeBSD and 38ns on linux. (i make sure not to use gettimeofday(), which in linux is through vdso, and getpid(), which is cached by glibc). Any idea on why there is this difference and whether/how we can reduce it ? This is the cost of blocking mutexes. Linux uses RCU instead [1]. Here are the numbers on current: $ time ./getppid 1 real0m22.926s user0m2.252s sys 0m20.669s After locking removing (patch below): $ time ./getppid 1 real0m15.224s user0m2.355s sys 0m12.868s Unfortunately, RCU can be used only in GPL code, but we can use passive serialization for simple deref. And even more, it's already implemented in NetBSD. [1] https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=kernel/timer.c;h=367d008584823a6fe01ed013cda8c3693fcfd761;hb=HEAD#l1411 [2] http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_pserialize.c?rev=1.5content-type=text/x-cvsweb-markup diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 7c46b2d..a13a17c 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -123,9 +123,7 @@ sys_getppid(struct thread *td, struct getppid_args *uap) { struct proc *p = td-td_proc; - PROC_LOCK(p); td-td_retval[0] = p-p_pptr-p_pid; - PROC_UNLOCK(p); return (0); } -- Andrey Zonov signature.asc Description: OpenPGP digital signature
syscall cost freebsd vs linux ?
today i was comparing the performance of some netmap-related code on FreeBSD and Linux (RELENG_9 vs 3.2) and i was surprised to see that our system calls are significantly slower. On comparable hardware (i7-2600k vs E5-1650) the syscall getppid() takes about 95ns on FreeBSD and 38ns on linux. (i make sure not to use gettimeofday(), which in linux is through vdso, and getpid(), which is cached by glibc). Any idea on why there is this difference and whether/how we can reduce it ? cheers luigi ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org