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.
IndexDiscussionGeneral Discussion,  Status › Processing, OpenGL & Java Native Compiler
Page Index Toggle Pages: 1
Processing, OpenGL & Java Native Compiler? (Read 2571 times)
Processing, OpenGL & Java Native Compiler?
May 17th, 2010, 5:55pm
 
I recently heard it's possible to compile Java 1.5 to native code for Windows and Linux (Jnc: http://jnc.mtsystems.ch/)

And that it even works fairly well.

Has anyone tried compiling any sketches with it? It seems like it would be fantastic for performance hungry OpenGL sketches, deployment purposes and even game dev with processing.

I'm going to try to see if it's even possible over the next couple days, but I figured I'd ask if anyone already had positive results. (Nothing came up in the few searches I did)

Jack
Re: Processing, OpenGL & Java Native Compiler?
Reply #1 - May 18th, 2010, 1:48am
 
I don't expect a boost of performance... Don't forget the JVM has HotSpot, a JIT (Just In Time) compiler that compiles to native code fragments of code it detects to be used a lot.
JNC might do that AOT as they say (Ahead Of Time), so it can improve startup time and have maximum performance from the start, but you won't have long running applets going much faster.
Granted, it is a nice way to distribute Java applications.

Last notes: it haven't been updated in a while and doesn't seem to support Java 1.6; and it is a commercial product, which is fine, but can stop lot of Processing users not using it for professional purpose.
Re: Processing, OpenGL & Java Native Compiler?
Reply #2 - May 18th, 2010, 12:18pm
 
Thanks PhiLho for your thoughts!

I think that all makes a lot of sense. The startup times are somewhat annoying though, though I suppose just popping up a quick spash screen with a launcher like processing does is a nice way to show response while the jvm starts. Or maybe have the windows installer register the jvm as a service, but that kindof makes me cringe a little.

I wasn't able to get it to compile the core.jar successfully, so I got blocked there. I probably need to try an older version of processing that is 1.5 compatible?

I also just found Excelsior JET which also has an AOT compiler that looks like it's even currently supported (yet also commercial)

If I get it working I'll try to do some benchmarks and post my results.

Jack
Re: Processing, OpenGL & Java Native Compiler?
Reply #3 - May 18th, 2010, 9:46pm
 
WebDext wrote on May 18th, 2010, 12:18pm:
I also just found Excelsior JET which also has an AOT compiler that looks like it's even currently supported (yet also commercial)

If I get it working I'll try to do some benchmarks and post my results.

Excelsior JET has passed Java SE 6 compliance tests and is indeed fully supported, with version 7.2 scheduled for June 2010. And there are free licenses available to public non-commercial projects.

I would be most interested in your benchmarking results. You may find my email address on the Contact page of our Web site.

Dmitry Leskov
Excelsior LLC
Re: Processing, OpenGL & Java Native Compiler?
Reply #4 - May 20th, 2010, 12:12pm
 
Well, Excelsior JET at least seems to work!

So far in the one test I did (just taking a particle system I wrote and checking the FPS in both cases) Excelsior JET created equal or worse frame rates.

But I'm not sure what caused it because I don't have a profiler and I didn't take the time to check out where the time is actually being spent yet (just using timers).

The code I was testing used OpenGL, so that has to go through JNI somewhere, and it updates FloatBuffer/DoubleBuffer/IntBuffer objects every frame so it can use glDrawElements/glDrawArrays calls. If I had to guess I'd think that could be the problem.

Also, I try to stay away from object allocations in the main loop as much as possible, but I suppose it still could be a difference in the memory manager. I'm really grasping at straws without hard data though.

I'll want to do some tests of static scenes with scripted camera paths and log the fps for comparison. Also, I didn't enable total program optimization, because of the long compile times (which really doesn't matter if it only needs to be built once before release) But I should test that to see if it helps at all. It sounded like that was more for just stripping out code that isn't used over real speed gains.

Any other thoughts on better ways to test the two? I haven't lost hope yet!

Jack


Re: Processing, OpenGL & Java Native Compiler?
Reply #5 - May 20th, 2010, 9:52pm
 
Jack,

I am very new to Processing, just played a bit with it yesterday. It seems to me that Processing source is either translated into Java bytecode or interpreted, but in any case it runs it a separate process started by invoking java.exe. Can you confirm this If so, then it is may be not native code performance that you observe...

Can you point me to the document explaining how to run a Processing program standalone, outside of the environment

If you would prefer communicating over email, my address is near the bottom of the Contact page.

As for the Global Optimizer, depending on the application it may or may not positively affect raw performance, but at least the cold startup time should improve.

Thank you,

Dmitry
Re: Processing, OpenGL & Java Native Compiler?
Reply #6 - May 22nd, 2010, 11:56am
 
Dmitry, Processing does a pre-processing (sic) pass on the code, to add a base class around it, to add imports, to add 'f' after numbers with decimal points, to convert #BAD8AA to 0xFFBAD8AA and so on.
So it generates a .java file in your temp dir, and then just compiles it with the regular Java compiler. Then, as you found out, the PDE runs the generated class(es) files in a separate process.

Now, you can also ask the PDE to export the sketch to HTML (a jar and an HTML page) or to an exe (light wrapper, actually).
The jar seems to be a good candidate for bytecode post processing.

Note that some people also just use Eclipse (or NetBeans, etc.) to write sketches, using Processing (core.jar and some others) as a simple library (but loosing some syntax facilities).
Page Index Toggle Pages: 1