Re: Massive performance loss from OS::sleep hack



Kris Kennaway wrote:
Hi,

I have been running the volano java benchmark (http://www.volano.com/benchmarks.html) on an 8-core i386 system, and out of the box jdk15 on FreeBSD performs extremely poorly. The system is more than 90% idle, and profiling shows that the ~800 threads in the benchmark are spending most of their time doing short nanosleep() calls.


I traced it to the following FreeBSD-specific hack in the jdk:

// XXXBSD: understand meaning and workaround related to yield
...
// XXXBSD: done differently in 1.3.1, take a look
int os::sleep(Thread* thread, jlong millis, bool interruptible) {
assert(thread == Thread::current(), "thread consistency check");
...

if (millis <= 0) {
// NOTE: workaround for bug 4338139
if (thread->is_Java_thread()) {
ThreadBlockInVM tbivm((JavaThread*) thread);
// BSDXXX: Only use pthread_yield here and below if the system thread
// scheduler gives time slices to lower priority threads when yielding.
#ifdef __FreeBSD__
os_sleep(MinSleepInterval, interruptible);
#else
pthread_yield();
#endif

When I removed this hack (i.e. revert to pthread_yield()) I got an immediate 7-fold performance increase, which brings FreeBSD performance on par with Solaris.

What is the reason why this code is necessary? Does FreeBSD's sched_yield() really have different semantics to the other operating systems, or was this a libkse bug that was being worked around?

Kris

Yeah, our sched_yield() really works well, in kernel, if the thread
scheduling policy is SCHED_OTHER (time-sharing), scheduler temporarily
lowers its priority to PRI_MAX_TIMESHARE, it is enough to give some CPU
time to other threads. Why doesn't the UNIX time-sharing work for java ?

Regards,
David Xu

_______________________________________________
freebsd-performance@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "freebsd-performance-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: whats the different between sched_core.c and sched_ule.c?
    ... maintains a set of KSE together, ... For Linux kernel 2.6 there were two competing ... Now, for FreeBSD, several benchmarks about threaded programs have circulated, ... And this is *not* the case of the BSD scheduler. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: Massive performance loss from OS::sleep hack
    ... I have been running the volano java benchmark ... When I removed this hack ) I got an immediate 7-fold performance increase, which brings FreeBSD performance on par with Solaris. ... Does FreeBSD's sched_yieldreally have different semantics to the other operating systems, or was this a libkse bug that was being worked around? ... latest POSIX spec. ...
    (freebsd-performance)
  • Re: Future of FreeBSD
    ... > of FreeBSD and direction of developement. ... The reality is that developers move on. ... This seems like an extreme characterization. ... 4BSD scheduler, but other things slightly less well. ...
    (freebsd-current)
  • Massive performance loss from OS::sleep hack
    ... I have been running the volano java benchmark ... When I removed this hack ) I got an immediate 7-fold performance increase, which brings FreeBSD performance on par with Solaris. ... Does FreeBSD's sched_yieldreally have different semantics to the other operating systems, or was this a libkse bug that was being worked around? ...
    (freebsd-performance)
  • Re: Google SoC 2009 Idea
    ... On Wed, 25 Feb 2009, Tim Kientzle wrote: ... Since you posted to a lot of different lists, I think you probably don't already use FreeBSD. ... Scheduler work is quite complex and interacts heavily with the rest of the system; it may not be a good choice for someone who doesn't already have a lot of experience with FreeBSD. ...
    (freebsd-hackers)

Quantcast