cvs commit: src/sys/libkern mcount.c

Bruce Evans brde at
Thu Jun 14 11:16:41 UTC 2007

On Wed, 13 Jun 2007, Kip Macy wrote:

> On 6/13/07, Kip Macy <kip.macy at> wrote:
>> - Original message -
>> No. It's unlikely that you even configure profiling.  Bruce
>> ROTFL. In that case what does 'config -pp' do? And why did it print
>> something to the effect of "profiling configured" on the console? And
>> why did the hang go away when I re-built without '-pp'?
>> Never mind. I'll just take the time to update the hwpmc support for my
>> hardware. "hwpmc" also doesn't cause a 50% slowdown when in use.
> To be more specific, low-resolution profiling works but causes
> netserver rx to drop from 9.7Gbps to 4Gbps. I'd like to know why you
> thought it was not configured.

Profiling (both kernel and userland) is too expensive to configure if
you're not using it.

I see a slowdown of 50% for "ping -fq localhost" with kernel profiling
configured but not even enabled.  ttcp with small packets doesn't slow
down quite quite as much until profiling is enabled.  Then a 50-70%
slowdown is normal.  There are just too much layering for things to
be very fast with profiling or as fast as possible without profiling.
However, operations not involving tinygrams are not slowed down too
much by profiling.  I think the extra function calls for profiling are
relatively more expensive (on amd CPUs at least) than they used to be
because they disturb pipelining relatively more, perhaps by hitting a
CPU resource limit that doesn't show up in simpler benchmarks.

One of the problems with gcc's -finstrument-functions feature has a
large overhead that keeps getting larger.  FreeBSD used to use this
because it is more portable than -pg and my -mprofiler-epilogue feature
and -mprofiler-epilogue gets broken by most gcc imports.  In gcc-3.4,
-finstrument functions became unusable since it breaks inlining of all
the little static inline functions in the kernel.  In gcc-4-2,, these
functions are inlined again, but they are still instrumented, and
actually instrumenting them is the most expensive part -- it gives a
pair of calls to profiling routines for all of the little static
functions in the kernel.  Instrumentation calls also cost more than
-pf -mprofiler-epilogue due to their portablility (same number of calls
but 2 parameters to pass for each call).  Instrumentation can be turned
off using an attribute(()) but I would prefer not to do that.  It is
a feature to be able to intrument all functions but you usually don't
want to instrument the ones that have been inlined for efficiency.


More information about the cvs-all mailing list