jvm-hotspot

NewRatio parameter not working with CMS garbage collector

只谈情不闲聊 提交于 2019-11-28 09:18:51
问题 I switched to CMS collector for my application and throughput of application decreased by half. From GC logs, I see a high frequency of minor GCs happening (aroung 10 per second ). I have allocated a heap size of 4G . The JVM be default is using very small size for young gen (less than 40MB ). I want to try out CMS via increasing the size of young gen. Can you point me to right JVM parameter for this. I tried -XX:NewRatio but JVM ignored this parameter and there was no change in young gen

Is there any instruction reordering done by the Hotspot JIT compiler that can be reproduced?

别说谁变了你拦得住时间么 提交于 2019-11-28 09:06:54
As we know, some JIT allows reordering for object initialization, for example, someRef = new SomeObject(); can be decomposed into below steps: objRef = allocate space for SomeObject; //step1 call constructor of SomeObject; //step2 someRef = objRef; //step3 JIT compiler may reorder it as below: objRef = allocate space for SomeObject; //step1 someRef = objRef; //step3 call constructor of SomeObject; //step2 namely, step2 and step3 can be reordered by JIT compiler. Even though this is theoretically valid reordering, I was unable to reproduce it with Hotspot(jdk1.7) under x86 platform. So, Is

Where is the OutOfMemoryError object created in Java

[亡魂溺海] 提交于 2019-11-28 08:10:51
问题 An OutOfMemoryError occurs when the heap does not have enough memory to create new objects. If the heap does not have enough memory, where is the OutOfMemoryError object created. I am trying to understand this, please advise. 回答1: Of course, this is an implementation-dependent behavior. HotSpot has some heap memory inaccessible for ordinary allocations, the JVM can use to construct an OutOfMemoryError in. However, since Java allows an arbitrary number of threads, an arbitrary number of

When can Hotspot allocate objects on the stack? [duplicate]

假如想象 提交于 2019-11-28 06:03:05
This question already has an answer here: Eligibility for escape analysis / stack allocation with Java 7 3 answers Since somewhere around Java 6, the Hotspot JVM can do escape analysis and allocate non-escaping objects on the stack instead of on the garbage collected heap. This results in a speedup of the generated code and reduces pressure on the garbage collector. What are the rules for when Hotspot is able to stack allocate objects? In other words when can I rely on it to do stack allocation? edit : This question is a duplicate, but (IMO) the answer below is a better answer than what is

JRockit JVM versus HotSpot JVM

☆樱花仙子☆ 提交于 2019-11-28 05:40:46
If anyone can give me brief information about the advantages and disadvantages of the two JVM since they all depend on the Standard JVM Specification. haylem JRockit was originally developed by Appeal and BEA Systems before being acquired by Oracle to run server software. 1 It was meant to be optimized for large applications requiring long running tasks, a lot of memory and a scalable environment, pushing optimizations for these scenarios even further than the Sun HotSpot JVM in server-mode (see also: Real differences between "java -server" and "java -client"? ). Since the acquisition of Sun

What is the size of methods that JIT automatically inlines?

耗尽温柔 提交于 2019-11-28 03:57:55
问题 I've heard that JIT automatically inlines small methods, like getters (they have about 5 bytes). What is the boundary? Is there any JVM flag? 回答1: HotSpot JIT inlining policy is rather complicated. It involves many heuristics like caller method size, callee method size, IR node count, inlining depth, invocation count, call site count, throw count, method signatures etc. Some limits are skipped for accessor methods (getters/setters) and for trivial methods (bytecode count less than 6). The

First time a Java loop is run SLOW, why? [Sun HotSpot 1.5, sparc]

喜夏-厌秋 提交于 2019-11-28 02:58:32
问题 In benchmarking some Java code on a Solaris SPARC box, I noticed that the first time I call the benchmarked function it runs EXTREMELY slowly (10x difference): First | 1 | 25295.979 ms Second | 1 | 2256.990 ms Third | 1 | 2250.575 ms Why is this? I suspect the JIT compiler, is there any way to verify this? Edit: In light of some answers I wanted to clarify that this code is the simplest possible test-case I could find exhibiting this behavior. So my goal isn't to get it to run fast, but to

Does Java JIT cheat when running JDK code?

青春壹個敷衍的年華 提交于 2019-11-28 02:32:29
I was benchmarking some code, and I could not get it to run as fast as with java.math.BigInteger , even when using the exact same algorithm. So I copied java.math.BigInteger source into my own package and tried this: //import java.math.BigInteger; public class MultiplyTest { public static void main(String[] args) { Random r = new Random(1); long tm = 0, count = 0,result=0; for (int i = 0; i < 400000; i++) { int s1 = 400, s2 = 400; BigInteger a = new BigInteger(s1 * 8, r), b = new BigInteger(s2 * 8, r); long tm1 = System.nanoTime(); BigInteger c = a.multiply(b); if (i > 100000) { tm += System

HotSpot JIT inlining strategy: top-down or down-top

…衆ロ難τιáo~ 提交于 2019-11-27 21:26:29
Suppose we have 3 methods: method 2 is called from method 1, method 3 is called from method 2. Methods 2 and 3 are of size 30 bytecodes each. Also, suppose for definiteness method 2 is always called from method 1 exactly once, and method 3 is always called from method 2 exaclty once. If method 2 is inlined first, method 3 will be called from the body of method 1 directly, and could be inlined in its turn. If method 3 is inlined into method 2 first, the size of the latter will become about 60 bytecodes, and it couldn't be inlined, because default MaxInlineSize threshold is 35 bytecodes. In

JIT not optimizing loop that involves Integer.MAX_VALUE

╄→尐↘猪︶ㄣ 提交于 2019-11-27 20:38:17
问题 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