Why 4x better FPS when NetBeans is Running?

I am running 1.4.2_01 on XP

When I start the game I am working on via webstart
http://freerails.sourceforge.net/jfreerails.jnlp
I get ~25FPS.

However, if I start NetBeans, then click on the webstart link I get ~100FPS.

If I then close NetBeans, and click on the webstart link, I get ~25FPS again.

Also, when I start two instances of the game, then minimize the one I started first, the second instance has ~100FPS while if I minimize the second, the first instance still has ~25FPS.

Using 1.4.0_04 and 1.4.1_01 JREs, the problem does not occur, i.e. I always get ~100FPS

Any ideas?

Luke

See if you can profile it when it runs at ~25 and again when it is running at ~100.

And maybe file a bug report anyway… just in case.

[quote]I am running 1.4.2_01 on XP
[/quote]
Try the latest JVM, not an old one. (1.4.2_04). Yes, it does have bugfixes in!

In general, if something works differently with 1.4.0_xxx then it’s a bug in the older jvm. 1.4.0 was very buggy in some parts.

Profiling 1.4.2_01 while I wait for 1.4.2_04 to download…

The first instance started ~25FPS


Hotspots
35%      sun.java2d.pipe.SolidTextRenderer.drawGlyphList:38
33%      sun.awt.windows.Win32DDRenderer.clipAndDrawLine:76
6%      jfreerails.client.top.GameLoop.run:101


The second instance started while the first instance is running but minimised ~75FPS


Hotspots
17%      sun.java2d.pipe.SolidTextRenderer.drawGlyphList:38
15%      jfreerails.client.top.GameLoop.run:101
8%      sun.java2d.SunGraphics2D.clone:244
...
2%      sun.awt.windows.Win32DDRenderer.clipAndDrawLine:76


It is the same VM and executing the same line of code, so why is:

sun.java2d.pipe.SolidTextRenderer.drawGlyphList:38 7x faster

and

sun.awt.windows.Win32DDRenderer.clipAndDrawLine:76 48x faster?

Updated, the problem persists with 1.4.2_04.

Setting -Dsun.java2d.d3d=false made the problem go away and increased the frame rate to 110FPS.

So, with the d3d=false it doesn’t matter if you’re running two applications or one, you always get 110 fps?

Have you tried 1.5 beta1?

[quote]So, with the d3d=false it doesn’t matter if you’re running two applications or one, you always get 110 fps?
[/quote]
From the command line, d3d=false always seems to work regardless of what else is running and gives me ~110FPS. Setting ddoffscreen=false or noddraw=true
also works, but this only gives me ~80FPS. Not setting any flags gives me ~25FPS.

From webstart, setting d3d=false seems to have no effect, i.e. I get ~25FPS unless another java app is running. Setting noddraw=true, however, does work and gives ~80FPS.

This is with 1.4.2_04. I haven’t tried 1.5 beta1 yet.

With 1.5 beta1

~95FPS with d3d=false
~70FPS with noddraw=true
~30FPS with no flags set

[quote]From webstart, setting d3d=false seems to have no effect
[/quote]
I suspect that the property gets set too late when set from Webstart. AWT is already active and the decision to use d3d has already been made.

Looks like some weirdness with the video drivers/DX/D3D.

What is your video board? What DX, driver version?

Try installing the latest driversif you haven’t already.

Does your app set sun.java2d.translaccel property?

Also, could you please run your app from the command line with -Dsun.java2d.trace=count, let it run for a while, then quit and post the output.

Then, start some other java app (netbeans or whatever), and run your app with the tracing enabled.

I’m just trying to figure out if we’re using different loops in the two cases.

I’m no driver expert but I’m pretty sure that most D3D (and to a lesser extent, OpenGL) drivers are optimized for a single onscreen context, which is their expected usage as DirectX is designed to be a games API. The D3D APIs are not specifically bad at handling multiple contexts but the implementations are, as I say, tuned to deal with the common case one one context.

When you have two contexts the continual switching between one and the other is likely to cause severe performance degradation.

The decision to use DirectX in the rendering pipeline by default for Java2D was probably unwise. There are many instances of incompatibility, poor performance, or incorrect behaviour between multiple DirectX applications onscreen.

Cas :slight_smile:

I agree that this is the most probable cause of this ‘weirdness’ - we’ve seen things like this before.

What would you suggest to use as an acceleration API on Windows?

Please don’t say “OpenGL”, it’s drivers state is in much worse condition than DX.

GDI+? It’s not accelerated, and will never be, according to some sources (and it’ll basically die slowly and painfully anyway when Longhorn comes)

We did consider having a pure GDI pipeline, but, of course, not everything could accelerated.

Unfortunately, DX/D3D seems to be the only viable solution, even considering all its shortcomings.

Hm, I was under the impression GDI+ was a bit better at this sort of thing…

You’re stuck with D3D if you don’t want to use OpenGL at all (don’t use DirectDraw!) - so it seems you need to find a way to get it to function a little more optimally. It should be possible to get it to cooperate a little better that it is though, I believe.

Out of interest, why don’t you try using OpenGL drivers? You’ve got a reliable 65% of the Windows desktop then (I mean working OpenGL drivers, too). You’ve got all the code already in the Linux build. If you detect a decent OpenGL implementation you could use that as the primary path; then back off to Direct3D for the 35% that don’t have GL drivers; then finally to GDI.

This ultimately would be of great benefit to you I think as your Mac and Linux codebases should be near identical. This will let you take care of the vast majority of desktop systems out there with one code path. (And remember we are talking very basic OpenGL functionality requirements here - no shaders or crazy stuff like that).

Need I also suggest that touting OpenGL as the primary accelerated API of choice on desktop systems will probably make the OEMs sit up and take a bit more notice of the proceedings.

Cas :slight_smile:

[quote]Out of interest, why don’t you try using OpenGL drivers? You’ve got a reliable 65% of the Windows desktop then (I mean working OpenGL drivers, too).
[/quote]
Isn’t the problem deciding whether the OpenGL is reliable as opposed to just being present? Perhaps have a table of driver versions which are known to be adequate.

What a coincidence, I have such a table :slight_smile: It’s more or less the case that any GL driver advertising version 1.3 capability or above will be able to accelerate Java2D operations without problem.

Cas :slight_smile:

[quote]What is your video board? What DX, driver version?
[/quote]


------------------
System Information
------------------
Time of this report: 3/17/2004, 22:04:48
       Machine name: D1QDQL0J
   Operating System: Microsoft Windows XP Home Edition (5.1, Build 2600) Service Pack 1 (2600.xpsp2.030422-1633)
           Language: English (Regional Setting: English)
System Manufacturer: Dell Computer Corporation
       System Model: Dimension 2350
               BIOS: IntelR - 42302e31
          Processor: Intel(R) Pentium(R) 4 CPU 2.50GHz
             Memory: 254MB RAM
          Page File: 208MB used, 417MB available
Primary File System: n/a
    DirectX Version: DirectX 8.1 (4.08.01.0810)
DX Setup Parameters: Not found
     DxDiag Version: 5.01.2600.1106 32bit Unicode



---------------
Display Devices
---------------
        Card name: Intel(R) 82845G/GL/GE/PE/GV Graphics Controller
     Manufacturer: Intel Corporation
        Chip type: Intel(R) 82845G Graphics Controller
         DAC type: Internal
        Device ID: Enum\PCI\VEN_8086&DEV_2562&SUBSYS_01471028&REV_03
   Display Memory: 64.0 MB
     Current Mode: 1024 x 768 (32 bit) (60Hz)
          Monitor: Dell E151FPp
  Monitor Max Res: 1024,768
      Driver Name: ialmrnt5.dll
   Driver Version: 6.14.10.3691 (English)
      DDI Version: 8 (or higher)
Driver Attributes: Final Retail
 Driver Date/Size: 10/8/2003 10:12:28, 36927 bytes
    Driver Signed: Yes
  WHQL Date Stamp: n/a
              VDD: 
         Mini VDD: ialmnt5.sys
    Mini VDD Date: 10/8/2003 10:11:20, 93979 bytes
Device Identifier: {D7B78E66-6622-11CF-F37D-4D21A2C2CB35}
        Vendor ID: 0x8086
        Device ID: 0x2562
        SubSys ID: 0x01471028
      Revision ID: 0x0003
         Registry: OK
     DDraw Status: Enabled
       D3D Status: Enabled
       AGP Status: Enabled
DDraw Test Result: All tests were successful.
 D3D7 Test Result: All tests were successful.
 D3D8 Test Result: All tests were successful.

[quote]Does your app set sun.java2d.translaccel property?
[/quote]
No

[quote]Also, could you please run your app from the command line with -Dsun.java2d.trace=count, let it run for a while, then quit and post the output.

Then, start some other java app (netbeans or whatever), and run your app with the tracing enabled.
[/quote]
Trace from first instance started, ~28FPS

And from the second instance, running while first instance is minimised ~95FPS

Someone from Sun (Chet?) has already stated that a the OpenGL pipeline IS being maintained in the Windows code base… and that perhaps some time in the future it could be included in the Windows JRE release.
I got the impression that it was simply the fact that there is no time to work out the kinks on Windows given that Windows already has acceleration through D3D and DirectDraw.

Too bad driver writers aren’t more accountable for the problems they cause for everyone else.

I’ll leave it to Chris to ramble about the quality of OpenGL drivers on windows, especially on non-nvidia boards.

Unfortunately for us, not everybody has the latest Nvidia board with the latest drivers. In fact, the majority have some kind of on-board intel i8xx stuff, and opengl there doesn’t fly (nor does d3d =).

Anyway, we too, think that we should have a complete D3D pipeline (no ddraw), because now we do too much switching between ddraw (blitting, locking), d3d (lines, rects, texture blits), which kills the performance.

Unfortunately, it won’t happen in 1.5…

Luke, thanks for all the info.

It appears that in the second case we don’t use d3d as much (I’m guessing because of some kind of drivers issue) for rendering rectangles/lines, and it works better as there is not as much context switching.

I’m not sure if we’ve tested on this particular board, I’ll check tomorrow.

Unfortunately, I don’t think the fix for this would be straightforward, and it’s very doubtful it’ll make it into 1.5.
The correct fix would likely involve rewriting our rendering pipeline on windows to use only D3D (or OGL)…