From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 3 07:54:06 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B5B016A4CE for ; Thu, 3 Jun 2004 07:54:06 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 231F443D48 for ; Thu, 3 Jun 2004 07:54:06 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i53Es5YA069029; Thu, 3 Jun 2004 09:54:05 -0500 (CDT) (envelope-from dan) Date: Thu, 3 Jun 2004 09:54:05 -0500 From: Dan Nelson To: Steven Hartland Message-ID: <20040603145405.GD80605@dan.emsphone.com> References: <184b01c4496c$4ea3a6a0$7b07000a@int.mediasurface.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <184b01c4496c$4ea3a6a0$7b07000a@int.mediasurface.com> X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-hackers@freebsd.org Subject: Re: FreeBSD vs Linux cpu usage measurements X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2004 14:54:06 -0000 In the last episode (Jun 03), Steven Hartland said: > I've been trying to do a direct comparison of game server cpu usages > across various OS. Our current primary OS is FreeBSD 5.X running a > 200HZ kernel. Initial tests on a dual boot opteron showed Linux using > 0% CPU for 32 player servers so I got suspicious. > > >From talking to people it appears that Linux only registers cpu usage > on the click tick so if a process was scheduled on the previous tick > but yielded before the current tick it would have 0% cpu usage. In > and extreme case could mean a process using 90% cpu or more could > still be show in top as using 0% I haven't seen this myself on any of my Linux boxes, but then again, I never use procps top. I always install unixtop (www.unixtop.org), to maintain the same top across all OSes. > This seemed to be extremely noticeable on a 2.4.15 kernel but the > values seem to me "more" correct on 2.6.5 but I believe this will be > entirely down to the increase from 100Hz in 2.4 -> 1000Hz in 2.6. > > Anyway that's the background now to the question. Is there a > fundamental difference in the way that FreeBSD records process cpu > usage as I've seen this behaviour while running FreeBSD ever. The "%CPU" column as shown by top is pretty much whatever the person that wrote the scheduler decides it is :) On AIX, for example, it's a number that starts at 0 every scheduling interval and ramps up to 120 slowly. Both of FreeBSD's schedulers use a decaying average for their %CPU. What unixtop does for about 25% of the platforms it supports is dig into the rusage data for each process and remember the last value, which gives you instantaneous %CPU over the previous sampling interval. -- Dan Nelson dnelson@allantgroup.com