While browsing the API, I noticed the class java.lang.Compiler. I was wondering if it was possible to use it to try and prod the hotspot compiler into compileing your classes before you start up the main game loop?

I've been working on my game both windows and linux, and it seems to me, that under linux my game takes a long time untill it is running at full speed, where as under windows after about 5 seconds of play, it stabilizes at 25 frames per second. I'm not sure, but it would seem that the hotspot compiler is taking a lot longer to figure out what it wants to optimize, and compile it under linux.

Could I somehow use java.lang.Compiler to reduce the amount of time it take my game to get to full speed under linux? What exactly is Compiler there for, and should I be using it?

First test report.well, i don't know if compilation is really done. it takes very few time, and the results of the bench does not change. If compilation is done, no optimisation is done (or at least the inlining, that's certain), thus, lots of the benefit for me disappears. Will test more when i'll have more time.

I had a bit of a play around with it, however I couldnt really get it working. Compileing most of my classes returned a false, which ment that they couldnt be compiled. Perhaps you need to instiantiate your classes before you can have them compiled. I was hoping though that somebody would be able to tell me why compiler was included in the API and what it is for.

Set it to like "10", so if the method is accessed 10 times, its compiled to native code... or 1 or something like that. I've tried this wtih Netbeans (beast-app) and the startup time is pretty aweful, but the app runs really snappy after that. The memory consumption goes up though....

(not to disagree with that last post, but) a warning: some people may not have that option on their Java VM. -X is a prefix for "unofficial, unsupported switch".

From the java API docs, java.lang.Compiler is really just a convenient way of interacting with whichever Compiler your VM is currently using (there are command-line switches to chose different Compiler's to be used by your VM, if you have them).

It mostly isn't defined by Sun (e.g. the javadoc comment for one method is "...and perform some documented operation" without even suggesting possible operations that this might include. I.e. Sun provides this as a sort of "reflection on your VM/compiler" letting you send custom commands to the compiler.

Its almost entirely useless unless you have the documentation for your compiler.

Since Java 1.4 no longer has a JIT compiler (in the traditional sense, don't have a URL for this, but look at release notes for Jav 1.3, 1.4), you may find that the Sun JDK's NEVER have a valid java.lang.Compiler any more. (the methods are pretty much "old style" java i.e. they aren't well named, they aren't properly documented, which is generally a sign that Sun have lost interest and probably don't care about that class much any more)

Hmmm, the CompileThreshold method gives me a bost of about 6 or 7 FPS under linux. Unfortunately I am kinda disapointed with the speed under linux. Acording to the profiler my game spends 63.3% of its time inside something called sun.awt.X11PMBlitLoops.Blit, where as under windows the big bottleneck was in a few methods of mine that need optimising. does anybody know if any speedups are planed for linux graphics? I herd a rumour, that they were going to change eveything to run using openGL so, full screen mode, and graphics accleration should run properly under linux.

Hmmm, the CompileThreshold method gives me a bost of about 6 or 7 FPS under linux. Unfortunately I am kinda disapointed with the speed under linux. Acording to the profiler my game spends 63.3% of its time inside something called sun.awt.X11PMBlitLoops.Blit, where as under windows the big bottleneck was in a few methods of mine that need optimising. does anybody know if any speedups are planed for linux graphics? I herd a rumour, that they were going to change eveything to run using openGL so, full screen mode, and graphics accleration should run properly under linux.

Hmmm, the CompileThreshold method gives me a bost of about 6 or 7 FPS under linux. Unfortunately I am kinda disapointed with the speed under linux. Acording to the profiler my game spends 63.3% of its time inside something called sun.awt.X11PMBlitLoops.Blit, where as under windows the big bottleneck was in a few methods of mine that need optimising. does anybody know if any speedups are planed for linux graphics? I herd a rumour, that they were going to change eveything to run using openGL so, full screen mode, and graphics accleration should run properly under linux.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org