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.
IndexProgramming Questions & HelpPrograms › Processing slow as molasses on linux - why
Page Index Toggle Pages: 1
Processing slow as molasses on linux - why? (Read 838 times)
Processing slow as molasses on linux - why?
Sep 17th, 2007, 4:34pm
 
I blame poor integration with X in Java.  but that's just a guess.  here's the situation:

I spent last year teaching Processing, using Linux on some pretty machines (2Ghz athlon dual-cores), and just consistently felt that it was extremely slow.  Any size larger than about 400 or 500 pixels gives a big hit to the framerate; even PDE feels slow, typing has small but irritating lag, etc.   Doing the same things on comparable, or less-powerful, macs, didn't have these issues.  Weird and annoying, but I didn't want to post something like "Processing is slow! Argh!" without some numbers to back it up.  So I tried to come up with some benchmarks and run them on identical hardware under at least Windows and Linux to try and gain some insight into what's going on.

Here's my little benchmark app:  1000 lines per frame, from black to white, printing out timing data after every 256 frames.

/////////////////////////////////////////////////////
float c;
int starttime,endtime;
void setup()
{
c=0;
size(1000,700);
starttime=millis();
frameRate(60);
}
void draw()
{
background(127,127,127);
stroke(c,c,c);
for(float i=0;i<1000;i++)
{
line(random(1000),random(700),random(1000),random(700));
}
c++;
if (c>255)
{
c=0;
endtime=millis();
float dt=endtime-starttime;
println("Total time=" + dt + " ms    Average Frametime=" + (dt/256));
starttime=millis();
}
}
//////////////////////////////////////////

Test machine is an HP Pavilion ze2000 laptop, nothing too special but not ancient and creaky either.  

AMD Sempron 1.6 GHz
ATI Radeon Xpress 200

here's the numbers (average frame time in milliseconds.  smaller is better).  the target framerate is 60fps, or 16 ms per frame.

=== WINDOWS XP HOME : NO OPENGL ===

:: 1000 lines
1000x700: 91 ms
400x400: 22 ms
100x70: 16 ms

:: 100 lines
1000x700: 36 ms
400x400: 16 ms
100x70: 16 ms

=== WINDOWS XP HOME : OPENGL ===

:: 10,000 lines
1000x700: 255ms

:: 1,000 lines
1000x700: 16 ms

=== UBUNTU 7.04 : NO OPENGL ===

:: 1000 lines

1000x700: 263.5ms
400x400: 60ms
100x70: 16.1ms

:: 100 lines

1000x700: 121 ms

:: 10 lines

1000x700: 121 ms

:: 0 lines

1000x700: 120 ms

=== UBUNTU 7.04 : OPENGL ===

:: 10,000 lines

1000x700: 184.39 ms

:: 1,000 lines

1000x700: 16.1 ms


Conclusions:

In Linux, without OpenGL acceleration, you can't have a large window size, period.  It appears that just the overhead of the draw() loop and background() call take up 120 ms, or around 8 fps, at 1000x700.

OpenGL acceleration solves the problem, giving full 60fps at 1000x700 for the 1000 lines test case.

Windows fares a little better without opengl, getting a frame rate of close to 12fps at 1000 lines, 1000x700, and getting around 28fps at 100 lines at 1000x700.  While the stage size is still a big factor, it's more sensitive to the number of lines.  

With OPENGL, again we get full 60fps at 1000 lines, 1000x700.  Interestingly, when we push the line count to 10,000, the linux ATI drivers apparently beat the Windows ATI drivers with 184 ms/frame vs 255 ms/frame.  

I don't care about windows at all, actually, I'm just interested in making Processing run faster in Linux

so, questions:

should I just ignore this and always use OpenGL?

is the reason mac 'feels' faster because the awt/java2d/whatever is secretly using hw acceleration?

is there any difference in performance between different versions of java?




Re: Processing slow as molasses on linux - why?
Reply #1 - Sep 17th, 2007, 5:47pm
 
Do you also encounter an unusually high CPU load whithout OpenGL If yes, this may be the same behaviour as the one I'm describing in this thread.

EDIT Fixed the URL
Re: Processing slow as molasses on linux - why?
Reply #2 - Sep 22nd, 2007, 5:21am
 
I'd like to chime in on the Mac speed bump you're bringing up.  When I run your benchmark in regular mode @ 60fps, my results are as follows:

Total time=22729.0 ms    Average Frametime=88.78516
With around 100 percent CPU usage (100 on one core)

OpenGL:
Total time=4096.0 ms    Average Frametime=16.0
Total CPU usage at around 30 percent on one core

Average frametime seems to top out around 240FPS at 4ms.
Total time=1311.0 ms    Average Frametime=5.1210938

Therefore, I don't see much of a speed improvement on my mac at least w/ the default rendering.  I'd like to know more about your Linux speed issue, as I'm looking into purchasing a few Linux boxes for processing.

(This is on a 2.4ghz Macbook pro with a 8600gts mobile.)
Re: Processing slow as molasses on linux - why?
Reply #3 - Nov 22nd, 2007, 8:28am
 
I can run some addt'l tests in the next couple days but here you go w/ Ubuntu 7.10 on a Thinkpad T61P 2.2GHZ T7500 w/ 4 GB RAM and NVidia 540m (256MB I think).

1000x700 - 1000 lines

Total time=7778.0 ms    Average Frametime=30.382812
Total time=7502.0 ms    Average Frametime=29.304688
Total time=7630.0 ms    Average Frametime=29.804688
Total time=7731.0 ms    Average Frametime=30.199219

1000x700 - 1000 lines - OpenGL
Total time=4415.0 ms    Average Frametime=17.246094
Total time=4220.0 ms    Average Frametime=16.484375
Total time=4200.0 ms    Average Frametime=16.40625
Total time=4214.0 ms    Average Frametime=16.460938
Total time=4232.0 ms    Average Frametime=16.53125
Total time=4231.0 ms    Average Frametime=16.527344

1000x700 - 10000 lines
Total time=12045.0 ms    Average Frametime=47.05078
Total time=11489.0 ms    Average Frametime=44.878906
Total time=12839.0 ms    Average Frametime=50.152344
Total time=12371.0 ms    Average Frametime=48.32422


1000x700 - 10000 lines - OpenGL
Total time=11262.0 ms    Average Frametime=43.992188
Total time=10926.0 ms    Average Frametime=42.679688
Total time=10724.0 ms    Average Frametime=41.890625
Total time=10600.0 ms    Average Frametime=41.40625
Total time=10897.0 ms    Average Frametime=42.566406

At 1000 lines CPU difference is fairly pronounced between OpenGL & not - 10-30 vs. 50-60%.  Once you push it up to 10000 lines the CPUs are up there towards 80-90% - w/o OpenGL is definitely working it harder but it's up there as well.
Page Index Toggle Pages: 1