public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [GCJ] Performance of GUI applications on embedded systems
@ 2008-11-05 13:53 ffileppo
  2008-11-05 14:07 ` Andrew Haley
  0 siblings, 1 reply; 30+ messages in thread
From: ffileppo @ 2008-11-05 13:53 UTC (permalink / raw)
  To: aph; +Cc: mark, java, classpath


> Mark Wielaard wrote:
> > On Wed, 2008-11-05 at 09:24 +0100, ffileppo wrote:
> >> I tried your improvement but now I'm getting Segmentation Fault whenever I execute any GUI application.
> >> (Non-gui code is working fine)
> >>
> >> Do you have any idea to investigate this problem?
> >
> > Run it under GDB and post a backtrace please.
>
> For what it's worth, I very much suspect that this will be a build
> problem.  ffileppo, we also need to know what configure options you
> used.
>
> Andrew.
>


Hi,

I tried rebuilding gcj (with Andrew's improvement) on a clean system
but I'm still getting Segmentation Fault when I run GUI applications on my embedded system.

Here is configure :

Configured with: ../configure --prefix=/root/WiTP/inst-gcc --with-sysroot=/root/WiTP/f8/rootfs-f8 --disable-libssp --disable-libgomp --disable-libmudflap --enable-libgcj --disable-bootstrap --disable-multilib --disable-sjlj-exceptions --target=arm-linux-gnueabi --enable-languages=c,c++,java --with-build-time-tools=/root/WiTP/binutils-inst/arm-linux-gnueabi/bin --with-ld=/root/WiTP/binutils-inst/arm-linux-gnueabi/bin/ld --with-nm=/root/WiTP/binutils-inst/arm-linux-gnueabi/bin/nm --with-strip=/root/WiTP/binutils-inst/arm-linux-gnueabi/bin/strip --with-as=/root/WiTP/binutils-inst/arm-linux-gnueabi/bin/as --with-float=soft --enable-java-awt=gtk --x-libraries=/root/WiTP/arm-rpm/usr/lib


And here is GDB backtrace

#0  0x40b92d14 in java::lang::Object::getClass () from /lib/libgcj.so.10
#1  0x40b116f0 in javax::swing::JComponent::isPaintRoot () from /lib/libgcj.so.10
#2  0x42f9b114 in Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning (env=0x24320, obj=<value optimized out>, rightGlyph=40,
    leftGlyph=79, fnt=<value optimized out>, p=0x0)
    at ../../../../../../../libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c:204
#3  0x41381c30 in gnu::java::awt::peer::gtk::FreetypeGlyphVector::getKerning () from /lib/libgcj.so.10
#4  0x41383f4c in gnu::java::awt::peer::gtk::FreetypeGlyphVector::performDefaultLayout () from /lib/libgcj.so.10
#5  0x4137022c in gnu::java::awt::peer::gtk::FreetypeGlyphVector::FreetypeGlyphVector () from /lib/libgcj.so.10
#6  0x41368ac4 in gnu::java::awt::peer::gtk::GdkFontPeer::layoutGlyphVector () from /lib/libgcj.so.10
#7  0x40e977c0 in java::awt::Font::layoutGlyphVector () from /lib/libgcj.so.10
#8  0x40ef0d10 in java::awt::font::TextLayout::TextLayout () from /lib/libgcj.so.10
#9  0x41358b24 in gnu::java::awt::peer::gtk::GdkFontPeer$GdkFontMetrics::stringWidth () from /lib/libgcj.so.10
#10 0x41150c38 in javax::swing::JComponent::isPaintRoot () from /lib/libgcj.so.10
#11 0x41151704 in javax::swing::SwingUtilities::layoutCompoundLabel () from /lib/libgcj.so.10
#12 0x411c7ec0 in javax::swing::plaf::basic::BasicLabelUI::layoutCL () from /lib/libgcj.so.10
#13 0x411d2500 in javax::swing::plaf::basic::BasicLabelUI::getPreferredSize () from /lib/libgcj.so.10
#14 0x4111f6f0 in javax::swing::JComponent::getPreferredSize () from /lib/libgcj.so.10
#15 0x411bbfdc in javax::swing::plaf::basic::BasicListUI::updateLayoutState () from /lib/libgcj.so.10
#16 0x411944ec in javax::swing::plaf::basic::BasicListUI::maybeUpdateLayoutState () from /lib/libgcj.so.10
#17 0x4119c52c in javax::swing::plaf::basic::BasicListUI::installUI () from /lib/libgcj.so.10
#18 0x4111e778 in javax::swing::JComponent::setUI () from /lib/libgcj.so.10
#19 0x4111e8c0 in javax::swing::JList::setUI () from /lib/libgcj.so.10
#20 0x41143d48 in javax::swing::JList::updateUI () from /lib/libgcj.so.10
#21 0x4116f1bc in javax::swing::JList::init () from /lib/libgcj.so.10
#22 0x4116f230 in javax::swing::JList::JList () from /lib/libgcj.so.10
#23 0x00012d88 in MainPanel::MainPanel ()
#24 0x00012f80 in MainPanel::main ()
#25 0x40b7be60 in gnu::java::lang::MainThread::call_main () from /lib/libgcj.so.10
#26 0x40bfe85c in gnu::java::lang::MainThread::run () from /lib/libgcj.so.10
#27 0x40b99648 in _Jv_ThreadRun () from /lib/libgcj.so.10
#28 0x40b0d588 in _Jv_RunMain () from /lib/libgcj.so.10
#29 0x40b0d720 in _Jv_RunMain () from /lib/libgcj.so.10
#30 0x40b0d75c in JvRunMain () from /lib/libgcj.so.10
#31 0x424b5db8 in __libc_start_main () from /lib/libc.so.6
#32 0x0001255c in _start ()



I'll try to revert Andrew's patch to be sure that's the cause of segmentation fault.


Thank you,

Francesco



^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: [GCJ] Performance of GUI applications on embedded systems
@ 2008-11-10  8:55 ffileppo
  2008-11-10 10:20 ` Andrew Haley
  0 siblings, 1 reply; 30+ messages in thread
From: ffileppo @ 2008-11-10  8:55 UTC (permalink / raw)
  To: aph; +Cc: java, classpath


> >>>
> >> You're right.
> >> However I'm experiencing slowness when testing some other GUI sample application (e.g. the test case attached at the end).
> >>
> >> In this particular test case, the application takes a lot of time to startup (compared to the same device, running WinCE and CrEme JVM) and during start up the CPU usage is always at 100%.
> >>
> >> After startup, I'v also noticed that highlighting and/or clicking a certain number of times on buttons cause the application to hang and after that the CPU usage is always 100%.
> >
> > I've identified some serious GTK locking problems with this version of gcj.
> >
> > I'm investigating.
>
> Found a very silly (:-) merge error in CairoGraphics2D.c.
> This fixes it.
>
> I don't think there should be any differences between the GTK peers
> in Classpath and gcj, should there?  Or indeed, and differences between
> the CNI code in Classpath and gcj.
>
> Andrew.
>
>
> Index: gnu_java_awt_peer_gtk_CairoGraphics2D.c
> ===================================================================
> --- gnu_java_awt_peer_gtk_CairoGraphics2D.c	(revision 141575)
> +++ gnu_java_awt_peer_gtk_CairoGraphics2D.c	(working copy)
> @@ -351,7 +351,6 @@
>    for (i = 0; i < n; i++)
>      {
>        PangoFcFont *font = JLONG_TO_PTR(PangoFcFont, fonts[i]);
> -  gdk_threads_leave ();
>
>        /* Draw as many glyphs as possible with the current font */
>        int length = 0;
>
>

Hi Andrew,

I can see that with your patch the application now doesn't
hang anymore when highlighting and/or clicking on buttons.
GUI performance of applications on my embbeded
system seems also to be quite better now.

I wonder if there's still some place for UI performance
improvement.

Thank you,

Francesco


^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: [GCJ] Performance of GUI applications on embedded systems
@ 2008-11-07 11:04 ffileppo
  2008-11-07 11:18 ` Andrew Haley
  2008-11-07 18:56 ` Andrew Haley
  0 siblings, 2 replies; 30+ messages in thread
From: ffileppo @ 2008-11-07 11:04 UTC (permalink / raw)
  To: aph; +Cc: java, classpath

> >> 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.
>
> > I'm testing your patch on my embedded system and now I can see that GUI performance are very much better (particularly during application startup).
> >
> > Thank you so much!
> >
> > However running my test case (please see my first post) I see that CPU usage is always at 100% (after the application is running),
> > so the responsiveness is still not very good.
>
> What do you expect?  You're setting up a Timer with a delay of
> 0 milliseconds between events, and it's running continuously.
>
> Andrew.
>

You're right.
However I'm experiencing slowness when testing some other GUI sample application (e.g. the test case attached at the end).

In this particular test case, the application takes a lot of time to startup (compared to the same device, running WinCE and CrEme JVM) and during start up the CPU usage is always at 100%.

After startup, I'v also noticed that highlighting and/or clicking a certain number of times on buttons cause the application to hang and after that the CPU usage is always 100%.

I'm still trying to get oprofile working on my target device to see what's going wrong.

Thank you,
Francesco

Test case:

import javax.swing.JComponent;
import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class GUITest {

  public static void main(String[] args) {

  JFrame frame = new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  JComponent newContentPane = new TestUI();
  frame.setTitle("TestUI");
  newContentPane.setOpaque(true);
  frame.setContentPane(newContentPane);
  frame.setBounds(10, 10, 500, 400);
  frame.setVisible(true);

  }

  static class TestUI extends JPanel {

  long startTime;
  JPanel createPanel(int start) {
  JPanel p = new JPanel();
  p.setLayout(null);

  for (int i=0; i<100; i++) {
      JButton ltit = new JButton("Variable "+(i+start)+": ");
      long val = System.currentTimeMillis() - startTime;
      JButton lval = new JButton(""+val);
      ltit.setBounds(5, 10+20*i, 150, 15);
      lval.setBounds(200, 10+20*i, 150, 15);
      p.add(ltit);
      p.add(lval);
  }
  return p;
  }

  TestUI() {
  super(new BorderLayout());
  startTime = System.currentTimeMillis();
  JTabbedPane p = new JTabbedPane();

  for (int i=0; i<10; i++) {
     JPanel page1 = createPanel(i*100+1);
     p.add("P"+i, page1);
  }

  add(p, BorderLayout.CENTER);
  }
  }

}

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: [GCJ] Performance of GUI applications on embedded systems
@ 2008-11-06 13:40 ffileppo
  2008-11-06 16:40 ` Andrew Haley
  0 siblings, 1 reply; 30+ messages in thread
From: ffileppo @ 2008-11-06 13:40 UTC (permalink / raw)
  To: aph; +Cc: java, classpath

> 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.
>


Hi Andrew,

I'm testing your patch on my embedded system and now I can see that GUI performance are very much better (particularly during application startup).

Thank you so much!

However running my test case (please see my first post) I see that CPU usage is always at 100% (after the application is running),
so the responsiveness is still not very good.

Do you think that there is still some places for improvement?
I'll try to use oprofile on my embedded system to see what's going wrong

Best Regards,

Francesco

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: [GCJ] Performance of GUI applications on embedded systems
@ 2008-11-05  8:24 ffileppo
  2008-11-05  9:44 ` Andrew Haley
  2008-11-05  9:45 ` Mark Wielaard
  0 siblings, 2 replies; 30+ messages in thread
From: ffileppo @ 2008-11-05  8:24 UTC (permalink / raw)
  To: aph; +Cc: java, classpath

> 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.
>
>


Hi Andrew,

I tried your improvement but now I'm getting Segmentation Fault whenever I execute any GUI application.
(Non-gui code is working fine)

Do you have any idea to investigate this problem?

Thank you,

Francesco


^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: [GCJ] Performance of GUI applications on embedded systems
@ 2008-11-03 12:51 ffileppo
  2008-11-03 14:53 ` Andrew Haley
  0 siblings, 1 reply; 30+ messages in thread
From: ffileppo @ 2008-11-03 12:51 UTC (permalink / raw)
  To: aph; +Cc: java, classpath

> > 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.
>
> Andrew.
>
>

Hi Andrew,
thanks a lot for your help.

Do you have any ideas to fix this problem?

Thank you,

Francesco

^ permalink raw reply	[flat|nested] 30+ messages in thread
* [GCJ] Performance of GUI applications on embedded systems
@ 2008-11-03  7:38 ffileppo
  2008-11-03 10:37 ` Andrew Haley
  0 siblings, 1 reply; 30+ messages in thread
From: ffileppo @ 2008-11-03  7:38 UTC (permalink / raw)
  To: java, classpath

Hi all,

I've been investigating about performance of java code compiled with gcj on embedded systems.
In particular I'm interested in testing AWT/SWING application using GTK/Xorg as graphical backend
(this is the only viable solution since QT peers are not well supported).

The embedded device I've been using for testing is a PXA270 processor (armv5te) equipped with 128Mb Ram;
running linux kernel 2.6.24 and using libgcj.so.10. GTK peers are running on Xorg, using matchbox
as window manager. The crosscompiler on my host is gcc 4.4.

During my tests I've noticed that java code using AWT/SWING (for example the test case attached at the end)
with GTK peer cause a very high load on the cpu.
Furthermore the applications take a lot of time to load and also the UI responsiveness is very slow.
Using "top" I can see that CPU is always at 100% during start up (it takes about 2 minutes
to get the application starting, Ram usage is ok).

I've also noticed that using optimizations (-O2, -O3...) does not help with graphical performance.

[On the same device, running WinCE and a commerical JVM (CrEme), applications have extremely better
graphical performance]

From my experience with this particual embedded system I can say that gcj has very high performance
when dealing with non-gui tasks (e.g. array sorting) compared with most of JVMs but gui
performance are very poor.

I would like to ask your opinion about the slowness of gui applications in my setup,
and also about viable solutions to improve this issue.
What do you think is the bottleneck?

-- libgcj itself?
-- GTK library / GTK peer implementation in classpath?
-- something dealing with Xorg?

Your feedback and ideas will be very appreciated.


Thank you,
Francesco


Test case:

import java.awt.BorderLayout;
import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.Timer;
import java.awt.event.*;


public class MainPanel extends JPanel implements ListSelectionListener {

  static final int NUM_ROWS = 500;

  JList list;
  JLabel lblSelection;
  DefaultListModel listModel;

  int startRow = 0;
  long startTime = 0;


javax.swing.Timer t = new javax.swing.Timer(0, new ActionListener() {
     public void actionPerformed(ActionEvent e) {
     long deltaTime = System.currentTimeMillis() - startTime;
     for (int i=startRow; i<NUM_ROWS; i++) {
     	listModel.set(i, ""+deltaTime);
     }

     startRow++;
     startTime = System.currentTimeMillis();

     }
});

public MainPanel() {
    super(new BorderLayout());

    listModel = new DefaultListModel();

    for (int i=0; i<NUM_ROWS; i++) {
    	listModel.addElement("Element "+i);
    }

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);

    JScrollPane listScrollPane = new JScrollPane(list);
    lblSelection = new JLabel(" ");
    add(lblSelection, BorderLayout.SOUTH);
    add(listScrollPane, BorderLayout.CENTER);
    t.start();
    startTime = System.currentTimeMillis();

}

public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {
      if (list.getSelectedIndex() == -1) {
        lblSelection.setText("");
      } else {
        lblSelection.setText("Item selected: "+list.getSelectedIndex());
      }
    }
}

public static void main(String[] args) {
    JFrame frame = new JFrame("TestUI #1");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JComponent newContentPane = new MainPanel();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    frame.setBounds(10, 10, 500, 400);
    frame.setVisible(true);
  }
}


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2008-11-10 10:20 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-05 13:53 [GCJ] Performance of GUI applications on embedded systems ffileppo
2008-11-05 14:07 ` Andrew Haley
2008-11-05 14:26   ` 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  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 12:51 ffileppo
2008-11-03 14:53 ` Andrew Haley
2008-11-03 15:04   ` 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

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).