Date: Tue, 18 Sep 2007 07:21:48 -0400 From: Kurt Miller <kurt@intricatesoftware.com> To: freebsd-java@freebsd.org Cc: Daniel Eischen <deischen@freebsd.org>, Kip Macy <kip.macy@gmail.com>, Kris Kennaway <kris@freebsd.org>, performance@freebsd.org Subject: Re: Massive performance loss from OS::sleep hack Message-ID: <200709180721.48995.kurt@intricatesoftware.com> In-Reply-To: <46EDDCC9.90403@intricatesoftware.com> References: <46EC1B55.4060202@FreeBSD.org> <b1fa29170709161256n25bdb7d8q8aa2f1b263c18e48@mail.gmail.com> <46EDDCC9.90403@intricatesoftware.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_MT77G2sKRW3o4KJ
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
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, \
--Boundary-00=_MT77G2sKRW3o4KJ--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709180721.48995.kurt>
