<s>
In	O
software	O
development	O
,	O
the	O
programming	O
language	O
Java	B-Language
was	O
historically	O
considered	O
slower	O
than	O
the	O
fastest	O
3rd	O
generation	O
typed	O
languages	O
such	O
as	O
C	B-Language
and	O
C++	B-Language
.	O
</s>
<s>
The	O
main	O
reason	O
being	O
a	O
different	O
language	O
design	O
,	O
where	O
after	O
compiling	O
,	O
Java	B-Language
programs	O
run	O
on	O
a	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
rather	O
than	O
directly	O
on	O
the	O
computer	O
's	O
processor	O
as	O
native	B-Language
code	I-Language
,	O
as	O
do	O
C	B-Language
and	O
C++	B-Language
programs	I-Language
.	O
</s>
<s>
Performance	O
was	O
a	O
matter	O
of	O
concern	O
because	O
much	O
business	O
software	O
has	O
been	O
written	O
in	O
Java	B-Language
after	O
the	O
language	O
quickly	O
became	O
popular	O
in	O
the	O
late	O
1990s	O
and	O
early	O
2000s	O
.	O
</s>
<s>
Since	O
the	O
late	O
1990s	O
,	O
the	O
execution	O
speed	O
of	O
Java	B-Language
programs	O
improved	O
significantly	O
via	O
introduction	O
of	O
just-in-time	O
compilation	O
(	O
JIT	O
)	O
(	O
in	O
1997	O
for	O
Java	B-Language
1.1	O
)	O
,	O
the	O
addition	O
of	O
language	O
features	O
supporting	O
better	O
code	O
analysis	O
,	O
and	O
optimizations	O
in	O
the	O
JVM	B-Language
(	O
such	O
as	O
HotSpot	B-Language
becoming	O
the	O
default	O
for	O
Sun	O
's	O
JVM	B-Language
in	O
2000	O
)	O
.	O
</s>
<s>
Hardware	B-Architecture
execution	O
of	O
Java	B-Language
bytecode	I-Language
,	O
such	O
as	O
that	O
offered	O
by	O
ARM	O
's	O
Jazelle	B-Language
,	O
was	O
also	O
explored	O
to	O
offer	O
significant	O
performance	O
improvements	O
.	O
</s>
<s>
The	O
performance	O
of	O
a	O
Java	B-Language
bytecode	I-Language
compiled	O
Java	B-Language
program	O
depends	O
on	O
how	O
optimally	O
its	O
given	O
tasks	O
are	O
managed	O
by	O
the	O
host	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
,	O
and	O
how	O
well	O
the	O
JVM	B-Language
exploits	O
the	O
features	O
of	O
the	O
computer	B-Architecture
hardware	I-Architecture
and	O
operating	B-General_Concept
system	I-General_Concept
(	O
OS	O
)	O
in	O
doing	O
so	O
.	O
</s>
<s>
Thus	O
,	O
any	O
Java	B-Application
performance	I-Application
test	O
or	O
comparison	O
has	O
to	O
always	O
report	O
the	O
version	O
,	O
vendor	O
,	O
OS	O
and	O
hardware	B-Architecture
architecture	O
of	O
the	O
used	O
JVM	B-Language
.	O
</s>
<s>
In	O
a	O
similar	O
manner	O
,	O
the	O
performance	O
of	O
the	O
equivalent	O
natively	O
compiled	O
program	O
will	O
depend	O
on	O
the	O
quality	O
of	O
its	O
generated	O
machine	B-Language
code	I-Language
,	O
so	O
the	O
test	O
or	O
comparison	O
also	O
has	O
to	O
report	O
the	O
name	O
,	O
version	O
and	O
vendor	O
of	O
the	O
used	O
compiler	O
,	O
and	O
its	O
activated	O
compiler	B-Application
optimization	I-Application
directives	O
.	O
</s>
<s>
Many	O
optimizations	O
have	O
improved	O
the	O
performance	O
of	O
the	O
JVM	B-Language
over	O
time	O
.	O
</s>
<s>
However	O
,	O
although	O
Java	B-Language
was	O
often	O
the	O
first	O
virtual	B-Architecture
machine	I-Architecture
to	O
implement	O
them	O
successfully	O
,	O
they	O
have	O
often	O
been	O
used	O
in	O
other	O
similar	O
platforms	B-Device
as	O
well	O
.	O
</s>
<s>
Early	O
JVMs	B-Language
always	O
interpreted	O
Java	B-Language
bytecodes	I-Language
.	O
</s>
<s>
This	O
had	O
a	O
large	O
performance	O
penalty	O
of	O
between	O
a	O
factor	O
10	O
and	O
20	O
for	O
Java	B-Language
versus	O
C	B-Language
in	O
average	O
applications	O
.	O
</s>
<s>
To	O
combat	O
this	O
,	O
a	O
just-in-time	O
(	O
JIT	O
)	O
compiler	O
was	O
introduced	O
into	O
Java	B-Language
1.1	O
.	O
</s>
<s>
Due	O
to	O
the	O
high	O
cost	O
of	O
compiling	O
,	O
an	O
added	O
system	O
called	O
HotSpot	B-Language
was	O
introduced	O
in	O
Java	B-Language
1.2	O
and	O
was	O
made	O
the	O
default	O
in	O
Java	B-Language
1.3	O
.	O
</s>
<s>
Using	O
this	O
framework	O
,	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
continually	O
analyses	O
program	O
performance	O
for	O
hot	O
spots	O
which	O
are	O
executed	O
frequently	O
or	O
repeatedly	O
.	O
</s>
<s>
However	O
,	O
due	O
to	O
time	O
constraints	O
,	O
the	O
compiler	O
cannot	O
fully	O
optimize	O
the	O
program	O
,	O
and	O
thus	O
the	O
resulting	O
program	O
is	O
slower	O
than	O
native	B-Language
code	I-Language
alternatives	O
.	O
</s>
<s>
A	O
Java	B-Language
virtual	I-Language
machine	I-Language
like	O
HotSpot	B-Language
can	O
also	O
deoptimize	O
code	O
formerly	O
JITed	O
.	O
</s>
<s>
The	O
1.0	O
and	O
1.1	O
Java	B-Language
virtual	I-Language
machines	I-Language
(	O
JVMs	B-Language
)	O
used	O
a	O
mark-sweep	O
collector	O
,	O
which	O
could	O
fragment	O
the	O
heap	O
after	O
a	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Starting	O
with	O
Java	B-Language
1.2	O
,	O
the	O
JVMs	B-Language
changed	O
to	O
a	O
generational	O
collector	O
,	O
which	O
has	O
a	O
much	O
better	O
defragmentation	O
behaviour	O
.	O
</s>
<s>
Modern	O
JVMs	B-Language
use	O
a	O
variety	O
of	O
methods	B-Language
that	O
have	O
further	O
improved	O
garbage	B-General_Concept
collection	I-General_Concept
performance	O
.	O
</s>
<s>
Compressed	O
Oops	O
allow	O
Java	B-Language
5.0	O
+	O
to	O
address	O
up	O
to	O
32	O
GB	O
of	O
heap	O
with	O
32-bit	O
references	O
.	O
</s>
<s>
Java	B-Language
does	O
not	O
support	O
access	O
to	O
individual	O
bytes	O
,	O
only	O
objects	O
which	O
are	O
8-byte	O
aligned	O
by	O
default	O
.	O
</s>
<s>
This	O
significantly	O
reduces	O
memory	O
use	O
compared	O
to	O
using	O
64-bit	O
references	O
as	O
Java	B-Language
uses	O
references	O
much	O
more	O
than	O
some	O
languages	O
like	O
C++	B-Language
.	O
</s>
<s>
Java	B-Language
8	O
supports	O
larger	O
alignments	O
such	O
as	O
16-byte	O
alignment	O
to	O
support	O
up	O
to	O
64	O
GB	O
with	O
32-bit	O
references	O
.	O
</s>
<s>
Before	O
executing	O
a	O
class	O
,	O
the	O
Sun	O
JVM	B-Language
verifies	O
its	O
Java	B-Language
bytecodes	I-Language
(	O
see	O
bytecode	O
verifier	O
)	O
.	O
</s>
<s>
However	O
,	O
as	O
the	O
Java	B-Library
class	I-Library
libraries	I-Library
are	O
also	O
regular	O
Java	B-Language
classes	O
,	O
they	O
must	O
also	O
be	O
loaded	O
when	O
they	O
are	O
used	O
,	O
which	O
means	O
that	O
the	O
start-up	O
time	O
of	O
a	O
Java	B-Language
program	O
is	O
often	O
longer	O
than	O
for	O
C++	B-Language
programs	I-Language
,	O
for	O
example	O
.	O
</s>
<s>
A	O
method	O
named	O
split-time	O
verification	O
,	O
first	O
introduced	O
in	O
the	O
Java	B-Language
Platform	I-Language
,	I-Language
Micro	I-Language
Edition	I-Language
(	O
J2ME	B-Language
)	O
,	O
is	O
used	O
in	O
the	O
JVM	B-Language
since	O
Java	B-Language
version	O
6	O
.	O
</s>
<s>
It	O
splits	O
the	O
verification	O
of	O
Java	B-Language
bytecode	I-Language
in	O
two	O
phases	O
:	O
</s>
<s>
In	O
practice	O
this	O
method	O
works	O
by	O
capturing	O
knowledge	O
that	O
the	O
Java	B-Language
compiler	O
has	O
of	O
class	O
flow	O
and	O
annotating	O
the	O
compiled	O
method	O
bytecodes	O
with	O
a	O
synopsis	O
of	O
the	O
class	O
flow	O
information	O
.	O
</s>
<s>
This	O
does	O
not	O
make	O
runtime	B-Application
verification	I-Application
appreciably	O
less	O
complex	O
,	O
but	O
does	O
allow	O
some	O
shortcuts	O
.	O
</s>
<s>
Java	B-Language
is	O
able	O
to	O
manage	O
multithreading	B-Operating_System
at	O
the	O
language	O
level	O
.	O
</s>
<s>
Multithreading	B-Operating_System
is	O
a	O
method	O
allowing	O
programs	O
to	O
perform	O
multiple	O
processes	O
concurrently	O
,	O
thus	O
producing	O
faster	O
programs	O
on	O
computer	O
systems	O
with	O
multiple	O
processors	O
or	O
cores	O
.	O
</s>
<s>
However	O
,	O
programs	O
that	O
use	O
multithreading	B-Operating_System
need	O
to	O
take	O
extra	O
care	O
of	O
objects	O
shared	O
between	O
threads	B-Operating_System
,	O
locking	B-Operating_System
access	O
to	O
shared	O
methods	B-Language
or	O
blocks	O
when	O
they	O
are	O
used	O
by	O
one	O
of	O
the	O
threads	B-Operating_System
.	O
</s>
<s>
Locking	B-Operating_System
a	O
block	O
or	O
an	O
object	O
is	O
a	O
time-consuming	O
operation	O
due	O
to	O
the	O
nature	O
of	O
the	O
underlying	O
operating	O
system-level	O
operation	O
involved	O
(	O
see	O
concurrency	B-Operating_System
control	I-Operating_System
and	O
lock	O
granularity	O
)	O
.	O
</s>
<s>
As	O
the	O
Java	B-Language
library	O
does	O
not	O
know	O
which	O
methods	B-Language
will	O
be	O
used	O
by	O
more	O
than	O
one	O
thread	B-Operating_System
,	O
the	O
standard	O
library	O
always	O
locks	O
blocks	O
when	O
needed	O
in	O
a	O
multithreaded	O
environment	O
.	O
</s>
<s>
Before	O
Java	B-Language
6	O
,	O
the	O
virtual	B-Architecture
machine	I-Architecture
always	O
locked	B-Operating_System
objects	O
and	O
blocks	O
when	O
asked	O
to	O
by	O
the	O
program	O
,	O
even	O
if	O
there	O
was	O
no	O
risk	O
of	O
an	O
object	O
being	O
modified	O
by	O
two	O
different	O
threads	B-Operating_System
at	O
once	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
this	O
case	O
,	O
a	O
local	O
was	O
locked	B-Operating_System
before	O
each	O
of	O
the	O
add	O
operations	O
to	O
ensure	O
that	O
it	O
would	O
not	O
be	O
modified	O
by	O
other	O
threads	B-Operating_System
(	O
vector	O
is	O
synchronized	O
)	O
,	O
but	O
because	O
it	O
is	O
strictly	O
local	O
to	O
the	O
method	O
this	O
is	O
needless	O
:	O
</s>
<s>
Starting	O
with	O
Java	B-Language
6	O
,	O
code	O
blocks	O
and	O
objects	O
are	O
locked	B-Operating_System
only	O
when	O
needed	O
,	O
so	O
in	O
the	O
above	O
case	O
,	O
the	O
virtual	B-Architecture
machine	I-Architecture
would	O
not	O
lock	O
the	O
Vector	O
object	O
at	O
all	O
.	O
</s>
<s>
Since	O
version	O
6u23	O
,	O
Java	B-Language
includes	O
support	O
for	O
escape	O
analysis	O
.	O
</s>
<s>
Before	O
Java	B-Language
6	O
,	O
allocation	O
of	O
registers	O
was	O
very	O
primitive	O
in	O
the	O
client	O
virtual	B-Architecture
machine	I-Architecture
(	O
they	O
did	O
not	O
live	O
across	O
blocks	O
)	O
,	O
which	O
was	O
a	O
problem	O
in	O
CPU	B-General_Concept
designs	I-General_Concept
which	O
had	O
fewer	O
processor	B-General_Concept
registers	I-General_Concept
available	O
,	O
as	O
in	O
x86s	B-Operating_System
.	O
</s>
<s>
However	O
,	O
the	O
server	O
virtual	B-Architecture
machine	I-Architecture
used	O
a	O
color-graph	O
allocator	B-Application
and	O
did	O
not	O
have	O
this	O
problem	O
.	O
</s>
<s>
Class	O
data	O
sharing	O
(	O
called	O
CDS	O
by	O
Sun	O
)	O
is	O
a	O
mechanism	O
which	O
reduces	O
the	O
startup	O
time	O
for	O
Java	B-Language
applications	O
,	O
and	O
also	O
reduces	O
memory	O
footprint	O
.	O
</s>
<s>
When	O
the	O
JRE	O
is	O
installed	O
,	O
the	O
installer	O
loads	O
a	O
set	O
of	O
classes	O
from	O
the	O
system	O
JAR	B-Language
file	I-Language
(	O
the	O
JAR	B-Language
file	I-Language
holding	O
all	O
the	O
Java	B-Library
class	I-Library
library	I-Library
,	O
called	O
rt.jar	O
)	O
into	O
a	O
private	O
internal	O
representation	O
,	O
and	O
dumps	O
that	O
representation	O
to	O
a	O
file	O
,	O
called	O
a	O
"	O
shared	O
archive	O
"	O
.	O
</s>
<s>
During	O
subsequent	O
JVM	B-Language
invocations	O
,	O
this	O
shared	O
archive	O
is	O
memory-mapped	B-General_Concept
in	O
,	O
saving	O
the	O
cost	O
of	O
loading	O
those	O
classes	O
and	O
allowing	O
much	O
of	O
the	O
JVM	B-Language
's	O
metadata	O
for	O
these	O
classes	O
to	O
be	O
shared	O
among	O
multiple	O
JVM	B-Language
processes	O
.	O
</s>
<s>
Apart	O
from	O
the	O
improvements	O
listed	O
here	O
,	O
each	O
release	O
of	O
Java	B-Language
introduced	O
many	O
performance	O
improvements	O
in	O
the	O
JVM	B-Language
and	O
Java	B-Language
application	B-Application
programming	I-Application
interface	I-Application
(	O
API	B-General_Concept
)	O
.	O
</s>
<s>
J2SE	O
1.3	O
:	O
Just-in-time	O
compiling	O
by	O
HotSpot	B-Language
.	O
</s>
<s>
Java	B-Language
SE	O
6	O
:	O
</s>
<s>
See	O
also	O
'	O
Sun	O
overview	O
of	O
performance	O
improvements	O
between	O
Java	B-Language
5	O
and	O
Java	B-Language
6	O
 '	O
.	O
</s>
<s>
Java	B-Language
Quick	O
Starter	O
reduces	O
application	O
start-up	O
time	O
by	O
preloading	O
part	O
of	O
JRE	O
data	O
at	O
OS	O
startup	O
on	O
disk	B-General_Concept
cache	I-General_Concept
.	O
</s>
<s>
Parts	O
of	O
the	O
platform	B-Device
needed	O
to	O
execute	O
an	O
application	O
accessed	O
from	O
the	O
web	O
when	O
JRE	O
is	O
not	O
installed	O
are	O
now	O
downloaded	O
first	O
.	O
</s>
<s>
The	O
full	O
JRE	O
is	O
12	O
MB	O
,	O
a	O
typical	O
Swing	B-Language
application	O
only	O
needs	O
to	O
download	O
4	O
MB	O
to	O
start	O
.	O
</s>
<s>
Graphics	O
performance	O
on	O
Windows	B-Application
improved	O
by	O
extensively	O
using	O
Direct3D	B-Application
by	O
default	O
,	O
and	O
use	O
shaders	O
on	O
graphics	B-Architecture
processing	I-Architecture
unit	I-Architecture
(	O
GPU	B-Architecture
)	O
to	O
accelerate	O
complex	O
Java	B-Language
2D	I-Language
operations	O
.	O
</s>
<s>
Several	O
performance	O
improvements	O
have	O
been	O
released	O
for	O
Java	B-Language
7	O
:	O
</s>
<s>
Future	O
performance	O
improvements	O
are	O
planned	O
for	O
an	O
update	O
of	O
Java	B-Language
6	O
or	O
Java	B-Language
7	O
:	O
</s>
<s>
Provide	O
JVM	B-Language
support	O
for	O
dynamic	B-Language
programming	I-Language
languages	I-Language
,	O
following	O
the	O
prototyping	O
work	O
currently	O
done	O
on	O
the	O
Da	B-Application
Vinci	I-Application
Machine	I-Application
(	O
Multi	B-Application
Language	I-Application
Virtual	I-Application
Machine	I-Application
)	O
,	O
</s>
<s>
Enhance	O
the	O
existing	O
concurrency	O
library	O
by	O
managing	O
parallel	B-Operating_System
computing	I-Operating_System
on	O
multi-core	B-Architecture
processors	I-Architecture
,	O
</s>
<s>
Allow	O
the	O
JVM	B-Language
to	O
use	O
both	O
the	O
client	O
and	O
server	O
JIT	O
compilers	O
in	O
the	O
same	O
session	O
with	O
a	O
method	O
called	O
tiered	O
compiling	O
:	O
</s>
<s>
Replace	O
the	O
existing	O
concurrent	B-Operating_System
low-pause	O
garbage	B-General_Concept
collector	I-General_Concept
(	O
also	O
called	O
concurrent	B-Operating_System
mark-sweep	O
(	O
CMS	O
)	O
collector	O
)	O
by	O
a	O
new	O
collector	O
called	O
Garbage	O
First	O
(	O
G1	O
)	O
to	O
ensure	O
consistent	O
pauses	O
over	O
time	O
.	O
</s>
<s>
Objectively	O
comparing	O
the	O
performance	O
of	O
a	O
Java	B-Language
program	O
and	O
an	O
equivalent	O
one	O
written	O
in	O
another	O
language	O
such	O
as	O
C++	B-Language
needs	O
a	O
carefully	O
and	O
thoughtfully	O
constructed	O
benchmark	O
which	O
compares	O
programs	O
completing	O
identical	O
tasks	O
.	O
</s>
<s>
The	O
target	O
platform	B-Device
of	O
Java	B-Language
's	O
bytecode	O
compiler	O
is	O
the	O
Java	B-Device
platform	I-Device
,	O
and	O
the	O
bytecode	O
is	O
either	O
interpreted	O
or	O
compiled	O
into	O
machine	B-Language
code	I-Language
by	O
the	O
JVM	B-Language
.	O
</s>
<s>
Other	O
compilers	O
almost	O
always	O
target	O
a	O
specific	O
hardware	B-Architecture
and	O
software	B-Device
platform	I-Device
,	O
producing	O
machine	B-Language
code	I-Language
that	O
will	O
stay	O
virtually	O
unchanged	O
during	O
execution	O
.	O
</s>
<s>
Very	O
different	O
and	O
hard-to-compare	O
scenarios	O
arise	O
from	O
these	O
two	O
different	O
approaches	O
:	O
static	O
vs.	O
dynamic	B-Application
compilations	I-Application
and	O
recompilations	O
,	O
the	O
availability	O
of	O
precise	O
information	O
about	O
the	O
runtime	O
environment	O
and	O
others	O
.	O
</s>
<s>
Java	B-Language
is	O
often	O
compiled	O
just-in-time	O
at	O
runtime	O
by	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
,	O
but	O
may	O
also	O
be	O
compiled	B-Application
ahead-of-time	I-Application
,	O
as	O
is	O
C++	B-Language
.	O
</s>
<s>
slower	O
than	O
compiled	O
languages	O
such	O
as	O
C	B-Language
or	O
C++	B-Language
,	O
</s>
<s>
similar	O
to	O
other	O
just-in-time	O
compiled	O
languages	O
such	O
as	O
C#	B-Application
,	O
</s>
<s>
much	O
faster	O
than	O
languages	O
without	O
an	O
effective	O
native-code	O
compiler	O
(	O
JIT	O
or	O
AOT	B-Application
)	O
,	O
such	O
as	O
Perl	B-Language
,	O
Ruby	B-Language
,	O
PHP	B-Application
and	O
Python	B-Language
.	O
</s>
<s>
In	O
some	O
rare	O
real-life	O
programs	O
,	O
Java	B-Language
out-performs	O
C	B-Language
.	O
One	O
example	O
is	O
the	O
benchmark	O
of	O
Jake2	B-Language
(	O
a	O
clone	O
of	O
Quake	B-Application
II	I-Application
written	O
in	O
Java	B-Language
by	O
translating	O
the	O
original	O
GPL	B-License
C	B-Language
code	O
)	O
.	O
</s>
<s>
The	O
Java	B-Language
5.0	O
version	O
performs	O
better	O
in	O
some	O
hardware	B-Architecture
configurations	O
than	O
its	O
C	B-Language
counterpart	O
.	O
</s>
<s>
While	O
it	O
is	O
not	O
specified	O
how	O
the	O
data	O
was	O
measured	O
(	O
for	O
example	O
if	O
the	O
original	O
Quake	B-Application
II	I-Application
executable	O
compiled	O
in	O
1997	O
was	O
used	O
,	O
which	O
may	O
be	O
considered	O
bad	O
as	O
current	O
C	B-Language
compilers	O
may	O
achieve	O
better	O
optimizations	O
for	O
Quake	O
)	O
,	O
it	O
notes	O
how	O
the	O
same	O
Java	B-Language
source	I-Language
code	I-Language
can	O
have	O
a	O
huge	O
speed	O
boost	O
just	O
by	O
updating	O
the	O
VM	O
,	O
something	O
impossible	O
to	O
achieve	O
with	O
a	O
100%	O
static	O
approach	O
.	O
</s>
<s>
For	O
other	O
programs	O
,	O
the	O
C++	B-Language
counterpart	O
can	O
,	O
and	O
usually	O
does	O
,	O
run	O
significantly	O
faster	O
than	O
the	O
Java	B-Language
equivalent	O
.	O
</s>
<s>
A	O
benchmark	O
performed	O
by	O
Google	O
in	O
2011	O
showed	O
a	O
factor	O
10	O
between	O
C++	B-Language
and	O
Java	B-Language
.	O
</s>
<s>
At	O
the	O
other	O
extreme	O
,	O
an	O
academic	O
benchmark	O
performed	O
in	O
2012	O
with	O
a	O
3D	O
modelling	O
algorithm	O
showed	O
the	O
Java	B-Language
6	O
JVM	B-Language
being	O
from	O
1.09	O
to	O
1.91	O
times	O
slower	O
than	O
C++	B-Language
under	O
Windows	B-Application
.	O
</s>
<s>
Some	O
optimizations	O
that	O
are	O
possible	O
in	O
Java	B-Language
and	O
similar	O
languages	O
may	O
not	O
be	O
possible	O
in	O
certain	O
circumstances	O
in	O
C++	B-Language
:	O
</s>
<s>
C-style	O
pointer	O
use	O
can	O
hinder	O
optimizing	O
in	O
languages	O
that	O
support	O
pointers	O
,	O
</s>
<s>
The	O
use	O
of	O
escape	O
analysis	O
methods	B-Language
is	O
limited	O
in	O
C++	B-Language
,	O
for	O
example	O
,	O
because	O
a	O
C++	B-Language
compiler	O
does	O
not	O
always	O
know	O
if	O
an	O
object	O
will	O
be	O
modified	O
in	O
a	O
given	O
block	O
of	O
code	O
due	O
to	O
pointers	O
,	O
</s>
<s>
Java	B-Language
can	O
access	O
derived	O
instance	B-Language
methods	I-Language
faster	O
than	O
C++	B-Language
can	O
access	O
derived	O
virtual	B-Application
methods	I-Application
due	O
to	O
C++'s	O
extra	O
virtual-table	O
look-up	O
.	O
</s>
<s>
However	O
,	O
non-virtual	O
methods	O
in	O
C++	B-Language
do	O
not	O
suffer	O
from	O
v-table	O
performance	O
bottlenecks	O
,	O
and	O
thus	O
exhibit	O
performance	O
similar	O
to	O
Java	B-Language
.	O
</s>
<s>
The	O
JVM	B-Language
is	O
also	O
able	O
to	O
perform	O
processor	O
specific	O
optimizations	O
or	O
inline	O
expansion	O
.	O
</s>
<s>
Results	O
for	O
microbenchmarks	O
between	O
Java	B-Language
and	O
C++	B-Language
highly	O
depend	O
on	O
which	O
operations	O
are	O
compared	O
.	O
</s>
<s>
For	O
example	O
,	O
when	O
comparing	O
with	O
Java	B-Language
5.0	O
:	O
</s>
<s>
Arrays	O
operations	O
performance	O
are	O
better	O
in	O
C	B-Language
.	O
</s>
<s>
Trigonometric	O
functions	O
performance	O
is	O
much	O
better	O
in	O
C	B-Language
.	O
</s>
<s>
The	O
scalability	O
and	O
performance	O
of	O
Java	B-Language
applications	O
on	O
multi-core	B-Architecture
systems	O
is	O
limited	O
by	O
the	O
object	O
allocation	O
rate	O
.	O
</s>
<s>
However	O
,	O
in	O
practice	O
,	O
modern	O
garbage	B-General_Concept
collector	I-General_Concept
algorithms	O
use	O
multiple	O
cores	O
to	O
perform	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
which	O
to	O
some	O
degree	O
alleviates	O
this	O
problem	O
.	O
</s>
<s>
Some	O
garbage	B-General_Concept
collectors	I-General_Concept
are	O
reported	O
to	O
sustain	O
allocation	O
rates	O
of	O
over	O
a	O
gigabyte	O
per	O
second	O
,	O
and	O
there	O
exist	O
Java-based	O
systems	O
that	O
have	O
no	O
problems	O
scaling	O
to	O
several	O
hundreds	O
of	O
CPU	B-Architecture
cores	I-Architecture
and	O
heaps	O
sized	O
several	O
hundreds	O
of	O
GB	O
.	O
</s>
<s>
Automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
in	O
Java	B-Language
allows	O
for	O
efficient	O
use	O
of	O
lockless	O
and	O
immutable	O
data	O
structures	O
that	O
are	O
extremely	O
hard	O
or	O
sometimes	O
impossible	O
to	O
implement	O
without	O
some	O
kind	O
of	O
a	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Java	B-Language
offers	O
a	O
number	O
of	O
such	O
high-level	O
structures	O
in	O
its	O
standard	O
library	O
in	O
the	O
java.util.concurrent	O
package	O
,	O
while	O
many	O
languages	O
historically	O
used	O
for	O
high	O
performance	O
systems	O
like	O
C	B-Language
or	O
C++	B-Language
are	O
still	O
lacking	O
them	O
.	O
</s>
<s>
Java	B-Language
startup	O
time	O
is	O
often	O
much	O
slower	O
than	O
many	O
languages	O
,	O
including	O
C	B-Language
,	O
C++	B-Language
,	O
Perl	B-Language
or	O
Python	B-Language
,	O
because	O
many	O
classes	O
(	O
and	O
first	O
of	O
all	O
classes	O
from	O
the	O
platform	B-Device
Class	O
libraries	O
)	O
must	O
be	O
loaded	O
before	O
being	O
used	O
.	O
</s>
<s>
When	O
compared	O
against	O
similar	O
popular	O
runtimes	O
,	O
for	O
small	O
programs	O
running	O
on	O
a	O
Windows	B-Application
machine	O
,	O
the	O
startup	O
time	O
appears	O
to	O
be	O
similar	O
to	O
Mono	B-Application
's	I-Application
and	O
a	O
little	O
slower	O
than	O
.NET	B-Application
'	I-Application
s	I-Application
.	O
</s>
<s>
It	O
seems	O
that	O
much	O
of	O
the	O
startup	O
time	O
is	O
due	O
to	O
input-output	B-General_Concept
(	O
IO	O
)	O
bound	O
operations	O
rather	O
than	O
JVM	B-Language
initialization	O
or	O
class	O
loading	O
(	O
the	O
rt.jar	O
class	O
data	O
file	O
alone	O
is	O
40	O
MB	O
and	O
the	O
JVM	B-Language
must	O
seek	O
much	O
data	O
in	O
this	O
big	O
file	O
)	O
.	O
</s>
<s>
Albeit	O
a	O
small	O
improvement	O
,	O
it	O
is	O
more	O
visible	O
in	O
small	O
programs	O
that	O
perform	O
a	O
simple	O
operation	O
and	O
then	O
exit	O
,	O
because	O
the	O
Java	B-Device
platform	I-Device
data	O
loading	O
can	O
represent	O
many	O
times	O
the	O
load	O
of	O
the	O
actual	O
program	O
's	O
operation	O
.	O
</s>
<s>
Starting	O
with	O
Java	B-Language
SE	O
6	O
Update	O
10	O
,	O
the	O
Sun	O
JRE	O
comes	O
with	O
a	O
Quick	O
Starter	O
that	O
preloads	O
class	O
data	O
at	O
OS	O
startup	O
to	O
get	O
data	O
from	O
the	O
disk	B-General_Concept
cache	I-General_Concept
rather	O
than	O
from	O
the	O
disk	O
.	O
</s>
<s>
Excelsior	B-Language
JET	I-Language
approaches	O
the	O
problem	O
from	O
the	O
other	O
side	O
.	O
</s>
<s>
In	O
November	O
2004	O
,	O
Nailgun	O
,	O
a	O
"	O
client	O
,	O
protocol	O
,	O
and	O
server	O
for	O
running	O
Java	B-Language
programs	O
from	O
the	O
command	O
line	O
without	O
incurring	O
the	O
JVM	B-Language
startup	O
overhead	O
"	O
was	O
publicly	O
released	O
.	O
</s>
<s>
introducing	O
for	O
the	O
first	O
time	O
an	O
option	O
for	O
scripts	B-Language
to	O
use	O
a	O
JVM	B-Language
as	O
a	O
daemon	B-Operating_System
,	O
for	O
running	O
one	O
or	O
more	O
Java	B-Language
applications	O
with	O
no	O
JVM	B-Language
startup	O
overhead	O
.	O
</s>
<s>
The	O
Nailgun	O
daemon	B-Operating_System
is	O
insecure	O
:	O
"	O
all	O
programs	O
are	O
run	O
with	O
the	O
same	O
permissions	O
as	O
the	O
server	O
"	O
.	O
</s>
<s>
Where	O
multi-user	B-Operating_System
security	O
is	O
needed	O
,	O
Nailgun	O
is	O
inappropriate	O
without	O
special	O
precautions	O
.	O
</s>
<s>
Scripts	B-Language
where	O
per-application	O
JVM	B-Language
startup	O
dominates	O
resource	O
use	O
,	O
see	O
one	O
to	O
two	O
order	O
of	O
magnitude	O
runtime	O
performance	O
improvements	O
.	O
</s>
<s>
Java	B-Language
memory	O
use	O
is	O
much	O
higher	O
than	O
C++'s	O
memory	O
use	O
because	O
:	O
</s>
<s>
There	O
is	O
an	O
overhead	O
of	O
8	O
bytes	O
for	O
each	O
object	O
and	O
12	O
bytes	O
for	O
each	O
array	O
in	O
Java	B-Language
.	O
</s>
<s>
C++	B-Language
also	O
allocates	O
a	O
pointer	O
(	O
usually	O
4	O
or	O
8	O
bytes	O
)	O
for	O
every	O
object	O
which	O
class	O
directly	O
or	O
indirectly	O
declares	O
virtual	B-Application
functions	I-Application
.	O
</s>
<s>
Lack	O
of	O
address	O
arithmetic	O
makes	O
creating	O
memory-efficient	O
containers	O
,	O
such	O
as	O
tightly	O
spaced	O
structures	O
and	O
XOR	B-Data_Structure
linked	I-Data_Structure
lists	I-Data_Structure
,	O
currently	O
impossible	O
(	O
the	B-Language
OpenJDK	I-Language
Valhalla	I-Language
project	I-Language
aims	O
to	O
mitigate	O
these	O
issues	O
,	O
though	O
it	O
does	O
not	O
aim	O
to	O
introduce	O
pointer	O
arithmetic	O
;	O
this	O
cannot	O
be	O
done	O
in	O
a	O
garbage	B-General_Concept
collected	I-General_Concept
environment	O
)	O
.	O
</s>
<s>
Contrary	O
to	O
malloc	O
and	O
new	O
,	O
the	O
average	O
performance	O
overhead	O
of	O
garbage	B-General_Concept
collection	I-General_Concept
asymptotically	O
nears	O
zero	O
(	O
more	O
accurately	O
,	O
one	O
CPU	O
cycle	O
)	O
as	O
the	O
heap	O
size	O
increases	O
.	O
</s>
<s>
Parts	O
of	O
the	O
Java	B-Library
Class	I-Library
Library	I-Library
must	O
load	O
before	O
program	O
execution	O
(	O
at	O
least	O
the	O
classes	O
used	O
within	O
a	O
program	O
)	O
.	O
</s>
<s>
Both	O
the	O
Java	B-Language
binary	O
and	O
native	O
recompilations	O
will	O
typically	O
be	O
in	O
memory	O
.	O
</s>
<s>
The	O
virtual	B-Architecture
machine	I-Architecture
uses	O
substantial	O
memory	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
a	O
composite	O
object	O
(	O
class	O
A	O
which	O
uses	O
instances	O
of	O
B	O
and	O
C	B-Language
)	O
is	O
created	O
using	O
references	O
to	O
allocated	O
instances	O
of	O
B	O
and	O
C	B-Language
.	O
In	O
C++	B-Language
the	O
memory	O
and	O
performance	O
cost	O
of	O
these	O
types	O
of	O
references	O
can	O
be	O
avoided	O
when	O
the	O
instance	O
of	O
B	O
and/or	O
C	B-Language
exists	O
within	O
A	O
.	O
</s>
<s>
In	O
most	O
cases	O
a	O
C++	B-Language
application	O
will	O
consume	O
less	O
memory	O
than	O
an	O
equivalent	O
Java	B-Language
application	O
due	O
to	O
the	O
large	O
overhead	O
of	O
Java	B-Language
's	O
virtual	B-Architecture
machine	I-Architecture
,	O
class	O
loading	O
and	O
automatic	O
memory	O
resizing	O
.	O
</s>
<s>
Performance	O
of	O
trigonometric	O
functions	O
is	O
bad	O
compared	O
to	O
C	B-Language
,	O
because	O
Java	B-Language
has	O
strict	O
specifications	O
for	O
the	O
results	O
of	O
mathematical	O
operations	O
,	O
which	O
may	O
not	O
correspond	O
to	O
the	O
underlying	O
hardware	B-Architecture
implementation	O
.	O
</s>
<s>
On	O
the	O
x87	B-Application
floating	O
point	O
subset	O
,	O
Java	B-Language
since	O
1.4	O
does	O
argument	O
reduction	O
for	O
sin	O
and	O
cos	O
in	O
software	O
,	O
causing	O
a	O
big	O
performance	O
hit	O
for	O
values	O
outside	O
the	O
range	O
.	O
</s>
<s>
The	O
Java	B-Language
Native	I-Language
Interface	I-Language
invokes	O
a	O
high	O
overhead	O
,	O
making	O
it	O
costly	O
to	O
cross	O
the	O
boundary	O
between	O
code	O
running	O
on	O
the	O
JVM	B-Language
and	O
native	B-Language
code	I-Language
.	O
</s>
<s>
Java	B-Language
Native	I-Language
Access	I-Language
(	O
JNA	O
)	O
provides	O
Java	B-Language
programs	O
easy	O
access	O
to	O
native	O
shared	O
libraries	O
(	O
dynamic-link	O
library	O
(	O
DLLs	O
)	O
on	O
Windows	B-Application
)	O
via	O
Java	B-Language
code	I-Language
only	O
,	O
with	O
no	O
JNI	B-Language
or	O
native	B-Language
code	I-Language
.	O
</s>
<s>
This	O
functionality	O
is	O
comparable	O
to	O
Windows	B-Application
 '	O
Platform/Invoke	O
and	O
Python	B-Language
's	I-Language
ctypes	O
.	O
</s>
<s>
But	O
it	O
has	O
a	O
cost	O
,	O
and	O
JNA	O
is	O
usually	O
slower	O
than	O
JNI	B-Language
.	O
</s>
<s>
Swing	B-Language
has	O
been	O
perceived	O
as	O
slower	O
than	O
native	O
widget	B-Library
toolkits	I-Library
,	O
because	O
it	O
delegates	O
the	O
rendering	O
of	O
widgets	O
to	O
the	O
pure	O
Java	B-Language
2D	I-Language
API	B-General_Concept
.	O
</s>
<s>
However	O
,	O
benchmarks	O
comparing	O
the	O
performance	O
of	O
Swing	B-Language
versus	O
the	O
Standard	B-Application
Widget	I-Application
Toolkit	I-Application
,	O
which	O
delegates	O
the	O
rendering	O
to	O
the	O
native	O
GUI	O
libraries	O
of	O
the	O
operating	B-General_Concept
system	I-General_Concept
,	O
show	O
no	O
clear	O
winner	O
,	O
and	O
the	O
results	O
greatly	O
depend	O
on	O
the	O
context	O
and	O
the	O
environments	O
.	O
</s>
<s>
Additionally	O
,	O
the	O
newer	O
JavaFX	B-Application
framework	O
,	O
intended	O
to	O
replace	O
Swing	B-Language
,	O
addresses	O
many	O
of	O
Swing	B-Language
's	O
inherent	O
issues	O
.	O
</s>
<s>
Some	O
people	O
believe	O
that	O
Java	B-Application
performance	I-Application
for	O
high	B-Architecture
performance	I-Architecture
computing	I-Architecture
(	O
HPC	O
)	O
is	O
similar	O
to	O
Fortran	B-Application
on	O
compute-intensive	O
benchmarks	O
,	O
but	O
that	O
JVMs	B-Language
still	O
have	O
scalability	O
issues	O
for	O
performing	O
intensive	O
communication	O
on	O
a	O
grid	B-Architecture
computing	I-Architecture
network	O
.	O
</s>
<s>
However	O
,	O
high	B-Architecture
performance	I-Architecture
computing	I-Architecture
applications	O
written	O
in	O
Java	B-Language
have	O
won	O
benchmark	O
competitions	O
.	O
</s>
<s>
In	O
2008	O
,	O
and	O
2009	O
,	O
an	O
Apache	B-Application
Hadoop	I-Application
(	O
an	O
open-source	O
high	B-Architecture
performance	I-Architecture
computing	I-Architecture
project	O
written	O
in	O
Java	B-Language
)	O
based	O
cluster	O
was	O
able	O
to	O
sort	O
a	O
terabyte	O
and	O
petabyte	O
of	O
integers	O
the	O
fastest	O
.	O
</s>
<s>
The	O
hardware	B-Architecture
setup	O
of	O
the	O
competing	O
systems	O
was	O
not	O
fixed	O
,	O
however	O
.	O
</s>
<s>
Programs	O
in	O
Java	B-Language
start	O
slower	O
than	O
those	O
in	O
other	O
compiled	O
languages	O
.	O
</s>
<s>
Thus	O
,	O
some	O
online	O
judge	O
systems	O
,	O
notably	O
those	O
hosted	O
by	O
Chinese	O
universities	O
,	O
use	O
longer	O
time	O
limits	O
for	O
Java	B-Language
programs	O
to	O
be	O
fair	O
to	O
contestants	O
using	O
Java	B-Language
.	O
</s>
