Date: Tue, 25 Jul 2000 07:14:50 +0900 From: Fuyuhiko Maruyama <fuyuhik8@is.titech.ac.jp> To: freebsd-java@FreeBSD.ORG Subject: Patches to allow timing based profiling. Message-ID: <55ittv41lx.wl@is.titech.ac.jp>
next in thread | raw e-mail | index | archive | help
--Multipart_Tue_Jul_25_07:14:43_2000-1
Content-Type: text/plain; charset=US-ASCII
Hi, all.
I made a patches to allow timing based profiling (using hprof)
on FreeBSD JDK 1.2.2 (with patchset-9).
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.
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.
With this patches, you can get timing based profiling data using
hprof like:
$ java -Xrunhprof:cpu=times Hello
Thank you.
--
Fuyuhiko Maruyama <fuyuhik8@is.titech.ac.jp>
Matsuoka laboratory,
Department of Mathematical and Computing Sciences,
Graduate School of Tokyo Institute of Technology.
--Multipart_Tue_Jul_25_07:14:43_2000-1
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="profiling.diffs"
Content-Transfer-Encoding: 7bit
--- src/share/javavm/runtime/executeJava_p5.inc.orig Tue Jun 29 19:16:43 1999
+++ src/share/javavm/runtime/executeJava_p5.inc Mon Jul 24 12:15:57 2000
@@ -220,6 +220,7 @@
jnz Lb(Profiling_jvmpi_$1)
Lb(BackFromProfiling_jvmpi_$1):
+ xor eax, eax
MOV(eax, al, BYTE PTR [esi])
Dispatch0
--- src/freebsd/hpi/green_threads/src/threads_md.c.orig Tue Jun 20 03:01:46 2000
+++ src/freebsd/hpi/green_threads/src/threads_md.c Mon Jul 3 11:41:38 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,12 +955,27 @@
static jlong sliceStartTime = -1;
+#ifdef __FreeBSD__
+static inline jlong
+ruGethrvtime()
+{
+ 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;
+ /* jlong time = 0LL; */
+ jlong time = ruGethrvtime();
#else
jlong time = gethrvtime();
#endif
@@ -973,7 +990,8 @@
{
sys_thread_t * t = greenThreadSelf();
#ifdef __FreeBSD__
- jlong time = 0LL;
+ /* jlong time = 0LL; */
+ jlong time = ruGethrvtime();
#else
jlong time = gethrvtime();
#endif
--Multipart_Tue_Jul_25_07:14:43_2000-1--
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?55ittv41lx.wl>
