Page 1 of 3 123 LastLast
Results 1 to 10 of 29

Thread: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

  1. #1
    Join Date
    Apr 2009
    Beans
    5

    Post HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    Introduction
    I recently moved from Vista to Ubuntu. And everything went really smooth. Way better than
    expected. But one thing really disturbed me:
    many of the bigger Java apps (Vuze, for example) seem to have really slow and
    unresponsive user interfaces. Trivial things like scrolling down a list of files contained
    within a torrent become a real ordeal. So I searched around the Web and found advices
    like "downgrade from Java 6 to Java 5", etc... but they did not make any difference
    at all.

    So I googled... and googled... and googled... and finally found this:
    http://java.sun.com/j2se/1.5.0/docs/...tures.html#ogl

    Among other things this link tells you, that there's a command line switch
    (-Dsun.java2d.opengl=true), that you can use to turn on OpenGL-acceleration for
    your Java programs... So I tried it out on Vuze... and was totally surprised to
    see how its GUI performance skyrocketed through the roof. So I decided to
    create this tutorial to share my new nerd trick

    I'm going to explain the steps in general and then I'm going to show two real
    world examples and tell you how to speed up Vuze and SmartSVN (chosen because
    they're two Java based apps which I use daily).


    Requirements
    1) An installed and enabled OpenGL-driver for your graphics card

    (https://help.ubuntu.com/community/BinaryDriverHowto) Note to Nvidia-Users:
    Don't use driver version 177 anymore; it's got serious 2D performance issues.

    2) Sun Java version 5 or higher

    (https://help.ubuntu.com/community/Java)

    3) A Java application with a sluggish user interface

    4) Ability to unterstand a bit of shell scripts...

    ... uhm... well that's a "bit" tricky... because in order to find the right place
    to put the command line switch into, you've got to understand a bit of shell scripts.
    Explaining this would be totally out of the scope of this tutorial. If you have a
    programming background it's a nobrainer. But if you are not able to read shell
    scripts, I suggest you either ask someone who is able and let him or her find the
    right spot, or... if you're the adventurous type... feel free to dive right into a tutorial
    about shell scripting For Example: http://steve-parker.org/sh/sh.shtml or
    http://tldp.org/LDP/abs/html/index.html


    General Steps
    It seems that Java apps are launched via shell scripts most of the time.
    These shell scripts typically set up command line options (among other things)
    for the application and finally start java with the command line options and the
    path of your application. So this is what you've got to do:

    Step 1)
    You've got to find the script that launches your particular application;
    examine the properties of your programs shortcut to get the path.

    Step 2)
    Open the launchscript in your favourite texteditor

    Step 3)
    Find the right place to add the command line switch, paste it there and save the file.

    Step 4)
    Launch your application and enjoy a snappy userinterface

    Example: Vuze
    Without OpenGL accelleration Vuze was extremely sluggish. But after I set the OpenGL
    switch, I even ditched uTorrent (running on Wine) because Vuze is so responsive now
    that I can really enjoy its powerful features.

    I'm using Vuze 4.2.0.2. I downloaded the Linux package from their homepage, unzipped
    it to /opt/vuze and made a shortcut on my desktop.

    Step 1)
    Rightclick the shortcut, open its properties and find out where the corresponding
    shell script is. In my case it's /opt/vuze/vuze.

    Step 2)
    Open the script in an editor. Let's assume your editor is gedit: Push ALT+F2,
    type "gedit /opt/vuze/vuze" (without the quotes) and confirm by pushing enter.

    Step 3)
    You examine the script and find this at its end
    Code:
    ${JAVA_PROGRAM_DIR}java "${JAVA_ARGS}" \
    	-cp "${CLASSPATH}" \
    	-Djava.library.path="${PROGRAM_DIR}" \
    	-Dazureus.install.path="${PROGRAM_DIR}" \
    	-Dazureus.script="$0" \
    	$JAVA_PROPS \
    	$START_CLASS "$@"
    Now you change the code to
    Code:
    ${JAVA_PROGRAM_DIR}java "${JAVA_ARGS}" \
    	-cp "${CLASSPATH}" \
    	-Djava.library.path="${PROGRAM_DIR}" \
    	-Dsun.java2d.opengl=true \
    	-Dazureus.install.path="${PROGRAM_DIR}" \
    	-Dazureus.script="$0" \
    	$JAVA_PROPS \
    	$START_CLASS "$@"
    and save the file.

    4) You run Vuze and are amazed, because it's really really fast

    Example: SmartSVN
    Another application I managed to get on speed is SmartSVN. It had really frustrating
    slowdowns, especially when scrolling through the source of compared files. But thanks
    to the OpenGL switch this is a story from the past

    I'm using version 5.0.5 and installed it into /opt.

    Step 1)
    Examine the shortcut, view its properties and find the shell script. In my case
    it's /opt/smartsvn/bin/smartsvn.sh.

    Step 2)
    Open the script. Let's again assume, that your editor is gedit.Just push ALT+F2
    and then type "gedit /opt/smartsvn/bin/smartsvn.sh" (without the doublequotes)
    and hit enter to confirm.

    Step 3)
    You need to change this line at the end of the file
    Code:
    $_JAVA_EXEC -classpath "$_CP" $_VM_PROPERTIES -Xmx${MAXIMUM_HEAP_SIZE} -Dsmartsvn.vm-xmx=${MAXIMUM_HEAP_SIZE} SmartSVN "$@"
    into this
    Code:
    $_JAVA_EXEC -classpath "$_CP" $_VM_PROPERTIES -Dsun.java2d.opengl=true -Xmx${MAXIMUM_HEAP_SIZE} -Dsmartsvn.vm-xmx=${MAXIMUM_HEAP_SIZE} SmartSVN "$@"
    and save the shell script.

    4.) Run SmartSVN and feel free to scroll up and down and compare files as much as you like

    The End
    Thats it. I hope you enjoyed my tutorial. Feel free to offer constructive criticism

  2. #2
    Join Date
    Oct 2004
    Location
    Barcelona, Spain
    Beans
    191
    Distro
    Ubuntu Development Release

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    This sounds very interesting.

    You mean one of the reasons why java IDEs like Netbeans and Eclipse run significantly slow is because they're not using OpenGL?
    Do you think this would speed them up?
    -------------------------------------
    Ubuntu in Spanish is Ubuñtu!
    Running Aspire 9814 AMD64 & Extensa 5620

  3. #3
    Join Date
    Apr 2009
    Beans
    5

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    Quote Originally Posted by Nano View Post
    This sounds very interesting.

    You mean one of the reasons why java IDEs like Netbeans and Eclipse run significantly slow is because they're not using OpenGL?
    Do you think this would speed them up?
    I have not tested it with Eclipse yet, but someone who read my tutorial pointed
    me to this page of the Netbeans documentation: http://performance.netbeans.org/howt...hes/index.html.
    Under "Options affecting graphic behavior" it mentiones the same openGL command
    line switch (and some other switches I didn't know about) to speed up their IDE.
    So you can definitely speed up Netbeans with this switch.

  4. #4
    Join Date
    Apr 2007
    Location
    BiH
    Beans
    Hidden!
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    It would be nice to have openGL for java enabled generally, so one doesn't have to tinker with particular apps. However, thanks a lot for these infos, Patrick
    ...

  5. #5
    Join Date
    Aug 2008
    Beans
    302
    Distro
    Kubuntu 11.10 Oneiric Ocelot

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    Yeah meho_r is right. Is there any way to enable opengl for all Java applications ? And what about Flash applications ? Do Pidgin and openoffice also use java ?

  6. #6
    Join Date
    Apr 2009
    Beans
    5

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    Quote Originally Posted by meho_r View Post
    It would be nice to have openGL for java enabled generally, so one doesn't have to tinker with particular apps. However, thanks a lot for these infos, Patrick
    Yes, that would be nice. The only thing I found in this direction is
    the file /etc/java-6-sun/jvm.cfg. I found out that it contains the
    default properties of the Java Virtual Machine. But adding the command
    line switch there did not make any differences...

  7. #7
    Join Date
    Oct 2004
    Location
    Barcelona, Spain
    Beans
    191
    Distro
    Ubuntu Development Release

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    Quote Originally Posted by Patrick Metz View Post
    I have not tested it with Eclipse yet, but someone who read my tutorial pointed
    me to this page of the Netbeans documentation: http://performance.netbeans.org/howt...hes/index.html.
    Under "Options affecting graphic behavior" it mentiones the same openGL command
    line switch (and some other switches I didn't know about) to speed up their IDE.
    So you can definitely speed up Netbeans with this switch.
    Thanks, mate, for your answer.
    I'll definitely try this out and let you know the results.

    Cheers!
    -------------------------------------
    Ubuntu in Spanish is Ubuñtu!
    Running Aspire 9814 AMD64 & Extensa 5620

  8. #8
    Join Date
    Oct 2004
    Location
    Barcelona, Spain
    Beans
    191
    Distro
    Ubuntu Development Release

    Apply performance OpenGL switch to Netbeans 6.5

    I have tried the tuning switch described above and I, indeed, experienced some performance improvements using Netbeans 6.5 with php plugins.

    In order to do this you have to edit the file

    "yourNetbeansInstallPath/etc/netbeans.conf"

    As described in the link posted by Patrick Metz, you have to edit the 6th line and add there your switches.
    Mine now looks like this:
    Code:
    netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -Dsun.java2d.opengl=true -Dsun.java2d.d3d=false"
    (I added the last two switches to the string.)

    After that just save the file and start again Netbeans from your regular launch script.


    Thanks for the tips, Patrick
    -------------------------------------
    Ubuntu in Spanish is Ubuñtu!
    Running Aspire 9814 AMD64 & Extensa 5620

  9. #9
    Join Date
    Jan 2006
    Beans
    1,237
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    as far as I see this is only valid for java 2d: http://java.sun.com/docs/books/tutorial/2d/index.html

    I don't see how it affects GUI resposiveness. Are you sure it's not a placebo effect

  10. #10
    Join Date
    Oct 2004
    Location
    Barcelona, Spain
    Beans
    191
    Distro
    Ubuntu Development Release

    Re: HowTo: extremely speed up slow Java apps by enabling them to use OpenGL

    Quote Originally Posted by cb951303 View Post
    as far as I see this is only valid for java 2d: http://java.sun.com/docs/books/tutorial/2d/index.html

    I don't see how it affects GUI resposiveness. Are you sure it's not a placebo effect
    Considering what coffee makes to me, this could also be a placebo effect, indeed. However, I'd swear there's a change
    It's also reported on Netbeans page under http://performance.netbeans.org/howt...hes/index.html
    -------------------------------------
    Ubuntu in Spanish is Ubuñtu!
    Running Aspire 9814 AMD64 & Extensa 5620

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •