From owner-freebsd-java Tue Jul 25 8:43: 0 2000 Delivered-To: freebsd-java@freebsd.org Received: from ares.trc.adelaide.edu.au (ares.trc.adelaide.edu.au [129.127.246.5]) by hub.freebsd.org (Postfix) with ESMTP id 92EDF37B649 for ; Tue, 25 Jul 2000 08:42:54 -0700 (PDT) (envelope-from glewis@ares.trc.adelaide.edu.au) Received: (from glewis@localhost) by ares.trc.adelaide.edu.au (8.9.3/8.9.3) id BAA22456; Wed, 26 Jul 2000 01:12:38 +0930 (CST) (envelope-from glewis) From: Greg Lewis Message-Id: <200007251542.BAA22456@ares.trc.adelaide.edu.au> Subject: Re: Patches to allow timing based profiling. In-Reply-To: <55ittv41lx.wl@is.titech.ac.jp> from Fuyuhiko Maruyama at "Jul 25, 2000 07:14:50 am" To: Fuyuhiko Maruyama Date: Wed, 26 Jul 2000 01:12:38 +0930 (CST) Cc: freebsd-java@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL70 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM964539758-18521-0_ Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --ELM964539758-18521-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Fuyuhiko Maruyama wrote: > Hi, all. > > I made a patches to allow timing based profiling (using hprof) > on FreeBSD JDK 1.2.2 (with patchset-9). Arigato Maruyama-san! > Patches attached this mail make two contributions: > 1. On pentium-platform (not PentiumPro, PentiumII, K6...), there > was problem JVM causes Segmentation Fault when profiling is > enabled. This is assembler version interpretter's bug (may be in > Solaris/Win32 version). The patch for executeJava_p5.inc fix > this bug. Good catch :). > 2. Patchset-9 doesn't give meaningful value for sysThreadCPUTime() > function. On Solaris, the function is implemented using > gethrvtime() which doesn't exist on FreeBSD, so patchset-9 used > to simply return 0. This is not so serious problem whenever > timing based profiling isn't used. The patch for threads_md.c > implement the function using getrusage(...). This may be too > heavy function, but I don't know any other simple alternatives. > The good news is, it will be used *only when* timing based > profiling is enabled, so I believe the heavyness of > sysThreadCPUTime() doesn't affect the efficiency of non-profiling > run. I've done this one slightly differently. I just named the function you implemented gethrvtime, which simplified the code a little bit. I don't think this has any adverse affects. I will attach a diff so you can look it over. -- Greg Lewis glewis@trc.adelaide.edu.au Computing Officer +61 8 8303 5083 Teletraffic Research Centre --ELM964539758-18521-0_ Content-Type: text/plain; charset=US-ASCII Content-Disposition: attachment; filename=threads_md.diff Content-Description: threads_md.diff Content-Transfer-Encoding: 7bit --- threads_md.c.orig Wed Jul 26 00:01:35 2000 +++ threads_md.c Wed Jul 26 00:08:15 2000 @@ -20,7 +20,9 @@ #include #ifdef __FreeBSD__ +#include #include +#include #else #include #endif @@ -953,15 +955,29 @@ static jlong sliceStartTime = -1; +#ifdef __FreeBSD__ +/* + * FreeBSD doesn't have gethrvtime(), so implement it using getrusage(). + */ +static inline jlong +gethrvtime() +{ + struct rusage rusage; + jlong time; + getrusage(RUSAGE_SELF, &rusage); + return ((jlong)rusage.ru_utime.tv_sec) * (jlong)1000000000 + + ((jlong)rusage.ru_utime.tv_usec * (jlong)1000) + + ((jlong)rusage.ru_stime.tv_sec) * (jlong)1000000000 + + ((jlong)rusage.ru_stime.tv_usec * (jlong)1000); +} +#endif + + jlong sysThreadCPUTime() { sys_thread_t * t = greenThreadSelf(); -#ifdef __FreeBSD__ - jlong time = 0LL; -#else jlong time = gethrvtime(); -#endif if (sliceStartTime == -1) sliceStartTime = time; time += t->elapsedCPUTime - sliceStartTime; @@ -972,11 +988,7 @@ updateSliceStart() { sys_thread_t * t = greenThreadSelf(); -#ifdef __FreeBSD__ - jlong time = 0LL; -#else jlong time = gethrvtime(); -#endif if (sliceStartTime == -1) sliceStartTime = time; t->elapsedCPUTime += time - sliceStartTime; --ELM964539758-18521-0_-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message