From owner-freebsd-current@FreeBSD.ORG Fri Jan 11 20:42:06 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B2596946; Fri, 11 Jan 2013 20:42:06 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 8FEB4F76; Fri, 11 Jan 2013 20:42:06 +0000 (UTC) Received: from ralph.baldwin.cx (c-68-39-198-164.hsd1.de.comcast.net [68.39.198.164]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id EE9CFB9B3; Fri, 11 Jan 2013 15:42:05 -0500 (EST) From: John Baldwin To: freebsd-current@freebsd.org Subject: Re: syscall cost freebsd vs linux ? Date: Fri, 11 Jan 2013 11:35:49 -0500 User-Agent: KMail/1.13.7 (FreeBSD/9.1-PRERELEASE; KDE/4.8.4; amd64; ; ) References: <20121119193202.GA79496@onelab2.iet.unipi.it> <50B460AA.10300@FreeBSD.org> In-Reply-To: <50B460AA.10300@FreeBSD.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201301111135.49997.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 11 Jan 2013 15:42:06 -0500 (EST) Cc: Andrey Zonov , Luigi Rizzo X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 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: Fri, 11 Jan 2013 20:42:06 -0000 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