Performance issues

Hi!



I'm experiencing some problems regarding performance, but I can't seem to figure out why.



We're working on an application with a fairly simple 3D scene. It consists of a few HUDs, a grid and some relatively simple objects mainly created from boxes/spheres/cylinders etc placed at the center of the 3D scene. You can move around the camera to view these objects from different angles and zoom in and out.



Normally, this application has a very low cpu usage. However, if you zoom the camera in close to the objects at the center of the scene, the cpu usage spikes and stays high. This has the biggest effect if you have 3-4 or more objects visible after zooming in, but is noticable even when only 1-2 objects are still in the view frustum after zooming.



This seems very illogical to me, since when you zoom back out again you have a lot more visible objects to render. Still, the cpu load drops dramatically if I do so. And when I zoom back in where only a couple of objects are inside the view port, the cpu load increases again.



I've tried culling all the HUDs to remove them from the equation. The effect is identical with or without the HUDs visible.



Also it's probably worth mentioning that this is a relatively old jme app, still running on jme 1. We're hoping to port to jme 2 in the future, but haven't had the time to do so yet.



Does anyone have any ideas what might cause such an effect? Any help would be appreciated.

Serenic said:

Normally, this application has a very low cpu usage. However, if you zoom the camera in close to the objects at the center of the scene, the cpu usage spikes and stays high. This has the biggest effect if you have 3-4 or more objects visible after zooming in, but is noticable even when only 1-2 objects are still in the view frustum after zooming.


High CPU Usage is not necessarily a bad thing. I assume you have a normal renderloop, wich will try to render as much frames as possible.
So a high CPU usage means, that the CPU is busy with non-rendering work. This usually is the case, when the GPU as very little to do. So if you have only few objects, the GPU is mostly IDLE, whereas all the culling work have to be done either way by the CPU.

If you can report the framerates, we could tell you, if it's really a performance problem or not.
The framerate shouldn't drop when displaying fewer objects.

If you can, check your program with a profiler (jvisualvm could be enough). The fact that the CPU load goes crazy after a user interaction may suggest that we are facing an EDT spin. The profiler will tell you that by means of a huge increase in the time spent in "post event" calls. On the other end, if you see an increase in the time spent in opengl or jme calls… well, there could be something wrong in the engine or in the way the program uses it.


I could try to profile to get a better idea, but I highly doubt it has anything to do with an EDT spin. Normally, the user can interact as much as he wants with the camera without this happening. It only happens specifically when you zoom in close on clusters of objects in the 3D scene, and the load goes back to normal if you zoom back out or move the camera so the objects exit the view frustum.

Yap, that behavior doesn't look like a threading issue at all.