supercharge java on the raspberry pi with zulu openjdk · –typical pi uses an arm11 with the...

25
© Copyright Azul Systems 2018 © Copyright Azul Systems 2015 @speakjava Supercharge Java On The Raspberry Pi with Zulu OpenJDK Simon Ritter Deputy CTO, Azul Systems 1

Upload: others

Post on 18-Jan-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

© Copyright Azul Systems 2015

@speakjava

Supercharge Java OnThe Raspberry Pi with

Zulu OpenJDK

Simon Ritter

Deputy CTO, Azul Systems

1

Page 2: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Poll Question

▪ How important is Java performance for your embedded applications

1. Critical to the project's success

2. We always want more, but we make do

3. We have no performance issues

2

Page 3: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Azul Systems

▪ Founded 2002, Based in Sunnyvale California

▪ 120+ employees worldwide

– Offices in U.S.A., Russia and India

▪ Two JVM product lines

– Zing: High performance, low latency, proprietary

– Zulu: Certified 100% build of OpenJDK

▪ Heavily involved in Java

– JCP EC, JSR EG for Java SE 9, 10 and 11

– Lead OpenJDK 6 project

3

Page 4: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018 4

The Raspberry Pi

Page 5: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Raspberry Pi

▪ Project started in 2006

– Goal to devise a computer to inspire children

– Inspiration from the BBC Micro project from 1981

History and Goals

Page 6: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Raspberry Pi

▪ Officially launched on February 29th 2012

– First production run was 10,000 boards

– Both RS and Farrell's servers were stalled on the day of

launch

– RS reported over 100,000 pre-orders in one day

▪ Current production is 15,000 boards per day

– Originally in China, now by Sony in the UK

▪ Over 15 million sold (10 million produced in the UK)

– Third best selling computer of all time

Page 7: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Raspberry Pi Versions

Model A

Model B

Version 1 Model BVersion 2/3

Pi Zero

Page 8: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Raspberry Pi Versions

8

Model Generation Hardware

Model A 1 ARMv6, 700MHz, Single core, 256/512Mb RAM, 1xUSB, No ethernet1+

Model B 1 ARMv6, 700MHz, Single core, 256/512Mb RAM,

2xUSB, 100Mb Ethernet

1+ 4xUSB

2 ARMv7, 900MHz, Quad core, 1Gb RAM

2 version 1.2 ARMv8, 900MHz

3 ARMv8, 1.2GHz

Pi Zero version 1.2/1.3 ARMv6, 1GHz, Single core, 512Mb RAM, no

Ethernet

W Added WiFi and Bluetooth

Page 9: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

A Brief (But Interesting) History Lesson

▪ Acorn BBC Micro (6502 based)

– Not powerful enough for Acorn’s plans for a business computer▪ Berkeley RISC Project

– UNIX kernel only used 30% of instruction set of Motorola 68000

– More registers, less instructions (Register windows)

– One chip architecture to come from this was… SPARC▪ Acorn RISC Machine (ARM)

– 32-bit data, 26-bit address space, 27 registers

– First machine was Acorn Archimedes

▪ Spin off from Acorn, Advanced RISC Machines

Page 10: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

ARM Features

▪ 32-bit RISC Architecture

– ARM accounts for vast majority of embedded 32-bit CPUs

– 15 billion chips sold in 2015, more than 80 billion in total

▪ Zero manufactured by ARM

▪ Abstract architecture and microprocessor core designs

– Typical Pi uses an ARM11 with the ARMv6 instruction set

▪ Low power consumption

– Good for mobile devices

– Raspberry Pi can be powered from 700mA 5V only PSU

– Raspberry Pi does not require heat sink or fan

Page 11: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Zulu & OpenJDK

Page 12: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

OpenJDK

▪ Launched in 2006

– Open source of the Sun implementation of the JDK

▪ Completely open sourced as of JDK 7 b53

– 30,000+ source files

– 7 million lines of code

12

Page 13: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

2007-2018: 11 Years Of OpenJDK

Page 14: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

OpenJDK Binary Distributions

Zulu Internal onlyJ9 Iced TeaHotspot

Page 15: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Zulu OpenJDK

▪ Azul’s binary distribution of OpenJDK– Passes all TCK tests

– No licensing issues

▪ GPLv2 with Classpath Exception

– Verified as built from 100% open-source

▪ JDK 6, 7, 8 and 9 for Intel

– JDK 9 not available for ARM/Raspberry Pi

– Next release for Pi will be JDK 11

15

Page 16: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Zulu Embedded: Customisable

▪ Packages: Zip, RPM, DEB

▪ Java 8 bundles: 6 builds, including Compact Profiles 1/2/3

16

JDK: 90MB JRE: 72MB JRE: 45MB CP3: 21MB CP2: 18MB CP1: 14MB

Headful Headless

Page 17: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Getting Started With Zulu OpenJDK

▪ Download the latest binary

– www.azul.com/downloads/zulu-embedded/

▪ Unpack zip or tarball

▪ Change your JAVA_HOME and PATH variables

– To point at Zulu install directory

▪ Job done!

– Complete drop in replacement

17

Page 18: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Zulu OpenJDK

C2 Compiler

Page 19: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Java Compilation

▪ javac generates bytecodes for the Java Virtual Machine

▪ These are interpreted when the application starts

– Each bytecode is converted to sequence of machine

specific instructions

▪ Hotspots are identified and quickly compiled (C1)

– No optimisations

– Running code is then profiled

▪ Code can be recompiled using optimising compiler (C2)

– Speculative optimisations, better intrinisics

19

Page 20: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

JVM Performance (JIT Related)

20

Bytecodes

interpreted

C1 JIT plus

profilingC2 JIT with

Deoptimisations

Steady optimised

state

Page 21: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Azul C2 Compiler Enhancements

▪ Added cryptographic intrinsics

– Use of processor hardware instructions

– Much faster than software emulation

▪ Added support for fused maths instructions available on

ARM CPUs

▪ Fixed a number of bugs in the C2 implementation

– Having adverse impact on performance

Page 22: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

SpecJVM Results

▪ Compared to Hotspot JDK 8u162 (ARM v6)

22

Test Improvement (%age)

crypto.aes 6

crypto.rsa 192

crypto.signverify 67

scimark.montecarlo 19

scimark.sparse.small 8

derby 9

Page 23: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018 23

Summary

Page 24: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

Zulu OpenJDK For Raspberry Pi

▪ Certified build of OpenJDK source

▪ Free version available under GPLv2 with CPE license

▪ Enhancements to C2 compiler available

▪ Commercial licensing with full 24x7x365 support available

▪ No more ARM binaries from Oracle as of JDK 9

24

www.azul.com/downloads/zulu-embedded/

Page 25: Supercharge Java On The Raspberry Pi with Zulu OpenJDK · –Typical Pi uses an ARM11 with the ARMv6 instruction set Low power consumption –Good for mobile devices –Raspberry

© Copyright Azul Systems 2018

© Copyright Azul Systems 2015

@speakjava

Thank You!

Simon Ritter

Deputy CTO, Azul Systems

25