Java performance: Difference between revisions

Content deleted Content added
Fixed grammar, fixed formatting
Line 38:
| publisher=[[Intel Corporation]]
| access-date=June 22, 2007}}</ref>
Some benchmarks show a 10-fold speed gain by this means.<ref>This [http://www.shudo.net/jit/perf/ article] shows that the performance gain between interpreted mode and Hotspot amounts to more than a factor of 10.</ref> However, due to time constraints, the compiler cannot fully optimize the program, and thus the resulting program is slower than native code alternatives.<ref>[http://www.itu.dk/~sestoft/papers/numericperformance.pdf Numeric performance in C, C# and Java ]</ref><ref>[http://www.cherrystonesoftware.com/doc/AlgorithmicPerformance.pdf Algorithmic Performance Comparison Between C, C++, Java and C# Programming Languages] {{webarchive|url=https://web.archive.org/web/20100331155325/http://www.cherrystonesoftware.com/doc/AlgorithmicPerformance.pdf |date=March 31, 2010 }}</ref>
 
===Adaptive optimizing===
Line 83:
====Escape analysis and lock coarsening====
{{Further|Lock (computer science)|Escape analysis}}
Java is able to manage [[Thread (computer science)|multithreading]] at the language level. Multithreading is a method allowingallows programs to perform multiple processes concurrently, thus producingimproving fasterthe performance for programs running on [[computer system]]s with multiple processors or cores. Also, a multithreaded application can remain responsive to input, even while performing long running tasks.
 
However, programs that use multithreading need to take extra care of [[Object (computer science)|objects]] shared between threads, locking access to shared [[Method (computer science)|methods]] or [[block (programming)|blocks]] when they are used by one of the threads. Locking a block or an object is a time-consuming operation due to the nature of the underlying [[operating system]]-level operation involved (see [[concurrency control]] and [[Lock (computer science)#Granularity|lock granularity]]).
Line 117:
Before [[Java version history|Java 6]], [[Register allocation|allocation of registers]] was very primitive in the ''client'' virtual machine (they did not live across [[Block (programming)|blocks]]), which was a problem in [[CPU design]]s which had fewer [[processor register]]s available, as in [[x86]]s. If there are no more registers available for an operation, the compiler must [[register spilling|copy from register to memory]] (or memory to register), which takes time (registers are significantly faster to access). However, the ''server'' virtual machine used a [[Graph coloring|color-graph]] allocator and did not have this problem.
 
An optimization of register allocation was introduced in Sun's JDK 6;<ref>[http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6320351 Bug report: new register allocator, fixed in Mustang (JDK 6) b59]</ref> it was then possible to use the same registers across blocks (when applicable), reducing accesses to the memory. This led to a reported performance gain of about 60% in some benchmarks.<ref>[http://weblogs.java.net/blog/2005/11/10/mustangs-hotspot-client-gets-58-faster Mustang's HotSpot Client gets 58% faster!] {{Webarchive|url=https://web.archive.org/web/20120305215143/http://weblogs.java.net/blog/2005/11/10/mustangs-hotspot-client-gets-58-faster |date=March 5, 2012 }} in Osvaldo Pinali Doederlein's Blog at java.net</ref>
 
====Class data sharing====
Line 157:
| publisher=Sun Microsystems
|last=Haase|first=Chet
| quote=''At the OS level, all of these megabytes have to be read from disk, which is a very slow operation. Actually, it's the seek time of the disk that's the killer; reading large files sequentially is relatively fast, but seeking the bits that we actually need is not. So even though we only need a small fraction of the data in these large files for any particular application, the fact that we're seeking all over within the files means that there is plenty of disk activity.''
|date= May 2007| access-date=July 27, 2007}}</ref>
*Parts of the platform needed to execute an application accessed from the web when JRE is not installed are now downloaded first. The full JRE is 12 MB, a typical Swing application only needs to download 4 MB to start. The remaining parts are then downloaded in the background.<ref>{{Cite web
Line 223:
 
==Comparison to other languages==
Objectively comparing the performance of a Java program and an equivalent one written in another language such as [[C++]] needs a carefully and thoughtfully constructed benchmark which compares programs completing identical tasks. The target [[Platform (computing)|platform]] of Java's [[bytecode]] compiler is the [[Java platform]], and the bytecode is either interpreted or compiled into machine code by the JVM. Other compilers almost always target a specific hardware and software platform, producing machine code that will stay virtually unchanged during execution{{citation needed|reason=What are the real world, non-theoretical implications of this?|date=May 2016}}. Very different and hard-to-compare scenarios arise from these two different approaches: static vs. [[dynamic compilation]]s and [[Dynamic recompilation|recompilations]], the availability of precise information about the runtime environment and others.
 
Java is often [[Just-in-time compilation|compiled just-in-time]] at runtime by the Java [[virtual machine]], but may also be [[Ahead-of-time compilation|compiled ahead-of-time]], as is C++. When compiled just-in-time, the micro-benchmarks of [[The Computer Language Benchmarks Game]] indicate the following about its performance:<ref>