Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jun 2004 09:54:05 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Steven Hartland <killing@multiplay.co.uk>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: FreeBSD vs Linux cpu usage measurements
Message-ID:  <20040603145405.GD80605@dan.emsphone.com>
In-Reply-To: <184b01c4496c$4ea3a6a0$7b07000a@int.mediasurface.com>
References:  <184b01c4496c$4ea3a6a0$7b07000a@int.mediasurface.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040603145405.GD80605>