Subject: Re: Some kernel profiling on a 5000/133 with -current
To: port-pmax <port-pmax@netbsd.org>
From: Ken Wellsch <kwellsch@tampabay.rr.com>
List: port-pmax
Date: 08/30/2001 13:04:02
On Fri, Aug 24, 2001 at 03:39:50PM -0400, Ken Wellsch wrote:
>
> index % time self children called name
> -----------------------------------------------------------------
> [10] 19.7 249.70 0.00 2023108 memcpy [10]
> -----------------------------------------------
> [16] 7.8 0.36 98.55 796813 microtime <cycle 8> [16]
> 98.35 0.00 796813/2023108 memcpy [10]
> -----------------------------------------------
> ...
I kept looking at this wondering, where the heck does microtime()
ever call memcpy()?
Well, I pondered this for a while and in looking at the code in
pmax/machdep.c I notice two "structure copies."
Sure enough, when I look at the assembler produced by "gcc" I see:
...
move $4,$16
move $17,$2
la $5,time
.set noreorder
.set nomacro
jal memcpy
li $6,8 # 0x8
.set macro
.set reorder
...
which matches up with the line "*tvp = time;" below:
microtime(tvp)
struct timeval *tvp;
{
int s = splclock();
static struct timeval lasttime;
*tvp = time;
...
Apparently "time" is treated as volatile, while the closing
structure copy "lasttime = *tvp;" does not involve memcpy().
So given that this code is executing with splclock(), is it
possible to replace
*tvp = time;
by
tvp->tv_sec = time.tv_sec;
tvp->tv_usec = time.tv_usec;
and thus avoid this expensive and ever so frequent call?
Cheers,
-- Ken