[tjr@FreeBSD.org: cvs commit: src/lib/libpthread/arch/amd64/amd64 context.S]

Tim Robbins tjr at freebsd.org
Tue Jun 8 01:44:01 GMT 2004


On Tue, Jun 08, 2004 at 09:10:27AM +0800, David Xu wrote:
> Is there any reason to use memory indirect jump ? did you
> have benchmarked context switch speed before and after this commit ?
> I won't use such indirect jump in speed sensitive case, it is
> not CPU branch trace cache friendly, it is better to use
> ret to match call in up level.

For the reason Peter mentioned, we can't use "ret" in the general case.
It may be possible to do it that way for voluntary/synchronous context
switches, but it's probably not worth the effort -- even the i386
context switch functions have not been micro-optimised to this level:
they save scratch registers + flags, perform redundant null pointer
checks, validate mc_len, initialise and save the FPU control word for
threads that don't touch the FPU, perform unaligned jumps, etc. etc.

As for benchmarks: the new version runs Mozilla infinitely faster :-)


Tim


More information about the freebsd-amd64 mailing list