We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsSoftware Bugs › odd cpu usage behaviour with windows/flash (0090)
Page Index Toggle Pages: 1
odd cpu usage behaviour with windows/flash (0090) (Read 2376 times)
odd cpu usage behaviour with windows/flash (0090)
May 11th, 2005, 7:55am
 
Hello, I've just discovered a quite unusual weirdness with Processing.  I'm using 0090beta under Windows XP Pro.  I have no JRE installed, so I'm using the Java that is bundled with Processing to test.

I have an OpenGL-based Processing sketch that rotates a bunch of meshes.  I normally get about 35fps average.

However, and here's the odd bit, if I use Firefox (or IE) to go to a website that utilizes the -Flash- plugin (ie: homestarrunner.com) my fps in this sketch jumps from 35 to about 55fps.  As soon as I close Firefox/IE, or go to a page that doesn't use the Flash plugin, the fps drops back to 35fps.

The fps jumps up and down even while the Processing sketch is running - it happens dynamically.

I'm not sure what is causing this, maybe some shared component in Windows is getting a priority boost from Flash and thus causing Processing to utilize more CPU.  (the Processing/java cpu usage jumps from a max of 50% to 95% when a webpage with Flash running is active somewhere). I have a single-processor machine.  Running Flash somehow causes Java to consume more CPU (nearly double the amount), which in turn vastly increases the framerate of my Processing sketch..

Just thought I'd mention this..

I really like this boost in performance -- when Processing can suddenly use more CPU, it really helps.. but right now the only way that happens is when the Flash plugin is loaded! Wink

dxtx
Re: odd cpu usage behaviour with windows/flash (00
Reply #1 - May 11th, 2005, 7:59pm
 
are you sure it's actually making the sketch run faster? or is it just that it's reporting the framerate as being higher?

it might be related to the 3rd item under the "can't fix" section:
http://processing.org/faq/bugs.html#cantfix

which basically causes the system time to go backwards when running a p5 applet at full tilt sometimes.. this would cause a higher framerate to be reported because the elapsed time per frame would be much smaller than it's supposed to be.

also, are you running on a dual processor system? if so, then a p5 piece will use up all of just one cpu (50% utilization) then the flash plugin is using the other cpu (added up to be 95% utilization).

at least those are the two things that i suspect, but if those aren't the case, something very odd is happening.
Re:odd cpu usage behaviour with windows/flash
Reply #2 - May 11th, 2005, 8:51pm
 
It's absolutely making the sketch run faster.  It might sound weird, but I've repeated this over and over.  It's repeatable every time for me.  I have a -single- processor system (a run of the mill 32-bit AMD AthlonXP 3200).  

Basically, if I -only- have Processing open and running, 'java.exe' never surpasses 50% cpu usage.  If I have a Flash plugin running somewhere, 'java.exe' immediately uses 99%, and with this it doubles the performance of my sketches.

Here are the steps I take..

1) Start Processing IDE (0090 Beta with included Java)
2) Run my (intensive) 3D/opengl Sketch with Processing.
* Sketch FPS: 30-35  
* java.exe CPU Usage: 45-50%
3) Leaving the sketch running, I open IE/Firefox.
4) I go to a page that has no Flash plugin, and check Task Manager/Sketch performance.
* Sketch FPS: 30-35
* java.exe CPU Usage: 45-50%
5) I go to -any- webpage that uses the Flash plugin, and then alt-tab back to Processing and check the Task Manager/Sketch performance -- and, surprisingly:
* Sketch FPS: 55-65  (doubles!)
* java.exe CPU Usage: 90-99%  (doubles!)

The Processing sketch (which has been open and running the entire time) is very, very noticably faster now.  It is an interactive sketch.  It's getting twice as much CPU, it's getting double the framerate, and it looks and feels, very noticably, twice as fast.

What's more, the very moment I close the browser window with the Flash plugin, the Processing applet dynamically scales back CPU Usage to the original 50% cpu usage/30-35fps.

I've also noticed this behaviour when I run the Trillian chat program.  java.exe suddenly jumps from 50% cpu usage to 99% cpu usage, and my Processing sketches operate MUCH smoother.

One question.  Is the normal behaviour with Processing applets to lock CPU usage of java.exe to 50%, or to give it as much CPU as it needs?  I prefer the later as I'm not writing "play nice" applications but things that are supposed to hog the system.  I see both behaviours here, so I don't even know what's considered normal!

Thanks,
Tim
Re: odd cpu usage behaviour with windows/flash (00
Reply #3 - May 12th, 2005, 12:25am
 
If it helps at all, I've reproduced this behaviour on three different windows machines: two Windows Xp Pro, and one Windows 2000.

All of these are using Processing 90beta and that version's bundled Java. I also don't believe this is a version 90beta specific issue.  I don't know where the problem lies, in the way Processing starts the applet, the JVM, or what.. but it is weird to have external applications directly affect the performance of Processing's applets.

Thanks,
Tim

Re: odd cpu usage behaviour with windows/flash (00
Reply #4 - May 12th, 2005, 7:01am
 
is it something that only happens with that sketch? only with opengl? with any sketch using opengl?

or is it only with applets that use an imported library? (i.e. when you have a code folder, or have an import xxxx statement at the beginning of your program, etc)

(all the info does help a lot, btw.. it would be a while before i could get around to tracking down and testing something like this...)
Re: odd cpu usage behaviour with windows/flash (00
Reply #5 - May 12th, 2005, 8:20am
 
Nope, it happens with any sketch, at least any that I've tried, even ones that don't use OpenGL or any other external library.

For instance, I'll use the very simple example at the bottom of this post, from the Processing reference.  If all I have running is the Processing 90Beta, when I run that sketch "javaw.exe" uses 20-30% or so of the CPU and the graphical bar takes a good *three seconds* to cross the screen.

HOWEVER, if I simply start Firefox and go to homestarrunner.com (or any other website that uses the Flash plugin) and rerun that sketch, this time "javaw.exe" uses 80-90% of the cpu and the bar draws in less than *one second*.

Even without checking Task Manager, it's very, very obvious that the bar crosses the screen is less than half the time.

Like I said before, it's not just the Flash plugin that causes this weirdness - the Trillian chat program does as well, and probably others.  Some applications don't inspire Java to operate with higher CPU though (Azareus doesn't, for one)

And also, like before, I can reproduce this on three different windows machines.. one of which isn't a computer I own and has completely different versions of things installed, including a different OS (Win2K vs WinXP).  That said, it could still be a weird coincidence and this problem only affects these three machines.. so if anyone else can reproduce this, that would be really cool! Smiley

Let me know if you need any other information.

-- here's the little code snippet I described above. It'll probably be familiar!

void setup() {
 size(200, 200);
 background(0);
 noStroke();
 fill(102);
 }
int a = 0;
void draw() {
 rect(a++%width, 10, 2, 80);
 }
Re: odd cpu usage behaviour with windows/flash (00
Reply #6 - Jul 28th, 2005, 5:03am
 
anyone figure out what's going on here yet?
Re: odd cpu usage behaviour with windows/flash (00
Reply #7 - Jul 28th, 2005, 2:11pm
 
rather than that, i've opened a bug for this guy:
http://dev.processing.org/bugs/show_bug.cgi?id=106
so that we can track the follow-up there.
Page Index Toggle Pages: 1