• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is Java 7 faster than ancient versions?

 
Ranch Hand
Posts: 701
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd like to know if Java 7 is faster than ancient versions.

Thank you
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java 7 is a language. It makes no sense to say it's faster or slower than other versions.

Oracle's new JVM might be faster than older versions, but I could write a JVM for Java 7 that runs old code slower than Sun's 1.1 version.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're asking about the Sun / Oracle Java implementations, then yes, Oracle's Java 7 JVM is certainly faster than older versions. In each new Java version from Oracle there are new optimizations and other performance improvements.
 
author
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is true there are improvements in the performance of the JVM with each release. However, the new features of Java 7 are intended to help you improve the maintainability and efficiency of your applications. This could in turn result in more reliable and possibly faster execution. For example, in our book we discuss the ThreadLocalRandom class. This class, when used in place of the older Random class, will improve the performance of your threads.

Also, don't forget the javac compiler has a -O option that will result in the compiler optimizing the compiled code.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jennifer Reese wrote:Also, don't forget the javac compiler has a -O option that will result in the compiler optimizing the compiled code.


No, it doesn't. And if it does, then it's not in the documentation.

The Java compiler (javac) doesn't do a lot of optimization. The JIT compiler that's part of the JVM on the other hand, does a lot of very sophisticated optimizations when it compiles the Java byte code to native machine code.

There's a reason why javac doesn't optimize. By not doing a lot of optimization, javac makes it easier for the JIT to generate optimized native machine code.
 
Jennifer Reese
author
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, you're right! As of 1.3, the -O has been deprecated and should not be used. In earlier releases, it would inline static, final and private methods to attempt to speed up your code.

For many applications, fine tuning JVM options is not really necessary, but if you are curious, here is an interesting article about some current options for improving JVM performance.
http://randomlyrr.blogspot.com/2012/03/java-tuning-in-nutshell-part-1.html

Also, just some general techniques to use to help the JVM handle your code in the optimal manner:
https://wikis.oracle.com/display/HotSpotInternals/PerformanceTechniques
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jennifer Reese wrote:Oops, you're right! As of 1.3, the -O has been deprecated and should not be used. In earlier releases, it would inline static, final and private methods to attempt to speed up your code. . . .

Presumably using JIT techniques works a lot better than trying inlining.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inlining is one of the optimizations that the JIT compiler does. Probably it works a lot better if javac leaves it to the JIT, so that's why they took it out of javac since version 1.3.
 
I am a man of mystery. Mostly because of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic