<p>Is there any performance to be gained these days from compiling java to native code, or do modern hotspot compilers end up doing this over time anyway?</p>

[{'answer_id': 51293, 'author': 'Frank Krueger', 'author_id': 338, 'author_profile': 'https://Stackoverflow.com/users/338', 'pm_score': 1, 'selected': False, 'text': '<p>Memory performance or CPU performance? Or are they the same these days?</p>\n\n<p>My only evidence is anecdotal and on a different platform: after porting a bunch of CPU-hungry apps to C# (.NET 2.0), I did not notice substantial loss in performance (I do not consider 10% substantial). Well written code seems to perform well on a variety of architectures.</p>\n\n<p>Most apps spend/waste time with:</p>\n\n<ul>\n<li>IO operations that will not benefit from static (compile-time) analysis.</li>\n<li>Bad Algorithms that will not benefit from static analysis.</li>\n<li>Bad Memory layouts in critical CPU inner loops. While it is technically possible that compilers help us here, I have yet to see a real compiler do anything interesting.</li>\n</ul>\n\n<p>So based upon my experience, unless you are writing a video codec, there is no benefit to compiling Java apps vs. just relying upon the hotspot compilers.</p>\n'}, {'answer_id': 51373, 'author': 'Einar', 'author_id': 2964, 'author_profile': 'https://Stackoverflow.com/users/2964', 'pm_score': 3, 'selected': True, 'text': '<p>There was a similar discussion here recently, for the question <a href="https://stackoverflow.com/questions/48144/what-are-advantages-of-bytecode-over-native-code">What are advantages of bytecode over native code?</a>. You can find interesting answers in that thread.</p>\n'}, {'answer_id': 51558, 'author': 'Nick Fortescue', 'author_id': 5346, 'author_profile': 'https://Stackoverflow.com/users/5346', 'pm_score': 2, 'selected': False, 'text': '<p>Some more anecdotal evidence. I\'ve worked on a few performance critical real-time trading financial applications. I agree with Frank, nearly every time your problem is not the lack of being compiled, it is your algorithm or data structure. Modern hot-spot compilers are very good with the right code, for example the <a href="http://acs.lbl.gov/~hoschek/colt/" rel="nofollow noreferrer">CERN Colt library</a> is within 90% of compiled, optimised Fortran for numerical work.</p>\n\n<p>If you are worried about speed I\'d really recommend a good profiler and get evidence as to where your bottlenecks are - I use <a href="http://www.yourkit.com/" rel="nofollow noreferrer">YourKit</a> and have been very pleased.</p>\n\n<p>We have only resorted to native compiled code for speed in one instance in the last few years, and that was so we could use <a href="http://www.nvidia.com/object/cuda_home.html#" rel="nofollow noreferrer">CUDA</a> and get some serious GPU performance.</p>\n'}, {'answer_id': 53089, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>Your question is a little large, the answer vary a lot</p>\n\n<ul>\n<li>If you are using Just In Time compilation (JIT) or not</li>\n<li>When you are using,, if your process is executed for a long time or not</li>\n</ul>\n\n<p>All recent JVM use JIT, but on old JVM the java code is several time slower that native code.</p>\n\n<p>If you have a server that run for a long period of time or batch that execute the same code again and again, the difference and up being very low.</p>\n\n<p>We wrote the same batch both in C++ and in Java and run it with different dataset, the result differ for about 3 second, with dataset taking from 5 minutes to several hours.</p>\n\n<p>But be careful, they are special case that there will be an important difference, for example the batch that need a lot memory.</p>\n'}, {'answer_id': 18665561, 'author': 'user2745303', 'author_id': 2745303, 'author_profile': 'https://Stackoverflow.com/users/2745303', 'pm_score': -1, 'selected': False, 'text': '<p>Tried Hello-World in with six different implementations just to check the overhead\nand the difference was staggering. Java was off the charts while the compiled languages did equally well. I could proved all the evidence (in a reproducible) if needed.</p>\n'}]
['https://Stackoverflow.com/questions/51276', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5045/']