From: Andrew Haley <aph@redhat.com>
To: ffileppo <ffileppo@libero.it>
Cc: java <java@gcc.gnu.org>, classpath <classpath@gnu.org>
Subject: Re: [GCJ] Performance of GUI applications on embedded systems
Date: Mon, 03 Nov 2008 14:53:00 -0000 [thread overview]
Message-ID: <490F101C.7030606@redhat.com> (raw)
In-Reply-To: <K9RD0K$D422D5C95E092FD552E987B8A2A75E5A@libero.it>
ffileppo wrote:
>>> oprofile is your friend. If you can get oprofile working on your
>>> target system, please use it and find out if it does what you need.
>> I did it. The answer is appended.
>>
>> The problem is that the program is spending almost all of the time
>> generating stack traces, millions and millions of them.
>>
> Hi Andrew,
> thanks a lot for your help.
>
> Do you have any ideas to fix this problem?
Here's one improvement. If you can get rid of the places in the GTK peers
where class and method lookups are performed at runtime you'll probably
have a fix. This shouldn't be a massive amount of work, just rather
boring.
In gcj,
* Compiled java code is quite fast.
* Class lookup by name is slow.
* Calling JNI code from compiled java code is quite fast.
* Calling compiled java code from JNI code is slow.
* Exceptions are slow.
Andrew.
Index: classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
===================================================================
--- classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h (revision 141430)
+++ classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h (working copy)
@@ -13,7 +13,7 @@
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_dispose (JNIEnv *env, jobject, jlongArray);
JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getNativeFontPointer (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphs (JNIEnv *env, jobject, jintArray, jintArray, jlongArray);
-JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning (JNIEnv *env, jobject, jint, jint, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning (JNIEnv *env, jobject, jint, jint, jlong, jfloatArray);
JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getMetricsNative (JNIEnv *env, jobject, jint, jlong);
JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative (JNIEnv *env, jobject, jint, jlong);
Index: classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
===================================================================
--- classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c (revision 141430)
+++ classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c (working copy)
@@ -169,9 +169,10 @@
(*env)->ReleaseLongArrayElements (env, fonts, fontArray, 0);
}
-JNIEXPORT jobject JNICALL
+JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning
-(JNIEnv *env, jobject obj __attribute__((unused)), jint rightGlyph, jint leftGlyph, jlong fnt)
+(JNIEnv *env, jobject obj __attribute__((unused)), jint rightGlyph, jint leftGlyph,
+ jlong fnt, jfloatArray p)
{
FT_Face ft_face;
FT_Vector kern;
@@ -187,12 +188,10 @@
pango_fc_font_unlock_face( font );
- values[0].d = (jdouble)kern.x/64.0;
- values[1].d = (jdouble)kern.y/64.0;
-
- cls = (*env)->FindClass (env, "java/awt/geom/Point2D$Double");
- method = (*env)->GetMethodID (env, cls, "<init>", "(DD)V");
- return (*env)->NewObjectA(env, cls, method, values);
+ jfloat *pelements = (*env)->GetPrimitiveArrayCritical(env, p, NULL);
+ pelements[0] = (jfloat)kern.x/64.0;
+ pelements[1] = (jfloat)kern.y/64.0;
+ (*env)->ReleasePrimitiveArrayCritical (env, p, pelements, 0);
}
JNIEXPORT jdoubleArray JNICALL
Index: classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===================================================================
--- classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java (revision 141430)
+++ classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java (working copy)
@@ -247,7 +247,7 @@
/**
* Returns the kerning of a glyph pair
*/
- private native Point2D getKerning(int leftGlyph, int rightGlyph, long font);
+ private native void getKerning(int leftGlyph, int rightGlyph, long font, float[] p);
private native double[] getMetricsNative(int glyphCode, long font);
@@ -301,6 +301,7 @@
GlyphMetrics gm = null;
float x = 0;
float y = 0;
+ float[] p = {0.0f, 0.0f};
for(int i = 0; i < nGlyphs; i++)
{
gm = getGlyphMetrics( i );
@@ -314,9 +315,9 @@
// using the same font
if (i != nGlyphs-1 && fontSet[i] == fontSet[i+1])
{
- Point2D p = getKerning(glyphCodes[i], glyphCodes[i + 1], fontSet[i]);
- x += p.getX();
- y += p.getY();
+ getKerning(glyphCodes[i], glyphCodes[i + 1], fontSet[i], p);
+ x += p[0];
+ y += p[1];
}
}
glyphPositions[nGlyphs * 2] = x;
next prev parent reply other threads:[~2008-11-03 14:53 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-03 12:51 ffileppo
2008-11-03 14:53 ` Andrew Haley [this message]
2008-11-03 15:04 ` Andrew Haley
-- strict thread matches above, loose matches on Subject: below --
2008-11-10 8:55 ffileppo
2008-11-10 10:20 ` Andrew Haley
2008-11-07 11:04 ffileppo
2008-11-07 11:18 ` Andrew Haley
2008-11-07 18:56 ` Andrew Haley
2008-11-08 11:40 ` Andrew Haley
2008-11-08 12:47 ` Andrew Haley
2008-11-09 0:25 ` Andrew John Hughes
2008-11-09 10:11 ` Mark Wielaard
2008-11-09 13:55 ` Andrew Haley
2008-11-06 13:40 ffileppo
2008-11-06 16:40 ` Andrew Haley
2008-11-06 17:02 ` Christian Thalinger
2008-11-05 13:53 ffileppo
2008-11-05 14:07 ` Andrew Haley
2008-11-05 14:26 ` Andrew Haley
2008-11-05 8:24 ffileppo
2008-11-05 9:44 ` Andrew Haley
2008-11-05 9:45 ` Mark Wielaard
2008-11-05 9:50 ` Andrew Haley
2008-11-03 7:38 ffileppo
2008-11-03 10:37 ` Andrew Haley
2008-11-03 12:02 ` Andrew Haley
2008-11-03 12:54 ` Andrew Haley
2008-11-03 13:02 ` Roman Kennke
2008-11-03 13:14 ` Andrew Haley
2008-11-03 15:46 ` Andrew Haley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=490F101C.7030606@redhat.com \
--to=aph@redhat.com \
--cc=classpath@gnu.org \
--cc=ffileppo@libero.it \
--cc=java@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).