Date: Wed, 26 Jul 2000 01:12:38 +0930 (CST) From: Greg Lewis <glewis@trc.adelaide.edu.au> To: Fuyuhiko Maruyama <fuyuhik8@is.titech.ac.jp> Cc: freebsd-java@FreeBSD.ORG Subject: Re: Patches to allow timing based profiling. Message-ID: <200007251542.BAA22456@ares.trc.adelaide.edu.au> In-Reply-To: <55ittv41lx.wl@is.titech.ac.jp> from Fuyuhiko Maruyama at "Jul 25, 2000 07:14:50 am"
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <string.h>
#ifdef __FreeBSD__
+#include <sys/types.h>
#include <sys/time.h>
+#include <sys/resource.h>
#else
#include <ucontext.h>
#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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007251542.BAA22456>
