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:Kurt Miller (ku@intricatesoftware.com)
Date:Sep 18, 2007 4:21:47 am
List:org.freebsd.freebsd-performance

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.

For 7.0 and up default UseThreadPriorities to true and always use pthread_yield(). For < 7.0 default UseThreadPriorities to false and conditionally use pthread_yield()/os_sleep(). User's can toggle UseThreadPriorities with the command line argument -XX:+UseThreadPriorities

-------- files/patch-vm::os_bsd.cpp -------- $FreeBSD: ports/java/jdk15/files/patch-vm::os_bsd.cpp,v 1.7 2007/06/09 05:14:56 glewis Exp $

--- ../../hotspot/src/os/bsd/vm/os_bsd.cpp.orig Mon Sep 17 17:39:33 2007 +++ ../../hotspot/src/os/bsd/vm/os_bsd.cpp Mon Sep 17 20:57:26 2007 @@ -508,7 +508,7 @@ #define getenv(n) ::getenv(n)

#ifndef DEFAULT_LD_LIBRARY_PATH -#define DEFAULT_LD_LIBRARY_PATH "/usr/lib" /* See ld.so.1(1) */ +#define DEFAULT_LD_LIBRARY_PATH "/usr/lib:/usr/local/lib" /* See ld.so.1(1) */ #endif #define EXTENSIONS_DIR "/lib/ext" #define ENDORSED_DIR "/lib/endorsed" @@ -2273,11 +2273,14 @@

// BSDXXX: Only use pthread_yield here and below if the system thread // scheduler gives time slices to lower priority threads when yielding. -#ifdef __FreeBSD__ +// pthread_yield() can also be used when thread priorities are disabled. +// Using os_sleep() here causes significant performance degradation. +#if defined(_ALLBSD_SOURCE) && (!defined(__FreeBSD__) || __FreeBSD__ < 7) + if ( UseThreadPriorities ) os_sleep(MinSleepInterval, interruptible); -#else - pthread_yield(); + else #endif + pthread_yield();

#if SOLARIS // XXX - This code was not exercised during the Merlin RC1 @@ -2299,11 +2302,14 @@

// BSDXXX: Only use pthread_yield here and above if the system thread // scheduler gives time slices to lower priority threads when yielding. -#ifdef __FreeBSD__ - os_sleep(MinSleepInterval, interruptible); -#else - pthread_yield(); +// pthread_yield() can be also used when thread priorities are disabled. +// Using os_sleep() here causes significant performance degradation. +#if defined(_ALLBSD_SOURCE) && (!defined(__FreeBSD__) || __FreeBSD__ < 7) + if ( UseThreadPriorities ) + os_sleep(MinSleepInterval, interruptible); + else #endif + pthread_yield(); return 0; }

------- files/patch-vm::globals.hpp -------- $FreeBSD$

--- ../../hotspot/src/share/vm/runtime/globals.hpp.orig Mon Sep 17 10:12:16 2007 +++ ../../hotspot/src/share/vm/runtime/globals.hpp Mon Sep 17 10:20:32 2007 @@ -130,6 +130,12 @@ #define falseInProduct true #endif

+#if !defined(_ALLBSD_SOURCE) || (defined(__FreeBSD__) && __FreeBSD__ >= 7) +#define OSUseThreadPriorities true +#else +#define OSUseThreadPriorities false +#endif + // develop flags are settable / visible only during development and are constant in the PRODUCT version // product flags are always settable / visible

@@ -2546,7 +2552,7 @@ "beginning to throw OutOfMemoryErrors in each compile") \ \ /* Priorities */ \ - product(bool, UseThreadPriorities, true, \ + product(bool, UseThreadPriorities, OSUseThreadPriorities, \ "Use native thread priorities") \ \ product(intx, ThreadPriorityPolicy, 0, \