effectiveness of compiler optimization

A

abc

I've been using Borland Java for a year or so. One thing I notice is that althought there are profiling tools
there are no optimization settings for the compiler. Whereas I'm used to having C/C++ compilers that hve
multiple options for optimizating for time or for memory etc. there seem to be none with this java compiler.

Is this just Borland or is that generally the case? Do people use 3rd party tools, such as byte-code optimizers,
instead?
 
R

Raymond DeCampo

I've been using Borland Java for a year or so. One thing I notice is that althought there are profiling tools
there are no optimization settings for the compiler. Whereas I'm used to having C/C++ compilers that hve
multiple options for optimizating for time or for memory etc. there seem to be none with this java compiler.

Is this just Borland or is that generally the case? Do people use 3rd party tools, such as byte-code optimizers,
instead?

I'm guessing it might be more fruitful for you to explore the options
available to the java executable for your JRE.

HTH,
Ray
 
A

abc

I'm guessing it might be more fruitful for you to explore the options
available to the java executable for your JRE.

Thank you for your reply. I pursued this as far as the HotSpot options docs but didn't really find anything that
seemed to be about optimizing. The Borland options page for the application talks about Optimizeit, an optional
feature I don'thave, but even that is about programmer optimizing activities and not about compiler
optimization. The hotspot page had various options that might make an app run faster or slower but they didn't
really seem to be about optimizing... am I missing something?
 
R

Raymond DeCampo

Thank you for your reply. I pursued this as far as the HotSpot options docs but didn't really find anything that
seemed to be about optimizing. The Borland options page for the application talks about Optimizeit, an optional
feature I don'thave, but even that is about programmer optimizing activities and not about compiler
optimization. The hotspot page had various options that might make an app run faster or slower but they didn't
really seem to be about optimizing... am I missing something?

How is making an app run faster or slower not about optimizing?

Ray
 
A

abc

How is making an app run faster or slower not about optimizing?

What I was asking about was "... optimization settings for the compiler." Turning off debugging options on the
compiler, or JRE, might make an app run faster but that is not what most CS people would consider an
optimization.
 
V

Vit

Is this just Borland or is that generally the case? Do people use 3rd party tools, such as byte-code optimizers,
You may try to study also the JET Java native-code compiler

http://www.excelsior-usa.com/jet.html

which performs a wide range of optimizations usual for optimizing
compilation. There is a broad range of options that control
optimizations: checks control, inlining, etc.
The performance results are shown here:

http://www.excelsior-usa.com/jetbench.html

All optimizations are performed beyond bytecode level, that is, on the
way to machine code. Evaluation versions for Windows and Linux are
available for study.

Vit
 
R

Roedy Green

I've been using Borland Java for a year or so. One thing I notice is that althought there are profiling tools
there are no optimization settings for the compiler. Whereas I'm used to having C/C++ compilers that hve
multiple options for optimizating for time or for memory etc. there seem to be none with this java compiler.

Is this just Borland or is that generally the case? Do people use 3rd party tools, such as byte-code optimizers,
instead?

All the effort has been put on optimising the machine code generation
from byte code. Preoptimising the byte code usually screws things up
by destroying the stereotypical patterns the machine code optimiser
looks for to generate special case code for.

Both Sun's JIT and Jet are doing quite a number of clever things
converting byte code to machine code.

See http://mindprod.com/jgloss/jet.html
http://mindprod.com/jgloss/nativecompiler.html
http://mindprod.com/jgloss/jit.html
http://mindprod.com/jgloss/compiler.html


--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
A

Andrew Thompson

What I was asking about was "... optimization settings for the compiler." Turning off debugging options on the
compiler, or JRE, might make an app run faster but that is not what most CS people would consider an
optimization.

HotSpot does optimisation according to the current environment,
being the end user's PC. It makes little/no sense to optimise
the bytecodes before that.

To put that another way.

Since the JRE optimises, and does so according to the best
information available at runtime, doing optimisation at compile
time can be counterproductive (or at least a waste of time).

Note: Follow-Ups set to c.l.j.programmer only
 
A

abc

HotSpot does optimisation according to the current environment,
being the end user's PC. It makes little/no sense to optimise
the bytecodes before that.

Do you know if the optimizations can be user controlled? I didn't come across any onfo on that while I was
looking today.
To put that another way.

Since the JRE optimises, and does so according to the best
information available at runtime, doing optimisation at compile
time can be counterproductive (or at least a waste of time).

It's been a long time since I studied compiler design but at the time compilers generally optimized at several
stages, including at the source code level, at the n-tuple level and peephole optimization at the object code
(byte code) level. Typical compile time optimizations done in non-Java languages include things like loop
unrolling, dead variable detection/removal, common sub-expression recognition etc. These would be done long
before object (byte) code was generated. I don't understand why these would be counter-productive or of no
effect, when it comes to Java, just because the JRE also optimizes. Can you explain further?
 
A

Andrew Thompson

Do you know if the optimizations can be user controlled?
I didn't come across any onfo on that while I was
looking today.

What information/URLs are you looking at?

( I am astounded your reference materials did not say
all that needed saying on the subject. )
 
R

Raymond DeCampo

What I was asking about was "... optimization settings for the
compiler." Turning off debugging options on the compiler, or JRE,
might make an app run faster but that is not what most CS people
would consider an optimization.

You've forgotten that Java is really an interpreted language. The JVM
can compile the byte code into native machine code. This is where the
best optimizations can be made.

Ray
 
A

abc

You've forgotten that Java is really an interpreted language. The JVM
can compile the byte code into native machine code. This is where the
best optimizations can be made.

Actually I didn't forget that. I looked for JVM/JRE options that gave
control over optimization to the user and found none. So again I ask,
are there settings for the Java compiler (or JVM/JRE) to control opimization
of an individual program. If I somehow missed them please point me at the
docs so I can investigate for myself.

There are many very effective optimizations to be made at the source code
level (source => source transformations) so what leads you to believe that
the best optimizations are made at the byte code => machine code interface?

If the transformation is being done by a JIT compiler I wouldn't think there
is sufficient time for thorough optimization as in my experience an
optimization pass generally significantly increases compile time with
traditional languages.
 
A

Adam Maass

Actually I didn't forget that. I looked for JVM/JRE options that gave
control over optimization to the user and found none. So again I ask,
are there settings for the Java compiler (or JVM/JRE) to control
opimization
of an individual program. If I somehow missed them please point me at the
docs so I can investigate for myself.

There are many very effective optimizations to be made at the source code
level (source => source transformations) so what leads you to believe that
the best optimizations are made at the byte code => machine code
interface?

If the transformation is being done by a JIT compiler I wouldn't think
there
is sufficient time for thorough optimization as in my experience an
optimization pass generally significantly increases compile time with
traditional languages.

Most JIT compilers don't start working on a give blob of bytecode until it's
been executed several times in interpreted mode. In fact, most of a program
will still be executed in interpreted mode; the JIT compilers make up the
time it takes to do an optimized compilation by not doing compilation at all
for the majority of the program where compilation wouldn't make a
difference.

In addition, there is more information available at runtime than there is at
compile time to help the JIT make decisions about what to optimize. For
example, a non-final method can be inlined by a JIT compiler at runtime if
the compiler can assure itself that the method isn't (currently) overridden
anywhere.

-- Adam Maass
 
A

abc

What information/URLs are you looking at?

( I am astounded your reference materials did not say
all that needed saying on the subject. )

Andrew,

I started out looking at the Borland docs/help using their search/index. Other than some mention of profiling
they are virtually silent on the subject of optimization, especially compiler optimization. Then I went on to
SUN at http://www.sun.com/documentation/ and searched under "optimization" - the majority of references that
came back related to C/C++/Fortran and none seemed relevent to what I was looking for. I
then looked at the JRE 1.4 (which is what is installed on the machine I'm using) online info (sorry can't
remember url) and it seemed to have no execution time flags that directly related to optimization. I looked at
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html which describes the flags that can be passed when
running an application; again no mention of optimization.

Then over the weekend I poked around a bit more and found a page on "non-standard" hotspot options. I found that
(if I am reading correctly) "-server" will turn optimization on (presumably optimization is off by default?).
However the docs mentioned in the last line above do not say that -server(-client) does anything about
optimization at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top