Alex headshot

AlBlue’s Blog

Macs, Modularity and More

JavaOne 2016: HotSpot Under the Hood

2016, assembly, hotspot, hsdis, java, javaone, openjdk, presentation

I’ve just given a presentation at JavaOne 2016, entitled “HotSpot Under the Hood”. It’s a new version of the talk I gave for the DocklandsLJC earlier on this year.

Unfortunately the talk wasn’t recorded (ony a few of the rooms appear to have any video recording in them) but the video from the above DocklandsLJC talk has just been published on InfoQ. It’s mostly the same presentation as before, but the JavaOne version was formatted to widescreen and a few additional slides were added (hopefully self sufficient).

I’ve uploaded the version of the presentation that I gave at JavaOne to my SpeakerDeck account, if you want to step through the slides individually.

Building hsdis

You don’t actually need to clone the whole OpenJDK repository in order to be able to compile hsdis; you just need to be able to grab the files from the hotspot/src/share/tools/hsdis/ directory. Specifically, you need to download:

There’s also a README file, which is useful but not necessary.

To build, you’ll also need to download binutils and expand it to a directory build/binutils.

Or, you can just copy and paste the following into an appropriate directory:

Building HSDIS
1
2
3
4
5
6
curl -O -O -O -O https://raw.githubusercontent.com/dmlloyd/openjdk/jdk9/jdk9/hotspot/src/share/tools/hsdis/{hsdis.c,hsdis.h,Makefile,README}
mkdir -p build/binutils
curl http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.gz | tar --strip-components=1 -C build/binutils -z -x -f -
make both || make
# make both # for dual 32-bit and 64-bit platforms
# make      # for single-type platforms

This will download all the necessary files, run the build, and you’ll be left with a number of .dylib (for macOS) and corresponding .so and .dll for other platforms.

The macOS platform can support building and using both 32-bit and 64-bit binaries on the same platform; however, Linux platforms generally can’t handle both types.

Note that if you’re building on Windows with Mingw, you’ll need to replace the AR command with ${MINGW)-ar, in the same line that changes the CC variant for ${MINGW}-gcc. Ideally this should be fixed upstream but championing a fix is non trivial.

Command Options

The command options that I used in the talk were as follows:

  • -XX:+UnlockDiagnosticVMOptions – needed for the vast number of -XX:Print* flags
  • -XX:+PrintInterpreter – dump the template interpreter table
  • -XX:+PrintCompilation – show the compilation of methods as they occur, and what level they run as
  • -XX:+PrintAssembly – dump the assembly code for methods as they are compiled
  • -XX:+/-UseCompressedOops – turn on (or off) the ability to compress OOPs on a 64 bit JVM (defaults to on for less than 32G)
  • -XX:+/-UseCompressedClassPointers – turn on (or off) the compression of class pointers (defaults to on for 64 bit platforms)
  • -XX:ObjectAlignmentInBytes=8 – align objects on 8 byte boundary. Must be multiple of 2. Can use up to 64G if set to 16 but caution/testing required.
  • -XX:+/-TieredCompilation – defaults to on for Java 8 but off for Java 7

When you’re using OpenJDK flags, it’s sometimes a benefit to add -version to the end so you don’t get the help usage. For example, if you want to see what all the flags you can use -XX:+PrintFlagsFinal -version which will dump everything you can tweak (including what flags have been detected based on your VM configuration).

Moving on

2016, eclipse, java

I’ve been working for the last decade in the finance industry in London, most recently at Credit Suisse where I was the JCP Executive Committe representative, attending meetings and voting on behalf of the firm. (You can see more information about what makes up the JCP EC; there are representatives from companies such as Azul, Eclipse, RedHat and Twitter as well as user groups such as SouJava and the London Java Community – along with big users of Java technology, such as Credit Suisse and Goldman Sachs.)

Working in finance has always been an interesting challenge, with a scale of computing resources unknown outside of a small set of cloud-scale technology companies. Furthermore time tends to be profitable which means large scale computing and/or meaty hardware, which from a technology perspective comes with its own challenges and interesting solutions. I’ve heard it said that some companies in the finance industry, if they were considered to be technology companies rather than financial houses, that they would be the biggest technology firms in the city.

The other thing that I’ve enjoyed has been writing books, speaking at conferences, and writing for InfoQ – not to mention the open source contributions that I’ve been doing over the years. Thanks to my previous employers for being understanding. It has also helped launch the Docklands.LJC, which has entered its teens and had speakers from across the globe come and talk to interested attendees from around the Wharf.

However, the time has come for me to move on, and at the end of this week I start somewhere new. It’s a well known technology company that you will have heard of, but it’s an ideal move for me and I am definitely looking forward to the challenges that lie ahead. My LinkedIn profile has me as a Director of Bandlem Ltd, which is my own company, but I need to verify what I can (and can’t) say before I say it publicly. As a result, and with the ramp up of the new role, I may be slightly quieter than usual here and on Twitter for the near future, but the good news is that I will be speaking at both JavaOne and EclipseCon later this year, as an independent speaker.

It also means that I will be handing over the reins of the Docklands.LJC to my co-founder Robert Barr, who will take over the organisation of events in the Docklands. Hopefully I’ll still be able to come over to them in the future, time permitting, so I may well see you at future events over there.

I will also be taking a sabbatical from writing at InfoQ for the time being; although my writing output has dropped (both here on the blog and at InfoQ), which I put down to having spent so long writing books. It will be an interesting exercise to see what I will do with free time in the evenings now.

I’m really looking forward to where I’m going, and I can’t wait to start.

EclipseCon and JavaOne presentations

2016, conference, eclipse, eclipsecon, java, javaone, swift

It’s a busy season on the conference circuit, it seems. I’ve been giving a few presentations at the Docklands.LJC recently, and I’ve also been accepted as a speaker at JavaOne in September and EclipseCon Europe in October.

The presentations from the Docklands.LJC have been recorded, and the videos are slowly making their way over to InfoQ. Generally the InfoQ versions are more professional, as they have synchronized slides to go along with the video recording, but they’re also available as early rushes over on the Docklands.LJC site itself.

If you’ve missed them, here’s what I’ve been talking about:

The presentations are also available on my SpeakerDeck pages if you find that’s an easier way to look through them. Plus, they might show up better if you’re on a mobile device. When the presentation decks for the other conference sessions are avaialble, they’ll appear here as well.

My upcoming talks include:

JavaOne – September

HotSpot Under the Hood – an introduction to how the HotSpot runtime optimised Java calls, how the interpreter and JIT compiler work together to make your programs run faster, and how to interpret what code is generated when an application runs. This is known as CON3808 on the JavaOne 2016 Session Catalog, but there doesn’t appear to be an easy way to link to it. From the abstract:

Have you ever wondered how the JVM works under the covers? How the JVM is able to JIT-optimize the bytecode classes and what the generated output looks like? This session shows how a compiled Java class is loaded in memory, when the JIT optimizations occur, and what the generated assembly looks like for hot code in the JVM. The presentation also looks at current object layouts, how the memory settings affect how objects are stored, and what effects this can have for high-performance Java code.

You can register for the conference now and save yourself some money before the price goes up.

EclipseCon Europe – October

Optimising Eclipse Plug-ins – a look at common patterns and anti-patterns when writing plug-in code, and the tools and resources that are at your disposal as an Eclipse plug-in author in finding out how to identify and fix these issues. It’s currently scheduled for Thursday at 11 but this may change nearer thetime; so watch out for it on the schedule. From the abstract:

In this presentation, Alex will talk about optimising Java code in the context of Eclipse plug-ins, and demonstrate some of the tools that come with every JVM that can be used to inspect the state of a Java process. He will also present some Eclipse specific tools such as MAT and the show how some common patterns (and anti-patterns) can be found in existing plug-in code, and how they can be improved. By the end of this talk, the attendees should have a good idea of what tools are at their disposal and be able to apply that knowledge to reduce the memory footprint or perceived run-time by end users.

You can register for the conference now and save yourself some money before the price goes up.