Recap the Java(JVM) : after reading Optimizing Java

Key aspects of the platform

  • Interpreter(interprete compiled byte codes)
  • JIT Compiler(HotSpot JVM, is used for OracleJDK and OpenJDK, has it, only compiles the most commonly executed(==important) parts of the program)
  • Classloading
  • Garbage Collection
Theory: JVM Subsystems 07:59

Interpreter

JIT compiler

Classloading

Garbage Collection

Modern Processor Architecture

  • the vast majority of work being done is about moving memory around rather than actually incrementing the individual element.
  • how noisy measurement in the JVM can become, the example benchmarked speed of Northbridge not the code.

Operating Systems and Code Execution

Memory layout of a Unix process and JVM

OS scheduler, State model of a thread, Context switches

Operating Systems and Code Execution 14:30

JVM Objects at Runtime

Objects in the heap

  • Every object in the heap is represented by an OOP
  • Ordinary Object Pointer
  • A pointer in the C/C++ sense
  • VM allocates from free space
  • Technically an instaceOop
  • Every Java reference points at an oop location or null
  • Oop location consist of, 2 machine words of header, Mark(instance specific data)and Klass world(type specific data, metadata about type of this object), in case of array, has a third world of header, array’s length, primitives does not have object headers of course and cannot live in the heap without boxing(generation of an object header to wrap the value).
Map.Entry
int[]
Array<Integer>, cost of boxing

Compressed Oops

  • for a 32-bit JVM the object header is 8 bytes
  • for a 64-bit JVM the object header is 16 bytes
  • while its trivial, the average Java application contains millions of objects, so to reduce this overhead, use CompressedOops, represent a 64-bit address in 32 bits, scale by a factor of 8 and add to a 64 bit base, address ~4billion objects rather than ~4billion addresses

Mark word

Klass word

Class objects & Klass Oops

Entry.class is class object which can be assigned to Java variable, type of Entry.class is Class, below area is metadata space

Bytecode Basics

AST from fib code

javap

The constant pool

JVM Interpreter

HotSpot Interpreter

Ocelot JVM

Performance terminology

  • Latency — end to end time at given workload, often quoted only for average load, useful to consider across a range of load
  • Throughput — # of units on known resource levels
  • Utilization — % of resources used to service requests
  • Efficiency — Through / Resource
  • Capacity — # of units in flight though the system
  • Scalability — Delta in Throughput or latency as resource is added

Main areas that are at root cause responsible for any source of slowness

  • External Systems
db or microservices etc
  • Operating Systems
  • JVM / GC
  • Application Code
  • Too much traffic

Basic analysis principles

Measuring Effectiveness of Memory/CPU

Garbage Collection

Mark & Sweep

Stop the world

Concurrent

Parallel

Generational Collection

Simple generational algorithm

after Java 8 no Perm

Survivor spaces

Thread-Local Allocation Buffers

Card tables

OutOfMemoryError

Virtual headroom

Allocation & Lifetime

Allocation rate

Lifetime

Metrics to watch

Hotspot’s Parallel Collectors

Drawbacks of Parallel Collectors

Concurrent Marking Algorithm

Safepoints reconsidered

Concurrent Mark and Sweep

Observable effects of CMS

Garbage First, G1

AOT, JIT compilation

Code Cache

Compilation Strategies in HotSpot

Escape Analysis

When to use microbenchmarks(MBMs)

GraalVM and Java9, 10

Compact String

JSR312 — reduce need for global safe points

java array

other references to recap JVM

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How I made a puppy training app in an afternoon

Three screenshots from a mobile. First shows a table of data about dog training and two buttons at the bottom for Skills and Training. The second shows a training log form with fields for skills, time, date and rating. Third shows a loading screen with a photo of a cute, scruffy black puppy.

Why you should consider .NET Core for your next project

ChakrDB: A Distributed RocksDB Born in the Cloud, Part 1

Integrating reCAPTCHA with PHP

TryHackMe — Chill Hack Writeup

JINA — And It’s Installation

Reflection Probes

2019 in Review: Going Remote

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
DoggyFootGuy

DoggyFootGuy

More from Medium

DSA | Kahn’s algorithm for Topological sorting

Single And Multi Dimensional Array in Java

Print a sequence using 3 threads | Java