Re: Java (bytecode) execution speed
- From: Chris Smith <cdsmith@xxxxxxx>
- Date: Sun, 29 Apr 2007 12:37:56 -0600
Lee <Lee@xxxxxxxxxxxx> wrote:
All other things being equal, we expect an interpreted language to run a
bit slower than native machine code.
Okay, but there are no interpreted languages discussed in the rest of
your post. All common implementations of Java use a JIT compiler, which
should lead to to no foregone conclusions about whether it will be
faster or slower than a compiled language. There are reasons it's
likely to be slower (the compiler must run quickly, so it won't do a lot
of global optimization), and reasons that today's very sophisticated JIT
compilers for Java are likely to run faster (because it runs at runtime,
the compiler can take advantage of statistical information about how
users are using the application right now, and optimize them as the fast
cases).
If you are looking into performance numbers for Java, you are making a
mistake by focusing on the bytecode execution model. In the end, it's
about a wash -- no loss or gain there. The really important stuff is in
garbage collection and management of the heap. Java's language
definition is such that there are often far more heap allocations than a
typical C program, and they are far shorter lived. Different heap
management techniques are used to adapt to that situation. This affects
the performance of Java applications quite a lot.
On average, the best heap allocation management (including garbage
collection) algorithms out there perform slightly worse than a C-style
explicit heap with free lists. Of course, there are applications where
it performs much better because it reduces the amount of computation
that goes into book-keeping; and there are applications where it
performs much worse if the lifecycles of objects in the application are
unusual. (Some poorly performing cases, should you be interested, are
when a large number of objects live just ever so slightly long enough to
make it out of the nursery, or when there are lots of long-lived objects
that contain frequently modified references to very short-lived
objects.)
Whats the current state of the art? Would we expect a java program to
run at 0.5 * the speed of C, or 0.7 or 0.9 or what?
I'd say anywhere from 0.7 to 1.1 times the speed of C would be a
reasonable guess, depending mainly on the nature of object lifetimes.
But it's just that; a guess.
--
Chris Smith
.
- References:
- Java (bytecode) execution speed
- From: Lee
- Java (bytecode) execution speed
- Prev by Date: Java (bytecode) execution speed
- Next by Date: Darstellung von Set-Elementen in JSF
- Previous by thread: Java (bytecode) execution speed
- Next by thread: Re: Java (bytecode) execution speed
- Index(es):
Relevant Pages
|