Results 1 to 7 of 7
  1. #1
    crunchor is offline Member
    Join Date
    Jun 2013
    Posts
    12
    Rep Power
    0

    Default Is that mainly because of JIT so that Java has outstanding performance in Linux?

    This testing is 4 years ago but I think current result is that Java is even better and even closer to the C++ speed:
    Onur Gumus's Blog: C# versus C++ versus Java performance comparison
    Is this because JIT is more advanced and Java can take advantage of Linux IS and hardware like CPU and ram?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Is that mainly because of JIT so that Java has outstanding performance in Linux?

    There's nothing special about JIT compilation; the following phases are involved:

    Java source code --> Java class code --> final machine code

    while in 'traditional' compilation, the following phases are involved:

    X source code --> X machine code.

    The second phase of Java compilation (JIT compilation) can happen days or months after the first phase has completed (i.e. when the class is run) and can happen multiple times (each time the class is first loaded in the virtual machine). The JIT compiler has its own machine dependent optimizer; but traditional compilers can have those too, that's why (in theory) the runtime for Java code and X code won't differ much, i.e. it all depends on the quality of the final code generators.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    crunchor is offline Member
    Join Date
    Jun 2013
    Posts
    12
    Rep Power
    0

    Default Re: Is that mainly because of JIT so that Java has outstanding performance in Linux?

    Quote Originally Posted by JosAH View Post
    There's nothing special about JIT compilation; the following phases are involved:

    Java source code --> Java class code --> final machine code

    while in 'traditional' compilation, the following phases are involved:

    X source code --> X machine code.

    The second phase of Java compilation (JIT compilation) can happen days or months after the first phase has completed (i.e. when the class is run) and can happen multiple times (each time the class is first loaded in the virtual machine). The JIT compiler has its own machine dependent optimizer; but traditional compilers can have those too, that's why (in theory) the runtime for Java code and X code won't differ much, i.e. it all depends on the quality of the final code generators.

    kind regards,

    Jos
    I see, then why Java is so fast in linux even though there is JVM? It is almost as fast as C++ and much faster than .net in windows.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Is that mainly because of JIT so that Java has outstanding performance in Linux?

    Quote Originally Posted by crunchor View Post
    I see, then why Java is so fast in linux even though there is JVM? It is almost as fast as C++ and much faster than .net in windows.
    One of the reasons why Java is quite fast is: object oriented languages tend to allocate memory for their objects quite often during runtime; C++ relies on good old malloc() but Java just has to test a pointer value (for the out of memory condition), increment the pointer and return the old pointer value. The garbage collector takes care of the rest (if needed); also JIT compilers run during runtime; they can have information available about dead code (shrinking the final code, therefore reducing the primary processor cache space) etc. On startup of the JVM, Java is still a bit slower though ... (it has more work to do).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    crunchor is offline Member
    Join Date
    Jun 2013
    Posts
    12
    Rep Power
    0

    Default Re: Is that mainly because of JIT so that Java has outstanding performance in Linux?

    so the only little disadvantage is it takes time to start up, load necessary stuff in ram right? So a lot of ram really help java performance as well?

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Is that mainly because of JIT so that Java has outstanding performance in Linux?

    Quote Originally Posted by crunchor View Post
    so the only little disadvantage is it takes time to start up, load necessary stuff in ram right? So a lot of ram really help java performance as well?
    More RAM postpones garbage collection, which takes some time, so more RAM never hurts.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Is that mainly because of JIT so that Java has outstanding performance in Linux?

    Quote Originally Posted by JosAH View Post
    more RAM never hurts.
    That's what I told ewe ... :)
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 0
    Last Post: 12-26-2012, 06:36 PM
  2. Replies: 1
    Last Post: 05-04-2012, 07:21 PM
  3. Java Performance?
    By oaklandsbest in forum New To Java
    Replies: 5
    Last Post: 06-09-2011, 12:43 PM
  4. Replies: 6
    Last Post: 04-08-2009, 04:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •