atom feed22 messages in org.freebsd.freebsd-performanceMassive performance loss from OS::sle...
FromSent OnAttachments
Kris KennawaySep 15, 2007 10:49 am 
Kris KennawaySep 15, 2007 12:08 pm 
Daniel EischenSep 15, 2007 3:37 pm 
Daniel EischenSep 15, 2007 9:47 pm 
Kip MacySep 15, 2007 10:52 pm 
Kris KennawaySep 16, 2007 3:16 am 
Daniel EischenSep 16, 2007 8:45 am 
Kurt MillerSep 16, 2007 9:06 am 
Kurt MillerSep 16, 2007 9:06 am 
Kip MacySep 16, 2007 12:56 pm 
Alfred PerlsteinSep 16, 2007 6:16 pm 
Kurt MillerSep 16, 2007 6:47 pm 
David XuSep 16, 2007 7:33 pm 
Kurt MillerSep 18, 2007 4:21 am 
Daniel EischenSep 18, 2007 5:29 am 
Kurt MillerSep 18, 2007 7:15 am 
Daniel EischenSep 18, 2007 10:08 am 
Kurt MillerSep 18, 2007 10:28 am 
Daniel EischenSep 18, 2007 11:00 am 
Kris KennawaySep 18, 2007 12:16 pm 
Kurt MillerSep 18, 2007 7:12 pm 
Kris KennawaySep 19, 2007 3:16 am 
Subject:Massive performance loss from OS::sleep hack
From:Kip Macy (kip.@gmail.com)
Date:Sep 15, 2007 10:52:06 pm
List:org.freebsd.freebsd-performance

Or more likely they'll continue to maintain a sched_yield that isn't posix compliant. We may just want to add some sort of interface so the jvm can tell the kernel that sched_yield should be non-compliant for the current process.

On 9/15/07, Daniel Eischen <deis@freebsd.org> wrote:

On Sat, 15 Sep 2007, Kurt Miller wrote:

Hello Kris,

I recall why I added the os_sleep() call. While working on the certification testing one of the JCK tests was deadlocking. The test itself was faulty in that it created a high priority thread in a tight yield loop. Since pthread_yield() on a single processor system will not yield to lower priority threads, the higher priority thread effectively blocked the lower priority thread from running and the test deadlocked.

I filed a formal appeal to have the JCK test corrected. However since the api states:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#yield() "Causes the currently executing thread object to temporarily pause and allow other threads to execute."

the appeal was denied. I further argued that many publications written by or or-authored by Sun employees state that Thread.yield() can not be relied upon in this fashion:

[ ... ]

It's odd that Sun would take this position since the POSIX behavior for sched_yield() is:

The sched_yield() function shall force the running thread to relinquish the processor until it again becomes the head of its thread list. It takes no arguments.

The "its thread list" mentioned above is the list of threads for its given priority. POSIX has a notion of a list of threads for each given priority; in SCHED_RR and SCHED_FIFO scheduling the higher priority threads will always run before lower priority threads.

Sun's defined Java behavior, or their interpretation, of Thread.yield() is not obtainable on a POSIX compliant system using sched_yield() (or pthread_yield()). Even using scope system threads or libthr, the kernel scheduler should run the higher priority threads before lower priority threads.

I suspect that Sun will eventually be forced to change their documented behavior for Thread.yield().