Re: syscall cost freebsd vs linux ?

From: John Baldwin <jhb_at_freebsd.org>
Date: Fri, 11 Jan 2013 11:35:49 -0500
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 100000000
> 
> real	0m22.926s
> user	0m2.252s
> sys	0m20.669s
> 
> After locking removing (patch below):
> 
> $ time ./getppid 100000000
> 
> 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
Received on Fri Jan 11 2013 - 19:42:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:33 UTC