jvm-hotspot

JIT not optimizing loop that involves Integer.MAX_VALUE

安稳与你 提交于 2019-11-28 20:03:21
While writing an answer to another question , I noticed a strange border case for JIT optimization. The following program is not a "Microbenchmark" and not intended to reliably measure an execution time (as pointed out in the answers to the other question). It is solely intended as an MCVE to reproduce the issue: class MissedLoopOptimization { public static void main(String args[]) { for (int j=0; j<3; j++) { for (int i=0; i<5; i++) { long before = System.nanoTime(); runWithMaxValue(); long after = System.nanoTime(); System.out.println("With MAX_VALUE : "+(after-before)/1e6); } for (int i=0; i

Java VM tuning - Xbatch and -Xcomp

删除回忆录丶 提交于 2019-11-28 19:47:43
问题 I am looking at the JVM configuration options for running Alfresco, mainly this document on the Alfresco Wiki. One of the recommendations is to use the JVM flags -Xcomp and -Xbatch . The justification of this is: If you wish to have Hotspot precompile the classes, you can add [-Xcomp and -Xbatch]. This will, however, significantly increase the server startup time, but will highlight missing dependencies that can be hit later. From what I have read elsewhere about the -Xcomp and -Xbatch flags,

Method Area and PermGen

依然范特西╮ 提交于 2019-11-28 19:32:38
I was trying to understand the memory structure of HotSpot JVM and got confused with the two terms "Method Area" and "PermGen" space. The docs I referred to say that Method Area contains the definition of classes and methods including the byte code. Some other docs say that they are stored in the PermGen space. So can I conclude that these two memory areas are same ? You should take a look at Java Memory Types and optionally at this doc about the Garbage Collection in Java. The latter is very verbose and both are useful. Actually the Method area is a part of the Permanent Generation: A third

Where are instance variables of an Object stored in the JVM?

一个人想着一个人 提交于 2019-11-28 18:53:38
Is an instance variable of an object in Java stored on the stack or method area of the JVM? Also, do we have different instance variable for multiple threads? If it is stored in method area how is instance variable different from static variable storage? Matej Špilár Stack and heap are the memories allocated by the OS to the JVM that runs in the system. Stack is a memory place where the methods and the local variables are stored. (variable references either primitive or object references are also stored in the stack). Heap is a memory place where the objects and its instance variable are

What does CompileThreshold, Tier2CompileThreshold, Tier3CompileThreshold and Tier4CompileThreshold control?

丶灬走出姿态 提交于 2019-11-28 18:22:31
HotSpot's tiered compilation uses the interpreter until a threshold of invocations (for methods) or iterations (for loops) triggers a client compilation with self-profiling. The client compilation is used until another threshold of invocations or iterations triggers a server compilation. Printing HotSpot's flags shows the following flag values with -XX:+TieredCompilation. intx CompileThreshold = 10000 {pd product} intx Tier2CompileThreshold = 0 {product} intx Tier3CompileThreshold = 2000 {product} intx Tier4CompileThreshold = 15000 {product} There are too many flags for just a client and

Why HotSpot will optimize the following using hoisting?

点点圈 提交于 2019-11-28 17:56:36
In the "Effective Java", the author mentioned that while (!done) i++; can be optimized by HotSpot into if (!done) { while (true) i++; } I am very confused about it. The variable done is usually not a const , why can compiler optimize that way? ahawtho The author assumes there that the variable done is a local variable, which does not have any requirements in the Java Memory Model to expose its value to other threads without synchronization primitives. Or said another way: the value of done won't be changed or viewed by any code other than what's shown here. In that case, since the loop doesn't

Advanced Code Hot Swapping in JDK 8?

懵懂的女人 提交于 2019-11-28 17:31:43
I am looking for better HotSwapping in the JavaVM. Being able to only apply method body changes is okay but quite limiting. The options available is JRebel and a discontinued project called Dynamic Code Evolution Virtual Machine (DCEVM) . There is a JEP 159 out there that was written by the core developper of DCEVM. A blog post from 2011 mentioned that the developers of DCEVM now work for Oracle to integrate this into the JDK. Do we have this kind of support for JDK 8 beta already or was it postponed to JDK 9? I need hot swapping for adding and removing and renaming private methods mostly.

How do i know which default settings are enabled for Sun JVM?

跟風遠走 提交于 2019-11-28 17:02:42
i want to try CompressedOops on my JVM. No I wonder if it might be enabled by default. I run this jvm on debian/squeeze: $ java -version java version "1.6.0_22" Java(TM) SE Runtime Environment (build 1.6.0_22-b04) Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode) Some people say it is enabled by default, some say it is not: from: http://forums.yourkit.com/viewtopic.php?f=3&t=3185 Yes, you are right, I also checked it and Compressed Oops is not activated by default in Java6u21 64-bit, I do not understand why it said so in the links I provided. I tried to check it with jconsole/JMX

Adjusting GC Overhead Exceeded parameters

血红的双手。 提交于 2019-11-28 13:53:56
I need my Oracle Hotspot to throw an exception java.lang.OutOfMemoryError: GC overhead limit exceeded much sooner than with the default parameters of UseGCOverheadLimit . By default, OOME occurs when more than 98% of the time is spent in GC and less than 2% of the heap is recovered (described http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#par_gc.oom ). For instance, I need my JVM to throw OOME when more than 20% of the time is spent in GC. Unfortunately, the -XX:GCTimeRatio=nn doesn't seem to make a difference. The reason I need to adjust my JVM in this way is that I'm

Disable Java JIT for a specific method/class?

久未见 提交于 2019-11-28 11:12:37
I'm having an issue in my Java application where the JIT breaks the code. If I disable the JIT, everything works fine, but runs 10-20x slower. Is there any way to disable the JIT for a specific method or class? Edit: I'm using Ubuntu 10.10, getting the same results both with: OpenJDK Runtime Environment (IcedTea6 1.9) (6b20-1.9-0ubuntu1) OpenJDK 64-Bit Server VM (build 17.0-b16, mixed mode) and: Java(TM) SE Runtime Environment (build 1.6.0_16-b01) Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode) The following option works on my JVMs, to exclude a specific method: -X