FreeBSD vs Linux cpu usage measurements
Dan Nelson
dnelson at allantgroup.com
Thu Jun 3 14:54:06 GMT 2004
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 at allantgroup.com
More information about the freebsd-hackers
mailing list