From owner-freebsd-performance@FreeBSD.ORG Wed Sep 19 02:13:04 2007 Return-Path: Delivered-To: performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C5F116A41A; Wed, 19 Sep 2007 02:13:04 +0000 (UTC) (envelope-from kurt@intricatesoftware.com) Received: from mail1.intricatesoftware.com (cl-18.ewr-01.us.sixxs.net [IPv6:2001:4830:1200:11::2]) by mx1.freebsd.org (Postfix) with ESMTP id AE5CA13C474; Wed, 19 Sep 2007 02:13:03 +0000 (UTC) (envelope-from kurt@intricatesoftware.com) Received: from seraph.intricatesoftware.com (relay@localhost.intricatesoftware.com [IPv6:::1]) by mail1.intricatesoftware.com (8.14.1/8.13.4) with ESMTP id l8J2D05f030590; Tue, 18 Sep 2007 22:13:01 -0400 (EDT) Received: from seraph.intricatesoftware.com (truk@localhost.intricatesoftware.com [127.0.0.1]) by seraph.intricatesoftware.com (8.14.1/8.14.1) with ESMTP id l8J2D1gE025066; Tue, 18 Sep 2007 22:13:01 -0400 (EDT) Received: (from truk@localhost) by seraph.intricatesoftware.com (8.14.1/8.14.1/Submit) id l8J2D1X0010907; Tue, 18 Sep 2007 22:13:01 -0400 (EDT) X-Authentication-Warning: seraph.intricatesoftware.com: truk set sender to kurt@intricatesoftware.com using -f From: Kurt Miller To: freebsd-java@freebsd.org Date: Tue, 18 Sep 2007 22:13:00 -0400 User-Agent: KMail/1.9.7 References: <46EC1B55.4060202@FreeBSD.org> <200709180721.48995.kurt@intricatesoftware.com> <46F0243A.8020902@FreeBSD.org> In-Reply-To: <46F0243A.8020902@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200709182213.00777.kurt@intricatesoftware.com> X-SMTP-Vilter-Version: 1.3.6 X-SMTP-Vilter-Virus-Backend: clamd X-SMTP-Vilter-Status: clean X-SMTP-Vilter-clamd-Virus-Status: clean X-Spamd-Symbols: ALL_TRUSTED X-SMTP-Vilter-Spam-Backend: spamd X-Spam-Score: -1.4 X-Spam-Threshold: 5.0 X-Spam-Probability: -0.3 X-Its-A-Nuisance: This is spam X-SMTP-Vilter-Unwanted-Backend: attachment X-SMTP-Vilter-attachment-Unwanted-Status: clean Cc: Daniel Eischen , Kip Macy , Kris Kennaway , performance@freebsd.org Subject: Re: Massive performance loss from OS::sleep hack X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2007 02:13:04 -0000 On Tuesday 18 September 2007 03:17:14 pm Kris Kennaway wrote: > 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. > > > > 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 > > Do we know that 6.x requires the old behaviour? Maybe it can default to > on there too. Otherwise this looks good to my eyeball (but the > DEFAULT_LD_LIBRARY_PATH change looks unrelated) > > -#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) Yea I messed up the DEFAULT_LD_LIBRARY_PATH part. I didn't intend to change that segment of the existing os_bsd.cpp patch. Regarding 6.x it either needs UseThreadPriorities defaulted to false or the os_sleep hack. After discussing the options with Daniel we agree that defaulting UseThreadPriorities to false and eliminating the os_sleep hack for all versions is the most consitant approach. The following is a CVS diff of ports/java/jdk15 that updates the port to fix the performance issue plus an alternative method to setting DEFAULT_LD_LIBRARY_PATH without patching and substituting it: Index: Makefile =================================================================== RCS file: /home/ncvs/ports/java/jdk15/Makefile,v retrieving revision 1.135 diff -u -r1.135 Makefile --- Makefile 7 Sep 2007 20:41:52 -0000 1.135 +++ Makefile 19 Sep 2007 01:53:17 -0000 @@ -7,7 +7,7 @@ PORTNAME= jdk PORTVERSION= ${JDK_VERSION}.${JDK_UPDATE_VERSION}p${JDK_PATCHSET_VERSION} -PORTREVISION= 1 +PORTREVISION= 2 PORTEPOCH= 1 CATEGORIES= java devel MASTER_SITES= # http://download.java.net/tiger/ @@ -129,6 +129,7 @@ MAKE_ENV+= ALT_BOOTDIR="${BOOTSTRAPJDKDIR}" \ ALT_MOTIF_DIR="${X11BASE}" \ + DEFAULT_LD_LIBRARY_PATH="/usr/lib:${LOCALBASE}/lib" \ SYS_CFLAGS="${CFLAGS}" \ LANG="C" \ JAVA_HOME="" \ @@ -161,7 +162,6 @@ JDKIMAGEDIR= ${WRKSRC}/../build/bsd-${HOTSPOTARCH}/j2sdk-image JDKIMAGEDIR_G= ${WRKSRC}/../build/bsd-${HOTSPOTARCH}/j2sdk-debug-image -LOCAL_FILES= ../../hotspot/src/os/bsd/vm/os_bsd.cpp PTHREAD_FILES= ../../hotspot/build/bsd/makefiles/vm.make \ ../../j2se/make/com/sun/java/pack/Makefile \ ../../j2se/make/common/Defs.gmk \ @@ -265,10 +265,6 @@ .endif post-patch: - @for file in ${LOCAL_FILES}; do \ - ${REINPLACE_CMD} -e "s:%%LOCALBASE%%:${LOCALBASE}:" \ - ${WRKSRC}/$${file}; \ - done @for file in ${PTHREAD_FILES}; do \ ${REINPLACE_CMD} -e "s:-pthread:${PTHREAD_LIBS}:g" \ ${WRKSRC}/$${file}; \ Index: files/patch-vm::globals.hpp =================================================================== RCS file: files/patch-vm::globals.hpp diff -N files/patch-vm::globals.hpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-vm::globals.hpp 19 Sep 2007 01:53:17 -0000 @@ -0,0 +1,26 @@ +$FreeBSD$ + +--- ../../hotspot/src/share/vm/runtime/globals.hpp.orig Wed May 2 04:01:50 2007 ++++ ../../hotspot/src/share/vm/runtime/globals.hpp Tue Sep 18 21:40:44 2007 +@@ -130,6 +130,12 @@ + #define falseInProduct true + #endif + ++#if defined(_ALLBSD_SOURCE) ++#define OSUseThreadPriorities false ++#else ++#define OSUseThreadPriorities true ++#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, \ Index: files/patch-vm::os_bsd.cpp =================================================================== RCS file: /home/ncvs/ports/java/jdk15/files/patch-vm::os_bsd.cpp,v retrieving revision 1.7 diff -u -r1.7 patch-vm::os_bsd.cpp --- files/patch-vm::os_bsd.cpp 9 Jun 2007 05:14:56 -0000 1.7 +++ files/patch-vm::os_bsd.cpp 19 Sep 2007 01:53:17 -0000 @@ -1,13 +1,32 @@ $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 Sun Jun 3 18:46:31 2007 -+++ ../../hotspot/src/os/bsd/vm/os_bsd.cpp.orig Sun Jun 3 18:47:28 2007 -@@ -499,7 +499,7 @@ - #define getenv(n) ::getenv(n) +--- ../../hotspot/src/os/bsd/vm/os_bsd.cpp.orig Mon Sep 17 21:03:04 2007 ++++ ../../hotspot/src/os/bsd/vm/os_bsd.cpp Tue Sep 18 21:36:51 2007 +@@ -2271,13 +2271,7 @@ + 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 + + #if SOLARIS + // XXX - This code was not exercised during the Merlin RC1 +@@ -2297,13 +2291,7 @@ + return 0; + } + +-// 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(); +-#endif + return 0; + } - #ifndef DEFAULT_LD_LIBRARY_PATH --#define DEFAULT_LD_LIBRARY_PATH "/usr/lib" /* See ld.so.1(1) */ -+#define DEFAULT_LD_LIBRARY_PATH "/usr/lib:%%LOCALBASE%%/lib" /* See ld.so.1 (1) */ - #endif - #define EXTENSIONS_DIR "/lib/ext" - #define ENDORSED_DIR "/lib/endorsed"