Questions tagged [jvm-hotspot]

HotSpot is the standard Java virtual machine used by both the Oracle and OpenJDK Java runtime environments.

HotSpot is the standard Java virtual machine used by both the Oracle and OpenJDK Java runtime environments for Java SE and EE environments.

This makes it the most widely deployed Java virtual machine in the world.

It is capable of running code from any language which can emit a Java .class file, as well as interpreted languages (e.g. JRuby) which have implemented their interpreters in Java (or another JVM language).

As of 2012, there are at least 200 languages which can run on top of the JVM - including Scala, Groovy, Clojure, JRuby, Jython and many smaller, niche languages.

HotSpot gets its name from the ability to dynamically profile running code and detect the "hot spots" of execution - the most commonly executing methods.

As, under most circumstances, programs spend most of their time in a small percentage of their methods, this focusing of optimization effort on the hot methods is very efficient.

HotSpot compiles and aggressively optimizes these hottest methods to highly platform-specific machine code which is specialized for the exact environment the code is running on.

This ability to use information about the runtime environment (precise instruction sets supported, memory and core configuration, etc) allows HotSpot to perform optimization tricks that are just not possible with a generic ahead-of-time strategy for "i386" or "i686" as is commonly seen in C/C++ environments.

This (along with the JVMs advanced memory management and garbage collection subsystem) makes the performance analysis of HotSpot-hosted programs more difficult compared to well-known techniques for C/C++. Direct comparison between the two environments is difficult - they each have individual strengths, and each has areas where they have definite advantages.

696 questions
13
votes
3 answers

weakCompareAndSwap vs compareAndSwap

This question is not about the difference between them - I know what spurious failure is and why it happens on LL/SC. My question is if I'm on intel x86 and using java-9 (build 149), why is there a difference between their assembly code? public…
Eugene
  • 117,005
  • 15
  • 201
  • 306
13
votes
1 answer

Where are the native methods of sun.misc.Unsafe implemented?

I've been reading through the sun.misc.Unsafe class (openjdk6) as I was curious how many native methods it actually referred to. Understandably there are a large number of native methods in the class, however I cannot seem to find where they are…
13
votes
2 answers

What's the purpose of including java.lang.Object in an interface's Constant Pool?

Compiling the following interface: package test; public interface MyInterface { public void foo(); } and checking the compiled code using javap -v -s test.MyInterface shows the following (-s prints member signatures): Compiled from…
M A
  • 71,713
  • 13
  • 134
  • 174
13
votes
1 answer

How do I disable Java stack frame optimizations, or profile stacks using system profilers?

System profilers, like DTrace and Linux perf_events, are able to profile stack traces from the JVM. Now, symbols aside (that's another problem), both DTrace and perf_events collect many stacks that are only 1 frame. These are partial, incomplete…
Brendan Gregg
  • 965
  • 8
  • 10
13
votes
1 answer

Strange behaviour of the Hotspot loop condition optimizer

Based on the discussions around an answer to this question, I discovered a really strange behaviour of the Java Hotspot optimizer. The observed behaviour can at least be seen in the Oracle VM 1.7.0_17, but seem to occur in older Java 6 versions as…
jarnbjo
  • 33,923
  • 7
  • 70
  • 94
13
votes
1 answer

Jvm native code compilation crazyness - I seem to suffer odd performance penalties for some time even after the code is compiled. Why?

Issue When benchmarking a simple QuickSort implementation in Java, I faced unexpected humps in the n vs time graphics I was plotting: I know HotSpot will attempt to compile code to native after it seems certain methods are being heavily used, so I…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
12
votes
1 answer

How can I know whether a Java object is in tenure or eden space from heap dump

I have a Hotspot JVM heap dump and I tried to find out whether an object is live in tenure space, eden space, or survivor space, but I could not. Appreciate if someone can help me.
James
  • 1,001
  • 2
  • 15
  • 23
12
votes
3 answers

VarHandle get/setOpaque

I keep fighting to understand what VarHandle::setOpaque and VarHandle::getOpaque are really doing. It has not been easy so far - there are some things I think I get (but will not present them in the question itself, not to muddy the waters), but…
Eugene
  • 117,005
  • 15
  • 201
  • 306
12
votes
3 answers

Android application Wi-Fi device - AP connectivity

I am building an application which can transfer data between a mobile and a Wi-Fi device... The mobile has got the AP enabled (through code) and another device connects to this specific network... How can I detect through code to see the details of…
Arun Abraham
  • 4,011
  • 14
  • 54
  • 75
12
votes
1 answer

Do objects with a lot of reference fields (except arrays) devastate Hotspot JVM's GC(s) heap traversal performance?

Imagine that I define a class with dozens of reference fields (instead of using reference arrays such as Object[]), and instantiate this class pretty heavily in an application. Is it going to affect the performance of garbage collector in Hotspot…
leventov
  • 14,760
  • 11
  • 69
  • 98
12
votes
1 answer

Oracle's Server JRE Contains JDK?

I've just downloaded Oracle's Server JRE for Java SE 7 (link) The file I downloaded was server-jre-7u45-linux-x64.tar.gz. When I extracted this file I was surprised to find a directory named jdk1.7.0_45 was created containing the full java JDK. Not…
Brice Roncace
  • 10,110
  • 9
  • 60
  • 69
12
votes
1 answer

Java vs C# Multithreading performance, why is Java getting slower? (graphs and full code included)

I have recently been running benchmarks on Java vs C# for 1000 tasks to be scheduled over a threadpool. The server has 4 physical processors, each with 8 cores. The OS is Server 2008, has 32 GB of memory and each CPU is a Xeon x7550…
intrigued_66
  • 16,082
  • 51
  • 118
  • 189
11
votes
11 answers

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

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 …
Adam Morrison
  • 206
  • 3
  • 8
11
votes
1 answer

Missing bounds checking elimination in String constructor?

Looking into UTF8 decoding performance, I noticed the performance of protobuf's UnsafeProcessor::decodeUtf8 is better than String(byte[] bytes, int offset, int length, Charset charset) for the following non ascii string: "Quizdeltagerne spiste…
11
votes
1 answer

-XX:+StressLCM, -XX:+StressGCM Options for JVM

While playing with some jcstress code, I noticed two parameters that are very new to me: StressLCM and StressGCM. The very first thing to do for me was searching for these in the source code itself and while I have found some things, it is still…
Eugene
  • 117,005
  • 15
  • 201
  • 306