graalvm
Published in

graalvm

Making sense of Native Image contents

What code ends up in the executable and who’s to blame?

GraalVM Dashboard UI
  • Code Size Breakdown — showing the size of the precompiled packages and classes
  • Heap Size Breakdown — showing which objects are on the preinitialized heap
  • Points-to Exploration — answering the question why certain classes and methods are included in the native image
  • -H:DashboardDump=<path> to define the path for the dump file
  • -H:+DashboardAll to dump all available data

GraalVM Dashboard in action

$ cd multithreading-demo-oversized/
$ mvn package
$ java -jar target/multithreading-1.0-jar-with-dependencies.jar
Synchronous execution for 4 times.
The execution for 4 times takes: 841ms.

Asynchronous threads execution for 4 Threads.
The execution of Thread 1 took: 182ms.
The execution of Thread 2 took: 192ms.
The execution of Thread 3 took: 191ms.
The execution of Thread 4 took: 196ms.
The execution of 4 Threads takes: 280ms.
Dumping diagnostic data at native image build time
$ ./target/multithreading-image-oversized
Synchronous execution for 4 times.
The execution for 4 times takes: 424ms.

Asynchronous threads execution for 4 Threads.
The execution of Thread 1 took: 229ms.
The execution of Thread 2 took: 202ms.
The execution of Thread 3 took: 225ms.
The execution of Thread 4 took: 211ms.
The execution of 4 Threads takes: 234ms.
JAR, native image, and BGV file sizes
  • -H:+DashboardHeap - to dump the breakdown of the image heap
  • -H:+DashboardCode - to dump the breakdown of the code size per method
  • -H:+DashboardPointsTo - to dump the points-to analysis information
  • -H:+DashboardJson - to dump in white-spaceless JSON format for smaller file
  • -H:+DashboardPretty - to dump in human readable JSON format
  • -H:-DashboardBgv - to NOT dump in BGV format otherwise dump will be done in both formats (note the minus "-" symbol after colon)
Upload a dump file window
Code Size Breakdown view
Heap Size Breakdown view
Points-to Explorer view

Using the data

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store