Bug 176150 - [OpenGL] org.eclipse.swt.opengl.*'s performance is poor on Windows platform
Summary: [OpenGL] org.eclipse.swt.opengl.*'s performance is poor on Windows platform
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows Server 2003
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Billy Biggs CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-02 04:05 EST by supertat CLA
Modified: 2019-09-06 15:36 EDT (History)
7 users (show)

See Also:


Attachments
test program by LWJGL (5.42 KB, text/plain)
2007-03-02 04:07 EST, supertat CLA
no flags Details
test program by JOGL (5.58 KB, text/plain)
2007-03-02 04:08 EST, supertat CLA
no flags Details
test program by JOGL (5.40 KB, text/plain)
2007-03-02 04:09 EST, supertat CLA
no flags Details
test program with GLUT for Windows VC++ (3.01 KB, text/plain)
2007-03-06 00:52 EST, supertat CLA
no flags Details
test program with GLUT for Linux (3.26 KB, text/plain)
2007-03-06 00:52 EST, supertat CLA
no flags Details
test program with JOGL (5.56 KB, text/plain)
2007-03-06 00:53 EST, supertat CLA
no flags Details
test program with LWJGL (5.58 KB, text/plain)
2007-03-06 00:53 EST, supertat CLA
no flags Details
test program with org.eclipse.opengl (4.82 KB, text/plain)
2007-03-11 20:32 EDT, supertat CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description supertat CLA 2007-03-02 04:05:05 EST
Build ID: M20070212-1330

Steps To Reproduce:
1.
Set up environment for SWT, JOGL, LWJGL.
2.
Run the attached 2 programs (Snippet195.java(for JOGL) and Snippet209.java(for LWJGL) on Windows and Linux.
Their performance(frames per second) will be displayed as output, and you will find it's very slow on Windows platform.

More information:
At my site, both programs show approximately 60 FPS on Windows, 2,400 FPS on Linux.
I used a dual-boot PC, that means the same hardware (NVIDIA Quadro FX 3450) is used for Windows and Linux. 
Graphic Driver is enabled for both.
I tried SWT 3.2.2 and 3.3M5.
Comment 1 supertat CLA 2007-03-02 04:07:10 EST
Created attachment 60136 [details]
test program by LWJGL
Comment 2 supertat CLA 2007-03-02 04:08:27 EST
Created attachment 60137 [details]
test program by JOGL
Comment 3 supertat CLA 2007-03-02 04:09:10 EST
Created attachment 60138 [details]
test program by JOGL
Comment 4 Steve Northover CLA 2007-03-02 19:49:14 EST
SWT provides a thin glue between an open GL libraries (such as LWJGL and JOGL) and the operating system.  Therefore, OpenGL should be running at native speed because we don't do anything.  If this is not true, we need to fix it.

Grant, can you please recreate the problem and take a quick look at it with Silenio to make sure we are not getting in the way?
Comment 5 supertat CLA 2007-03-02 22:30:17 EST
(In reply to comment #4)
> Grant, can you please recreate the problem and take a quick look at it with
> Silenio to make sure we are not getting in the way?

Sorry, I cannot understand what I should do for you.
Could you explain more in detail ?
Comment 6 supertat CLA 2007-03-02 22:33:23 EST
Now I understand you are asking Grant (^^)
Please ignore my latest comment.
Comment 7 Steve Northover CLA 2007-03-03 00:04:06 EST
Can you confirm that the performance of a C program that makes the same OpenGL calls is faster than the equivalent SWT one?
Comment 8 supertat CLA 2007-03-06 00:52:06 EST
Created attachment 60302 [details]
test program with GLUT for Windows VC++

test program with GLUT for Windows VC++
Comment 9 supertat CLA 2007-03-06 00:52:57 EST
Created attachment 60303 [details]
test program with GLUT for Linux

test program with GLUT for Linux
Comment 10 supertat CLA 2007-03-06 00:53:24 EST
Created attachment 60304 [details]
test program with JOGL

test program with JOGL
Comment 11 supertat CLA 2007-03-06 00:53:50 EST
Created attachment 60305 [details]
test program with LWJGL

test program with LWJGL
Comment 12 supertat CLA 2007-03-06 00:55:05 EST
(Please ignore my previous benchmark result.
 I unchecked "Vertical Sync" at the graphic driver's settings,
 and now I can overcome 60 FPS.)

My new benchmark result is as follows (unit is FPS):
----------------------+---------+---------
                      | Windows | Linux
-------+--------------+---------+---------
C++    | GLUT         |    2700 |  3200
Java   | SWT + JOGL   |    1400 |  2400
Java   | SWT + LWJGL  |    1400 |  2400
-------+--------------+---------+---------
I attached following 4 files used in the above benchmark.
- glut_windows.cc: with GLUT for Windows VC++
- glut_linux.cc:   with GLUT for Linux
- SWT_JOGL.java :  with JOGL
- SWT_LWJGL:       with LWJGL
Could you reduce the difference between C++ and Java for both platforms ?
Comment 13 Steve Northover CLA 2007-03-06 10:00:41 EST
How does this compares with the experimental SWT OpenGL bindings?  (See http://www.eclipse.org/swt/opengl/)  For the purposes of comparison, could you recode your example to use that?
Comment 14 supertat CLA 2007-03-06 15:14:59 EST
OK. I will recode next week.

Comment 15 supertat CLA 2007-03-11 20:32:08 EDT
Created attachment 60522 [details]
test program with org.eclipse.opengl
Comment 16 supertat CLA 2007-03-11 20:38:47 EDT
I tried org.eclipse.opengl and here is the result.
----------------------------------+---------+---------
                                  | Windows | Linux
-------+--------------------------+---------+---------
C++    | GLUT                     |    2700 |  3200
Java   | SWT + JOGL               |    1400 |  2400
Java   | SWT + LWJGL              |    1400 |  2400
Java   | SWT + org.eclipse.opengl |    1400 |     ?
-------+--------------------------+---------+---------
I could not try org.eclipse.opengl on Linux since I use x86_64 and could not find 64-bit version of libgl-0500.so.
Comment 17 Steve Northover CLA 2007-03-12 23:28:57 EDT
Felipe, want to have a quick look at this mystery?  Could it be the JNI overhead in Java vs C++?
Comment 18 Steve Northover CLA 2007-04-18 01:57:09 EDT
Was part of the problem on Windows caused by the just fixed bug 182810?
Comment 19 Jeff Norris CLA 2007-04-18 17:51:50 EDT
Looking at the source code for the test programs I think it is quite possible that the recent fix to bug #182810 will narrow the gap between Windows and Linux that is reported in this bug.  

Both the LWJGL and JOGL test programs attached to this bug call canvas.setCurrent() in handleEvent.  In a single context scenario like these test programs, setCurrent() tries to early-out when it detects that the call to setCurrent() was not necessary.  However, (as reported in bug #182810) this detection was not working on Windows, forcing every call to setCurrent() to perform the time-consuming portions of that method.

supertat, it would be great if you could grab the build that contains the fix reported in #182810 (20070418), run your test programs again on the same machines, and report the results here.  We suspect there may be other sources of slowness on the Windows platform but it would be great to see how close the fix to 182810 gets us.

Comment 20 supertat CLA 2007-04-18 20:35:30 EDT
Jeff,
I haven't tried the build yet, but as you suggested in bug #182810, I tried commenting out "canvas.setCurrent();" at display.asyncExec() and confirmed performance on Windows has improved from 1400 to 1800 FPS.
On Linux, no effect.
----------------------------------+---------+---------
                                  | Windows | Linux
-------+--------------------------+---------+---------
C++    | GLUT                     |    2700 |  3200
Java   | SWT + JOGL               |    1800 |  2400
Java   | SWT + LWJGL              |    1800 |  2400
Java   | SWT + org.eclipse.opengl |    1800 |     ?
-------+--------------------------+---------+---------
Comment 21 Steve Northover CLA 2007-05-23 19:59:17 EDT
Java is still slower than C for no good reason.  Could the glutIdle() function run more often than asyncExec()?  Can someone test this hypothesis?
Comment 22 Jeff Norris CLA 2007-05-23 22:28:10 EDT
There's definitely a big difference between the way that the Java examples and the C examples are painting their FPS.  One idea would be to just move the fps printing into the display function in the C++ program and see if that changes anything. 
Comment 23 Steve Northover CLA 2007-05-24 09:51:06 EDT
What??  I really didn't look at the test code.  Are you telling me that the OpenGL code is not line for line the same in the C and Java?  If this is the case, then the comparison might be quite bogus.

Jeff, want to investigate?  It's the end game of Eclipse 3.3 and I don't have any time to look into it.  If we are in fact slower that C code for some reason, I want to know.  Please use the experimental SWT OpenGL support in org.eclipse.opengl.  It's not great, but I know that all that binding does it make OpenGL calls directly to C.  It can't get faster.
Comment 24 Eclipse Webmaster CLA 2019-09-06 15:36:26 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.