DOAG 2010, Nürnberg

Oracle Optimized Java SE for Embedded Platforms

Dr. Rainer Eschrich Principal Sales Consultant Java Embedded Business Unit The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

© Oracle 2010 2 Topics

Why Java

Java SE Embedded

Technical Details

Use Cases

Conclusions

© Oracle 2010 3 ©2010 Oracle Corporation Java in Embedded – An Introduction

Embedded Trends

• Cortex A5 Dual Core • Atom Dual Core Processors • PowerPC QorIQ Family • Cortex A9 Dual/Quad Core • N550 1.5ghz 8.5w • P2020 Dual Core 1.2ghz • 250mw power 1ghz today • D525 1.8ghz 13w • P4080 Quad Core 1.5ghz •ARM Eagle Cortex A15 Coming • D510 1.66ghz 13w Embedded Communication • Quad 2.5 ghz! • Nvidia 2 – 1ghz Dual A9 • 330 1.6ghz 8w Processors • Marvell Quad-Core •TI OMAP4 Dual core Cortex-A9

Common Themes • Embedded Multi-Core is everywhere • ARM continuing low power legacy, Intel moving into that space with Atom • ARM setting sights on server market

© Oracle 2010 5 Java Features

• Proven & Stable • Huge Developer Base • Rapid Application Development • Fully Object Oriented • Run on a Virtual Machine – Memory Management, Portability, Cross Platform … • Multi-Thread, -Process and -CPU/Core support • Security • Networking • Deployment

©2010 Oracle Corporation The Java Embedded Continuum

Java Card Java ME(CLDC) Java ME(CDC) Java SE

What I will talk about! Embedded Space

©2010 Oracle Corporation Java in Embedded – Java SE Embedded

What does “Embedded” mean? • Two definitions used: Legal and Technical • Legal definition of Embedded SE: Designates a Field Of Use (FOU)

– Embedded FOU defined in the license file as anything that is not a “general purpose desktop computer or server” • e.g : “industrial control systems, wireless mobile telephones, wireless handheld devices, kiosks, TV/STB, Blu-ray Disc devices, ATM's etc...” – Applies to both embedded (footprint-reduced) SE implementations and “regular” SE implementations

– Royalty bearing, affordable pricing • Dedicated, flexible, versatile pricing model applies: based on unit cost and volume.

©2010 Oracle Corporation Java SE Embedded Only Implementation

● Embedded Only Features: − Memory reductions/optimizations − Disk/Flash/ROM size reductions ● Headless Configuration ● Removal of optional files and Java classes − Low Power Handling − Additional Platforms (/ARM, Linux/Power, WinXP Embedded)

And of course all the good stuff Java SE brings out of the box and via third party libraries/apps … (like Java EE ...)

© Oracle 2010 10 Targeted Configurations (Today)

Processor Operating Headless or FPU Java SE System Headful Version ARMv5 Linux Headless Soft-Float 6U21 ARMv6/v7 Linux Headless & Hard-Float 6U21 Headfull (v7)

PowerPC Linux Headless Classic 6U21 e600 core Hard-Float PowerPC Linux Headless Embedded 6U21 e500v2 core Hard-Float Linux Headless X86 6U21

X86 XP Headful x86 5U10 Embedded

© Oracle 2010 11 Java in Embedded – Tech Stuff

Small Footprint for Embedded

●The standard release’s ROM/disk footprint is too big for many embedded devices − Memory getting cheaper, but cost remains a factor: Profit = Margin x Volume

●Small footprint optimizations − Additional Compression, File Removal − Footprint reduction of up to 56% ● e.g 6.0 for ARM around 32 MB ● e.g., for 5.0 on Linux/x86: from 68MB to 29.5MB

©2010 Oracle Corporation Java SE – Custom Embedded Builds • Technical definition of embedded SE: Custom – footprint-reduced – but still SE compatible

SE specification

“Regular” SE implementation

Embedded SE implementation optional NOT an SE components implementation

©2010 Oracle Corporation Small Footprint for Embedded

File removal includes ● Deployment: Java Web Start, Plug-in, Pack2000 and Unpack2000 ● IDL and RMI: rmiregistery, rmid, servertool,tnameserv ● Security: Policytool, keytool, ktab, klist, kinit ● Orbd ● Man pages ● Localization − Character convertors (charsets.jar) ● Remove either Client Compiler or Server Compiler

©2010 Oracle Corporation Headless Feature for SE Embedded

● Headless option − No support for keyboard, mouse, video − Otherwise full SE functionality, including printing

● Runtime and build implementation − Headless flag hard-wired on ● Djava.awt.headless=true − “Headful” files removed, including libmawt.so

©2010 Oracle Corporation Low Memory Support

● The Linux community has been searching for solutions to handle low memory conditions

● Killing processes is NOT the answer (SIGABORT, ouch!)

● We chose to support /dev/mem_notify − Linux kernel driver monitoring available memory

Block Waiting / YES Create Open Monitoring /dev/mem for Input dev/me from Device m_notif Thread notify y avail? NO Full GC

Feature Unavailable *Release Additional VM Memory (JIT Buffers, etc)

©2010 Oracle Corporation Java SE Embedded Feature Power Conservation

• Goal – Reduce CPU usage to 0% when Java applications are idle in order to allow CPU clock to be reduced or suspended • Modifications Performed – Hotspot Virtual Machine • Eliminated all Polling Threads – Java SE AWT/Swing Changes • Eliminated Polling for X Events when idle

©2010 Oracle Corporation 18 Embedded Caffeine Mark Performance Improvements

+29%

+22%

+21%

© Oracle 2010 19 specJVM98 Performance Improvements

+19%

+17%

© Oracle 2010 20 Performance Java SE 6 versus Android2.2

2.5X 1.53X

2.16X 2.15X

© Oracle 2010 21 Tuning your Embedded Java Solution

● Default configuration ● Improving Startup Time ● Taking Advantage of Multi-core processors ● Picking the Right Garbage Collector

Throughput/Response Time

Disk/Flash Consumption Memory Consumption

Clock Speed, Number of CPUs Heap Size ?

JIT Strategy Startup Time

Garbage Collection Policy

© Oracle 2010 22 Java SE Embedded Design Focus

• Assumptions leading to our default configuration of SE Embedded – Most embedded devices are resource constrained – Keeping per unit device cost low is high priority – Use lower clocked processors Option Java SE Embedded Default State Performance Monitoring Off by Default Compression of JAR Files All Jar File Compressed All JRE Files Included Optional Files Removed Class Data Sharing Off by Default JIT Compiler Only –client JIT available

© Oracle 2010 23 Improving Startup Time

● Class Data Sharing (If classloading is bottleneck) − Enabling Class Data Sharing − Customizing Class Data Sharing Archive − Can improve Startup by 25%-30% ● Uncompressing jar files (If disk space is available) − Gain is dependent on disk access and CPU clock speed ● Lower Compilation Threshold (If MP device) -XX:CompilationThreshold=xxxx (default is 1500) ● Deferring Initialization or Class Loading in your application

© Oracle 2010 24 Enabling and Configuring Class Data Sharing

● Enabling CDS with default classlist − java –Xshare:dump − Once complete, CDS is automatically enabled

● Use java –Xshare:on OR –Xshare:off to compare startup times. ● The default classlist is for GUI Swing Based Apps

© Oracle 2010 25 Customizing Class Data Sharing for Embedded Java Applications

1. Create a list of classes loaded at the startup of your application java –Xshare:off –XX:+TraceClassLoadingPreorder {your app} >my_class_list *exit your app soon after startup 2. Extract only bootclass loaded classes. Outputs classlist.linux. java MakeClassList my_class_list >new_classlist 3. Add checksum to end of new_classlist java AddJsum new_classlist classlist 4. Copy classlist to {JRE}/lib directory 5. Create classes.jsa file java –Xshare:dump – You now have a customized classes.jsa file!

Tools referenced on this page can be found in openjdk sources here: jdk/make/tools/src/build/tools

© Oracle 2010 26 Taking Advantage of Multi-Core Processors with Java

● Built in VM Features that take advantage of SMP − Parallel Garbage Collection − Concurrent Garbage Collection − Background JIT Compilation ● Lower Compilation Threshold

● Parallelize your Java Application Code

© Oracle 2010 27 Which Garbage Collector Should I Use? Java SE Embedded Contains all of the standard collectors

Collector Option Pro Con MP

Serial -XX:+UseSerialGC Best Choice for single N (default) CPU

Concurrent -XX:+UseConcMarkSweepGC Better if response Uses processor Y -XX:+CMSIncrementalMode time is highest resources while priority embedded app is Shorter GC pauses running

Parallel -XX:+UseParallelGC Better if throughput is GC must still pause Y (Young) highest priority. embedded app during -XX:+UseParallelOldGC Uses multiple collections. Parallel (Old) processors to speed up GC collection

For more details on GC tuning options see: http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html

© Oracle 2010 28 Reducing System Resource Requirements (Reducing Memory Consumption)

●Customizing Heap Sizes -Xms -Xmx ●Adjust Free Ratios -XX:MaxHeapFreeRatio=xx (control heap reduction, default 70) -XX:MinHeapFreeRatio=xx (controls heap expansion, default 40) ●Reducing JIT CodeBuffer -XX:ReservedCodeCacheSize=xxM ●Standard Java SE tools can be used to identify potential memory savings − Use jvisualvm with Linux x86 JDK ● Heapdump option

© Oracle 2010 29 Java in Embedded – Use Cases

Java SE for Embedded - Example devices

• Routers & Switches • Smart Meters • • ATMs • Storage Appliances RFID Readers • Video Conferencing • • Parking Meters Network Management Systems Systems • POS Systems • In-Flight Entertainment • Lottery/Gaming • Medical Imaging Systems Systems Systems • Radar Systems • Video Streaming Systems • Multi Function Printers • Industrial PCs • Electronic Voting • Intelligent Power • Factory Automation Systems Systems • Voice Messaging Module • Geo-Imaging Devices Systems • Netbooks • Security Systems

© Oracle 2010 31 Java SE Embedded in Smart Metering

EnergyICT Java SE Embedded Based Smart Meter Concentrator

© Oracle 2010 32 Java SE Embedded – Sheeva Plug

● Low Power ARM/Linux based device design by Maxwell − 512 MB RAM, 512 MB Flash, USB & Gigabit Ethernet − ca. 100-120 US$ for single devices ● Flexible and Capable ● Runs Java SE Arm v5/Linux headless ● Low Power Java Web Server: http://www.theregister.co.uk/2010/11/11/diy_zero_energy_home_server/

© Oracle 2010 33 Java in Embedded – Conclusion

Future Enhancements under Consideration

• Performance, Startup and Size Reduction always top priority • Server (C2) JIT for ARM Platforms • Bundled Solutions for Specific Markets • Embedded specific Module implementations • JDK7 • G1 – Garbage First Collector • MVM – Multi-Tasking Virtual Machine

© Oracle 2010 35 Benefits of Java SE Based Embedded Solutions

1 Decouples Software Development from 5 Most Popular Embedded Processors Hardware Development Cycle Supported Allowing Design Flexibility

2 Development and Testing Can be Done 6 Java SE embedded isolates your apps Using Standard Desktop Systems from Linux kernel, glibc differences

All Standard Java SE Garbage 3 Rich set of standard APIs For Quick 7 Time To Market Collectors Supported

Customized for Embedded Devices To 4 Same Versions of Java as Desktop & 8 Server Releases Reduce Production Cost

© Oracle 2010 36 Questions?

For more information on Embedded Java: http://www.oracle.com/technetwork/java/embedded/overview/index.html

© Oracle 2010 37