I wrote an OpenGL Display that scrolls spectrographic information supplied at very fast rates - from a 100 to a 1000 lines per second. The visual’s own display thread is slower than the pace at which the Data is supplied (typically 25 fps) so the idea is to scroll the information and then write a block (of the new information) and then sleep while accumulating information in a buffer until woken up again. All this is basically just to say that the Visual does a lot of work. The Display itself is only a small component in a much larger app I wrote that is used to analyze spectrogram data. The app has quite a few of these Displays all scrolling quite happily.
I wrote the Displays using GL4Java initially and when the App was pushed to the limit the machine was usually running at about 70% CPU usage. When I migrated to the JOGL apps I was happily suprised to find that the Processor usage decreased from 70% to about 50%.
Recently, however we have discovered a Time Acceleration problem in Windows whenever I use these displays. The PC Time literally “accelerates” and you can actually see the System Clock racing ahead. Sometimes the System Time would increase by almost 10 seconds in 1 minute. We also noticed that the Time problem became significant the faster we displayed information on the App. Of course, when working with information that is related to Time, having the System Time behave all willy-nilly is a serious complication for us.
Long story short, eventually I found the following bug report on Sun’s Bug Parade: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4500388. Which basically describes the bug as being a byproduct of switching between High Resolution and Low Resolution Time on Windows (Read the bug for a description of the problem). And it commonly occurs on Multithreaded apps with threads that sleep with a sub-ten-millisecond resolution.
Luckily there is a flag (-XX:+ForceTimeHighResolution) you can provide the VM so that it always uses High Resolution Time and never switches between the two. This solved the problem for us and I was very happy (phew). But here’s the clincher: I had feared that by using the flag we would suffer a performance impact, since the bug report warned that it might be so. I found however that the opposite was true in my case.
The CPU Usage was in fact, reduced by an incredible factor of about 5:1. With the flag enabled the app with GL4Java dropped from 70% to 30% CPU usage and with JOGL the CPU usage dropped from 50% to almost 0%. That’s right: 0%.
The engineers here couldn’t believe their eyes, that we were displaying information at a rate so fast its almost impossible to see and the CPU was idling around 0%, peaking to 4% every now and again.
Anyway this was really incredible for me as well and I was wondering if anybody else here have had a similar experience. And also if anybody is having problems with the System Time or High Processor usage; it might be worth it to check whether this flag makes a difference.
Thanks JOGL, you’ve definitely impressed me and my colleagues.