Bug 106 : processing sometimes won't run above 50% cpu
Last modified: 2005-08-14 07:47




Status:
ASSIGNED
Resolution:
-
Priority:
P3
Severity:
normal

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-07-28 05:10
original report
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1115790904

dxtx:

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

------

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!

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!

------

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.

------

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...)

------

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);
}
Additional Comment #1 From fry 2005-07-28 05:26
this may be related to bug #107 and the flash player is simply disabling
the vertical sync on the graphics card. the more that i think about it, i
have a feeling that's what's going on.