amd64 cpu_switch in C.

Jeff Roberson jroberson at chesapeake.net
Wed Mar 12 08:51:22 UTC 2008


On Wed, 12 Mar 2008, Peter Wemm wrote:

> On Tue, Mar 11, 2008 at 9:14 PM, David Xu <davidxu at freebsd.org> wrote:
>> Jeff Roberson wrote:
>> > http://people.freebsd.org/~jeff/amd64.diff
>>
>>  This is a good idea. In fact, according to calling conversion, some
>>  registers are not needed to be saved across function call, e.g on
>>  i386, eax, edx, and ecx. :-) but gdb may need them to dig out
>>  stack variable's value.
>
> Jeff and I have been having a friendly "competition" today.
>
> With a UP kernel and INVARIANTS, my initial counter-patch response had
> nearly double the gain on my machine.  (Jeff 7%, mine: 13.5%).
> I changed to compile kernels the same as he did (no invariants, SMP
> kernel, but kern.smp.disabled=1).  After that, our patch sets were the
> same again - both at about 10% gain over baseline.
>
> I've made a few more changes and am now at 23% improvement over baseline.

The question is whether we care to have it in C or not.  Given a C and 
assembly version with similar optimizations the assembly version will 
always win.  However, it's easier to write the optimizations in C.

>
> I'm not confident of testing methodology.  More tests are in progress.

To keep everyone else up to date;  We're using:
http://people.freebsd.org/~jeff/yield.c & yield.sh

Given two processes and the scheduling methodology for sched_yield() every 
yield should trigger a context switch to a new process.

>
> The good news is that this tuning is finally being done.  It should
> have been done in 2003 though...

Yes indeed, better late than never.

>
> -- 
> Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
> "All of this is for nothing if we don't go to the stars" - JMS/B5
> "If Java had true garbage collection, most programs would delete
> themselves upon execution." -- Robert Sewell
>


More information about the freebsd-arch mailing list