How to enable JIT?

D

Dmitriy Melnik

Hi everyone!
I wanna speed up the program I am creating now. I heard one way to do
it is to use JIT. Is it possible to enable it on HotSpot VM? If it is
how can I do that?
Thanks in advance.
 
T

Thomas Kellerer

Dmitriy Melnik wrote on 21.02.2009 18:47:
Hi everyone!
I wanna speed up the program I am creating now. I heard one way to do
it is to use JIT. Is it possible to enable it on HotSpot VM? If it is
how can I do that?

It's enabled by default, there is nothing you need to do.

You can only influence the threshold when bytecode gets compiled into native
code (after how many executions)

For details see:

http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
 
A

Arne Vajhøj

Thomas said:
Dmitriy Melnik wrote on 21.02.2009 18:47:

It's enabled by default, there is nothing you need to do.

Not only is id enabled by default - I don't even think it can
be disabled in newer JVM's.

Arne
 
D

Dmitriy Melnik

So another question arouse. What VM can provide the best performance?
The matter is I am creating a cryptographic system and need it run as
fast as possible.
 
A

Arne Vajhøj

Dmitriy said:
So another question arouse. What VM can provide the best performance?
The matter is I am creating a cryptographic system and need it run as
fast as possible.

I don't think the difference is that big. For newer Java versions SUN's
with -server is approx. as fast as IBM's and BEA's.

If you test with your specific code, then one of them may
be a bit faster than the other, but you may find a different
one to be faster with some other code.

Arne
 
D

Dmitriy Melnik

I don't think the difference is that big. For newer Java versions SUN's
with -server is approx. as fast as IBM's and BEA's.

If you test with your specific code, then one of them may
be a bit faster than the other, but you may find a different
one to be faster with some other code.

Arne

Thanks! I really appreciate your help.
 
L

Lew

Dmitriy said:
Thanks! I really appreciate your help.

Two approaches to increase speed:
- tune the VM parameters (-server, -X and -XX options);
- throw hardware at the problem.

If your application is correctly multithreaded, then additional CPU cores can
speed things up (subject to Amdahl's Law). More memory can help to a point,
especially on 64-bit platforms. If I/O is an issue in your application,
faster disks will help. No optimization of a slow algorithm will improve
things as much as a faster algorithm, assuming equivalent correctness.

The dictum for optimization is to measure performance first, then again after
optimization attempts. Results are often counter-intuitive.
 
D

Dmitriy Melnik

Lew said:
Two approaches to increase speed:
- tune the VM parameters (-server, -X and -XX options);
- throw hardware at the problem.

If your application is correctly multithreaded, then additional CPU cores can
speed things up (subject to Amdahl's Law).  More memory can help to a point,
especially on 64-bit platforms.  If I/O is an issue in your application,
faster disks will help.  No optimization of a slow algorithm will improve
things as much as a faster algorithm, assuming equivalent correctness.

The dictum for optimization is to measure performance first, then again after
optimization attempts.  Results are often counter-intuitive.

Thanks for the useful post. I've already played with VM options a
little bit. Quadratic sieve factoring algorithm runs about 10% faster
with the combination of -server and -XX:+AggressiveOpts options.

Btw, what do you mean by trimming sigs? I'm a complete newbie on
Usenet.
 
J

Joshua Cranmer

Dmitriy said:
Btw, what do you mean by trimming sigs? I'm a complete newbie on
Usenet.

The text below a line consisting of `-- ' is a standard signature; many
Usenet clients will automatically strip it when replying (as well as
displaying it in a different manner). There are sometimes people who do
not use the line to indicate a signature (most often, when it is just a
person's name); it is still good form to strip those lines from replies.
 
E

EJP

Lew said:
Two approaches to increase speed:
- tune the VM parameters (-server, -X and -XX options);
- throw hardware at the problem.

Specifically, in this case, throw a hardware crypto accelerator at the
problem. That'll fix it.
 
D

Dmitriy Melnik

EJP said:
Specifically, in this case, throw a hardware crypto accelerator at the
problem. That'll fix it.

I am creating a distributed system for cryptographic computations. I
am going to use Java to provide scalability among different platforms.
And also to allow users to add their own algorithms easily. The only
concern is performance. I wonder if I can achieve that of languages
like C. A hardware accelerator won't fit in my case I suppose.
 
D

Dmitriy Melnik

For the "symmetric" class of cryptographic algorithms (symmetric
encryption, hashing...), a properly optimized Java implementation
typically achieves between 25 to 50% fo the performance achieved with a
properly optimized C implementation. Which is enough for most purposes.
For some algorithms, I observed up to 75% of C speed; the performance
killer operation seems to be array accesses, so algorithms which are
heavy on array accesses (e.g. RC4) get the worst penalty.

For the more numerical primitives (e.g. RSA), mileage varies.
java.math.BigInteger is not the fastest package for big integers ever
(but it is not bad either).


On a general basis, if you stick to the JCA interfaces then you gain
support of hardware accelerators "for free".

Thanks for the reply. Indeed not very encouraging results! I am now
developing a distributed system for supporting cryptographic and
cryptoanalytic computations. There are number factorization algorithms
and other ones that require a lot of processing time. I wonder if it
is practical to trade off some performance for the simplicity of
adding new nodes and algorithms to the system which Java is able to
provide?
 
R

Roedy Green

So another question arouse. What VM can provide the best performance?
The matter is I am creating a cryptographic system and need it run as
fast as possible.

Without spending any money, use java -server in the JDK.

If you want max speed, use Jet with native compilation and global
optimisation. Read the jet manuals thoroughly. There are many things
you can tweak to squeeze out a few last drops of performance,
including fast startup.

see http://mindprod.com/jgloss/jet.html

You an try it the evaluation version too see how much it will help
your app.

See also http://mindprod.com/jgloss/optimising.html
http://mindprod.com/jgloss/optimiser.html

Usually the really big gains come from tweaking your algorithm.
--
Roedy Green Canadian Mind Products
http://mindprod.com

One path leads to despair and utter hopelessness. The other,
to total extinction. Let us pray we have the wisdom to choose correctly.
~ Woody Allen .
 
L

Lew

Thomas said:
For the "symmetric" class of cryptographic algorithms (symmetric
encryption, hashing...), a properly optimized Java implementation
typically achieves between 25 to 50% fo the performance achieved with a
properly optimized C implementation. Which is enough for most purposes.
For some algorithms, I observed up to 75% of C speed; the performance
killer operation seems to be array accesses, so algorithms which are
heavy on array accesses (e.g. RC4) get the worst penalty.

Care to show the benchmarks for those claims? What hardware, C and Java
versions, optimization options, etc., did you use? Did you at least turn on
maximum optimizations for Java ("-server", GC tuning)? Did you count JVM
startup time or did you start the timing at the beginning of the relevant
algorithm? Did you let HotSpot warm up first?

Quoting such numbers with supporting context is very misleading and irresponsible.
 
R

Roedy Green

I am creating a distributed system for cryptographic computations. I
am going to use Java to provide scalability among different platforms.
And also to allow users to add their own algorithms easily. The only
concern is performance. I wonder if I can achieve that of languages
like C. A hardware accelerator won't fit in my case I suppose.

Nowadays no problem. The compilers and optimisers are vastly improved.
Java is in theory a much easier language to optimise than C. It is
much harder to do things behind the compiler's back in Java.

When you optimise your algorithms, MEASURE them first to see where the
time is being chewed up. See http://mindprod.com/jgloss/profiler.html
Always work on the current bottleneck.

--
Roedy Green Canadian Mind Products
http://mindprod.com

One path leads to despair and utter hopelessness. The other,
to total extinction. Let us pray we have the wisdom to choose correctly.
~ Woody Allen .
 

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,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top