Skip site navigation (1)Skip section navigation (2)
Date:      Sun,  6 Feb 2005 11:06:48 +0100 (CET)
From:      Anthony Ginepro <anthony.ginepro@laposte.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   java/77162: Tomcat5 regression with jdk15-p1
Message-ID:  <20050206100648.2F5782073@renaissance.homeip.net>
Resent-Message-ID: <200502061010.j16AAIuw079057@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         77162
>Category:       java
>Synopsis:       Tomcat5 regression with jdk15-p1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-java
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 06 10:10:18 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Anthony Ginepro
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD renaissance.homeip.net 5.3-STABLE FreeBSD 5.3-STABLE #1: Sun Feb 6 10:02:52 CET 2005 rapiere@renaissance.homeip.net:/usr/obj/usr/src/sys/CUSTOM_20041231 i386
Tomcat 5.0 and 5.5

>Description:
	Tomcat 5.x becomes much slower with jdk15-p1 than jdk15-exp 
	as reported in :
	http://marc.theaimsgroup.com/?l=freebsd-java&m=110633266311615&w=2

	After some experiments, I get back normal operations when reverting
	hotspot/src/os/bsd/vm/os_bsd.cpp (which is what the patch joined does).

>How-To-Repeat:
	Start Tomcat 5.x and check logs/catalina.out for startup time.
	Try JSP pages which are also slow the first time.
>Fix:
--- os_bsd.cpp	Sun Feb  6 10:49:29 2005
+++ /data/jdk15-new1/work/hotspot/src/os/bsd/vm/os_bsd.cpp	Sat Feb  5 17:36:49 2005
@@ -1,8 +1,10 @@
+// XXXBSD: check usage of ::sleep()s (looks like Solaris's ones are defined
+// in miliseconds, but FreeBSD's in seconds (convert to usleep/nanosleep?)
 // XXXBSD: double check of semantics of mmap() and family
-// XXXBSD: understand meaning and workaround related to yield
+// XXXBSD: understanmd meaning and workaround related to yield
 
 /*
- * $Id: os_bsd.cpp,v 1.6 2005/01/19 10:38:57 phantom Exp $
+ * $Id: os_bsd.cpp,v 1.4 2005/01/08 10:35:51 phantom Exp $
  */
 /*
  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
@@ -38,14 +40,6 @@
 #if defined(__FreeBSD__)
 # include <pthread_np.h>
 #endif
-#if defined(__NetBSD__)
-# include <sched.h>
-# include <sys/resource.h>
-# define pthread_yield() sched_yield()
-# define pthread_getprio(a) 0
-# define pthread_setprio(a, b) 0
-# define pthread_main_np() 0
-#endif
 
 #define MAX_PATH (1 * K)
 
@@ -377,7 +371,7 @@
 
 
 void os::init_system_properties_values() {
-#ifdef _ALLBSD_SOURCE
+#ifdef __FreeBSD__
   struct utsname uts;
   uname(&uts);
   const char *arch = uts.machine;
@@ -416,7 +410,7 @@
 #define malloc(n) (char*)NEW_C_HEAP_ARRAY(char, (n))
 #define getenv(n) ::getenv(n)
 
-#define DEFAULT_LD_LIBRARY_PATH "/usr/lib:/usr/local/lib" /* See ld.so.1(1) */
+#define DEFAULT_LD_LIBRARY_PATH "/usr/lib" /* See ld.so.1(1) */
 #define EXTENSIONS_DIR "/lib/ext"
 #define ENDORSED_DIR "/lib/endorsed"
 
@@ -1380,7 +1374,6 @@
 // Prints the names and full paths of all opened dynamic libraries
 // for current process
 void os::print_dll_info(outputStream * st) {
-#ifdef RTLD_DI_LINKMAP
     Dl_info dli;
     void *handle;
     Link_map *map;
@@ -1412,10 +1405,6 @@
     }
 
     dlclose(handle);
-    return;
-done:
-#endif
-    st->print_cr("Error: Cannot print dynamic libraries.");
 }
 
 bool _print_ascii_file(const char* filename, outputStream* st) {
@@ -1560,7 +1549,7 @@
     // Look for JAVA_HOME in the environment.
     char* java_home_var = ::getenv("JAVA_HOME");
     if (java_home_var != NULL && java_home_var[0] != 0) {
-#ifdef _ALLBSD_SOURCE
+#ifdef __FreeBSD__
       struct utsname uts;
       char cpu_arch[12];
       uname(&uts);
@@ -1887,22 +1876,50 @@
 }
 
 static int os_sleep(jlong millis, bool interruptible) {
-  struct timespec t;
+  const jlong limit = INT_MAX;
+  jlong prevtime;
   int res;
   
-  t.tv_sec = millis / 1000L;
-  t.tv_nsec = (millis % 1000L) * 1000000;
+  while (millis > limit) {
+    if ((res = os_sleep(limit, interruptible)) != OS_OK)
+      return res;
+    millis -= limit;
+  } 
+
+  // Restart interrupted polls with new parameters until the proper delay 
+  // has been completed.
+
+  prevtime = getTimeMillis();
+
+  while (millis > 0) {
+    jlong newtime;
+
   if (!interruptible) {
-    do {
-      res = nanosleep(&t, &t);
-    } while ((res == OS_ERR) && (errno == EINTR));
+    // Following assert fails for os::yield_all:
+    // assert(!thread->is_Java_thread(), "must not be java thread");
+    res = poll(NULL, 0, millis);
   } else {
     assert(Thread::current()->is_Java_thread(), "must be java thread");
-    INTERRUPTIBLE_NORESTART(nanosleep(&t, &t), res, os::Bsd::clear_interrupted);
+    INTERRUPTIBLE_NORESTART_VM(poll(NULL, 0, millis), res, 
+      os::Bsd::clear_interrupted);
   }
   // INTERRUPTIBLE_NORESTART_VM returns res == OS_INTRPT for thread.Interrupt
 
-  return res;
+    if((res == OS_ERR) && (errno == EINTR)) {
+      newtime = getTimeMillis();
+      assert(newtime >= prevtime, "time moving backwards");
+    /* Doing prevtime and newtime in microseconds doesn't help precision,
+       and trying to round up to avoid lost milliseconds can result in a
+       too-short delay. */
+      millis -= newtime - prevtime;
+      if(millis <= 0)
+	return OS_OK;
+      prevtime = newtime;
+    } else
+      return res;
+  }
+
+  return OS_OK;
 }
 
 int os::Bsd::naked_sleep() {

	


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050206100648.2F5782073>