Massive performance loss from OS::sleep hack

Daniel Eischen deischen at freebsd.org
Tue Sep 18 05:29:26 PDT 2007


On Tue, 18 Sep 2007, Kurt Miller wrote:

> David Xu confirmed for me that pthread_yield() does give some
> time to lower priority threads on 7.0 using thr. Attached and inline
> are two patches for the 1.5 port that is how I suggest the issue be
> addressed.

I don't think you should rely on pthread_yield() doing that,
it is dependent on the scheduler, and if you are running
in SCHED_FIFO/SCHED_RR, it won't work with libthr either.
Currently, you can only run in SCHED_FIFO or SCHED_RR as
root using libthr, but that hopefully won't always be
true.

I think the way that will always work is to lower the
priority and raise it back again after the yield, when
using thread priorities.  This should work for libthr,
libc_r, and libkse under all versions of the OS.

As for knobs, it would be nice to be able to turn off
the default lowering and raising of priorities for
Thread.yield() even when using thread priorities.  Most
likely, the only applications that relies on that behavior
are the TCK tests themselves.  I certainly wouldn't expect
Thread.yield() to allow a lower priority thread to
run.

Are you allowed to supply knobs when running the TCK
tests?  Or does the JVM have to do the right thing by
default?

-- 
DE


More information about the freebsd-performance mailing list