Real-Time Java for Latency Critical Banking Applications. Bertrand Delsart JavaRTS Technical Leader Author of Sun's RTGC technology



Similar documents
Validating Java for Safety-Critical Applications

Realtime Linux Kernel Features

Linux Process Scheduling Policy

Mission-Critical Java. An Oracle White Paper Updated October 2008

What s Cool in the SAP JVM (CON3243)

Tutorial: Getting Started

Replication on Virtual Machines

JBoss Data Grid Performance Study Comparing Java HotSpot to Azul Zing

Understanding Hardware Transactional Memory

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Low level Java programming With examples from OpenHFT

Tuning Your GlassFish Performance Tips. Deep Singh Enterprise Java Performance Team Sun Microsystems, Inc.

Performance Comparison of RTOS

Real Time Cloud Computing

Zing Vision. Answering your toughest production Java performance questions

Java Performance. Adrian Dozsa TM-JUG

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Cloud Computing and Robotics for Disaster Management

Tomcat Tuning. Mark Thomas April 2009

CSCI E 98: Managed Environments for the Execution of Programs

Real Time Programming: Concepts

Practical Performance Understanding the Performance of Your Application

Real-Time Scheduling 1 / 39

JSLEE and SIP-Servlets Interoperability with Mobicents Communication Platform

Operating Systems 4 th Class

The Design of the Inferno Virtual Machine. Introduction

Chapter 6, The Operating System Machine Level

JVM Performance Study Comparing Oracle HotSpot and Azul Zing Using Apache Cassandra

Embedded Systems. 6. Real-Time Operating Systems

Design Pattern for the Adaptive Scheduling of Real-Time Tasks with Multiple Versions in RTSJ

Predictable response times in event-driven real-time systems

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Java Environment for Parallel Realtime Development Platform Independent Software Development for Multicore Systems

Lecture 3 Theoretical Foundations of RTOS

<Insert Picture Here> Java Application Diagnostic Expert

Application of Android OS as Real-time Control Platform**

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

General Introduction

IBM Tivoli Composite Application Manager for WebSphere

Cloud Computing. Up until now

Multi-core Programming System Overview

Using jvmstat and visualgc to Solve Memory Management Problems

Apache Tomcat Tuning for Production

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2007 Lecture 5 - DBMS Architecture

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Garbage Collection in the Java HotSpot Virtual Machine

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Adobe LiveCycle Data Services 3 Performance Brief

WebSphere Performance Monitoring & Tuning For Webtop Version 5.3 on WebSphere 5.1.x

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

Tool - 1: Health Center

Achieving Nanosecond Latency Between Applications with IPC Shared Memory Messaging

OPERATING SYSTEMS SCHEDULING

11.1 inspectit inspectit

Azul's Zulu JVM could prove an awkward challenge to Oracle's Java ambitions

Java VM monitoring and the Health Center API. William Smith

White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux

Section 1.4. Java s Magic: Bytecode, Java Virtual Machine, JIT,

Useful metrics for Interpreting.NET performance. UKCMG Free Forum 2011 Tuesday 22nd May Session C3a. Introduction

Chapter 16: Virtual Machines. Operating System Concepts 9 th Edition

Why Threads Are A Bad Idea (for most purposes)

3 - Introduction to Operating Systems

Efficient Architectures for Low Latency and High Throughput Trading Systems on the JVM

Chapter 13 Embedded Operating Systems

Understanding Java Garbage Collection

MEASURING WORKLOAD PERFORMANCE IS THE INFRASTRUCTURE A PROBLEM?

Resource Aware Scheduler for Storm. Software Design Document. Date: 09/18/2015

System Software and TinyAUTOSAR

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Using In-Memory Computing to Simplify Big Data Analytics

Cognos8 Deployment Best Practices for Performance/Scalability. Barnaby Cole Practice Lead, Technical Services

IBM Tivoli Composite Application Manager for WebSphere

Real-time KVM from the ground up

The Design and Performance of Real-Time Java Middleware

Java Garbage Collection Basics

Top 10 Performance Tips for OBI-EE

Oracle Corporation Proprietary and Confidential

HP NonStop JDBC Type 4 Driver Performance Tuning Guide for Version 1.0

Extreme Performance with Java

Titolo del paragrafo. Titolo del documento - Sottotitolo documento The Benefits of Pushing Real-Time Market Data via a Web Infrastructure

Liferay Performance Tuning

Oracle WebLogic Thread Pool Tuning

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition

Operating System Structures

Chapter 2 System Structures

An Oracle White Paper July Oracle Primavera Contract Management, Business Intelligence Publisher Edition-Sizing Guide

Virtual Machine Learning: Thinking Like a Computer Architect

Garbage Collection in NonStop Server for Java

An Oracle White Paper September Advanced Java Diagnostics and Monitoring Without Performance Overhead

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

Comparison between scheduling algorithms in RTLinux and VxWorks

Distributed File Systems

Transcription:

Real-Time Java for Latency Critical Banking Applications Bertrand Delsart JavaRTS Technical Leader Author of Sun's RTGC technology R eal-time S ystem

Agenda Background Benefits of a Real-Time Java Virtual Machine Benefits of Real-Time Garbage Collectors Q&A 2

Agenda Background Benefits of a Real-Time Java Virtual Machine Benefits of Real-Time Garbage Collectors Q&A 3

Background Banking Trend Avoiding latencies (unexpected delays) has always been important Steve Rubinow (NYSE Group CTO): If you've got some trades going through at 10 milliseconds and some at 1 millisecond, that's a problem. Our customers don't like variance 4

Background Banking Trend Physical co-location is removing the external sources of jitter (variation of execution time) Application jitter is now much more visible Dave Cummings (BATS CEO) Five years ago we were talking seconds, now we're into the milliseconds. Five years from now we'll probably be measuring latency in microseconds Alistair Brown (LIME Brokerage CEO) Shortly, we'll be talking micro- versus milliseconds, and at that point speed will probably have less and less relevance 5

Background Categories of Application Predictability Non real-time Soft real-time Hard real-time No time-based deadlines > Standard programming logic > Example: UI, web services, algorithmic calculations Deadlines may be missed occasionally under well-defined conditions > Mainstream real-time needs > Example: Automated trading system, 3G telco router Deadlines cannot be missed > Typically highest priority on system > Example: Robotic motion control and management, Data feed processing 6

Background Traditional Design Choices to Improve Predictability Use mainstream programming tools and standard platforms OR Use customized lowerlevel tools and proprietary platforms > Everything is equally important; so try go faster to get everything done > Guessing game: no guarantee that deadlines will be met just postponed > Low infrastructure utilization > Lack of predictable solution > Predictable solution, but... > Expensive dedicated tools, training, headcount; longer development cycles, complicated maintenance > Challenging integration of real-time elements with the standard applications 7

Background Traditional Real-Time Design Choices: Examples Example 1: Global engineering conglomerate needs PLC control elements with hard real-time capabilities for industrial automation PC-oriented SBC boards cost ~20% of custom boards but have no integrated real-time solution OR Custom boards from a specialized provider are very costly and require more for software/tools Example 2: Leading financial services institution needs to scale its market-facing system while meeting Service Level Agreements Standard Java applications offer flexibility and scalability but GC pauses threaten SLAs OR Legacy system able to meet current SLAs but no longer viable with regard to maintainability and scalability 8

Background Real-Time Design Choices Use mainstream programming tools and standard platforms > Everything is equally important; try go faster to get everything done > Guessing game no guarantee that deadlines will be met > Low infrastructure utilization > Lack of predictable solution OR Use customized lowerlevel tools and proprietary platforms How about an open standards-based platform that formally deals > Predictable solution, but... > Expensive dedicated tools, training, headcount, longer development cycles, effort-intensive maintenance > Challenging integration of real-time elements with the standard applications with real-time challenges? 9

Background Real-Time Specification for Java (RTSJ) 1998 Real-Time Specification for Java (JSR-001) proposal submitted Joint Sun/IBM Many others: Ajile, Apogee, Motorola, Nortel, QNX, Thales, TimeSys, WindRiver 2002 2005 2007 2008 JSR-001 approved by the Java Community Process TimeSys Reference Implementation RTSJ update proposal submitted (JSR-282) - Apogee Aphelion - Sun Java Real-Time System - IBM's websphere RealTime RTGC added to Sun Java RTS Others companies implementing RTSJ (not yet certified) New Sun/IBM JSR 10

Agenda Background Benefits of a Real-Time Java Virtual Machine Benefits of Real-Time Garbage Collectors Q&A 11

RTSJ Use case 1: Send Market Data at a Fixed Rate Neither too late... nor too often! Mainstream Java solution: while (true) do { compute_data(); now = System.currentTimeMillis() Thread.sleep(next_period now); send_data(); next_period += period; } Problem: > Not guaranteed to wake-up quickly after the sleep call! 12

RTSJ RTSJ Benefit 1 : Priority Semantic You must specify the relative importance of the tasks, including with respect to the other processes. Mainstream setpriority(10); is not sufficient! RTSJ offers in Java usual real-time scheduling semantics > RealtimeThreads preempt non real-time ones > Higher priority threads preempt lower priority ones > Locks are properly handled (a low priority thread owning a critical resource will be boosted by the thread that requires it) 13

RTSJ Use case 1 revisited Code executed by a RealtimeThread setpriority(my_rtpriority); while (true) do { compute_data(); now = System.currentTimeMillis() Thread.sleep(next_period now); send_data(); next_period += period; } Problem: > What if a more important RT threads preempts me just before calling sleep? 14

RTSJ RTSJ Benefit 2: Rich Real-Time APIs RTSJ provides what you will find in most RT Operating Systems > Absolute Time Clock, Timers, Non Blocking Queues... RTSJ provides an additional layer to make your life simpler > Periodic Threads, Asynchronous Event Handlers, RawMemoryAccess, Deadline Miss Monitoring and Management, Asynchronous Transfer of Control... RTSJ optionally defines advanced APIs > Cost Overflow Monitoring and Management, Feasibility Analysis... 15

RTSJ Use case 1, RTSJ version Code executed by a RealtimeThread setpriority(my_rtpriority); setreleaseparameters(myperiodparam); while (true) do { compute_data(); RealtimeThread.waitForNextPeriod(); send_data(); } (other variants with Timers, AbsoluteTime wait,...) Problem: > Is this sufficient? 16

RTSJ Yes... if optimized for Determinism The fastest Garbage Collectors suspend all the threads while they recycle memory The fastest JIT compilers make some assumptions to generate more efficient code and must 'deoptimize' threads if the assumption becomes invalid Solution 1: > RTSJ defines additional threads optimized for determinism and isolated for GC jitter. > They are as deterministic as C/C++ code! 17

RTSJ NoHeapRealtimeThreads Code executed by a NoHeapRealtimeThread setpriority(my_rtpriority); setreleaseparameters(myperiodparam); while (true) do { compute_data(); RealtimeThread.waitForNextPeriod(); send_data(); } Problem: > What about memory allocation since 'isolated' from the GC? 18

RTSJ Memory areas for NHRTs Don't bother if 200 microseconds latencies are OK!!! ImmortalMemory for non recycled objects ScopedMemory for recycling > Memory areas not subject to the Garbage Collector > Per area counters to know how many threads are using an area > Objects automatically deleted when the count of their area is 0 > Dynamic read/write checks to guarantee the safety of this recycling 19

RTSJ Use case 1, ScopedMemory version Code executed by a NoHeapRealtimeThread while (true) do { scopedmemory1.enter(runnable); // sm1 recycled for the next loop } void run() { compute_data(); waitfornextperiod(); send_data(); } Problem: > Is send_data() endorsing read/write constraints? 20

Agenda Background Benefits of a Real-Time Java Virtual Machine Benefits of Real-Time Garbage Collectors Q&A 21

RTGCs in General Making Java Predictable, RTGC Real-Time GC > Essentially a garbage collector with knobs > Large interrupts are avoided at the cost of small, regular, and predictable collections > The GC runs often enough to recycle memory on time, depending on allocation and collection rates Several models/approaches exist > IBM, Aicas, Sun,... Way simpler from a coding point of view > Single heap > No read/write checks 22

RTSJ + RTGCs Overall System Model Non real-time Real-Time JVM Standard Java Heap > Regular Java threads Real-time code and existing, non real-time, code can communicate, share memory, state, and overall environment something not possible in current real-time solutions Soft real-time Hard real-time Standard Java Heap or Scoped or Immortal memory > Real-Time threads > Real-Time Garbage Collector Scoped/Immortal/Heap > NoHeapReal-Time threads > Real-Time threads > Hard Real-Time Garbage Collector 23

Java RTS Sun's RTGC Apply concept of policy to Henriksson's approach Goal: Hard RT latencies for high priority GC'd threads Solution: implement GC as real-time threads > Running at a priority lower than the hard RT threads > And possibly concurrently with the other threads Advantages > Scalable (no issues with multi-processor support) > Flexible 24

Java RTS Default RTGC Scheduling Policy NHRTs Priority Could run concurrently on another CPU Critical RT threads Boosted GC Work at GC Max prio Soft RT threads Run-to-block GC Start GC Work at low priority Time Thread doing work Thread pause priority interruption GC active/running Boosting (Remaining Memory Too Low) 25

Java RTS Use case 1 revisited Code executed by a hard RealtimeThread while (true) do { waitfornextperiod(); send_data(); } Code executed by a soft RealtimeThread while (true) do { compute_data(); waitfornextperiod(); } softrt.setdeadlinemisshandler(dmh) 26

Java RTS Use case 1 Deadline Miss Handler Hard Real-Time AsynchronousEventHandler void handleasyncevent() { quickly_compute_simpler_data(); softrtthread.scheduleperiodic(); } or void handleasyncevent() { softrttthread.setpriority(hardprio); softrtthread.scheduleperiodic(); } 27

Java RTS Use Case 2 : Events Driven Request with Deadlines A request is valid: > For a limited time > When a set of asynchronous input feeds dependent conditions are true Proposed design: > Use a high priority critical thread for the request > If necessary, rely on priority boosting to safely use locks to check the <condition,deadline> pair(s) > Use AsynchronousEventHandlers to process the input feeds > Potentially at different priorities (hard and/or soft) > Use Minimum Inter-arrival Time policies to handle overflows 28

Java RTS Use Case 3 : NASDAQ Reduce I/O Jitter and Context Switches I/O must not hold other requests Implemented Solution: > One thread per-cpu > One front-end to receive requests and executed non I/O ones > I/O requests dispatched to another thread > I/O completion can be seen as a new request by the front-end Benefits from Java RTS deterministic compilation and memory management but : > What if I/O requests can be processed at different rates? > Could I handle more non I/O requests? 29

Java RTS Use Case 3 : Why Care about Context Switches? This should not be your role! Risk : under-utilization of resources Scalable Design: > Chosen number of high priority time-critical front-end threads > Could even be at different priorities depending on the input stream > AsynchronousEventHandler to process I/Os at a lower priority > New I/O processing threads will automatically be created by the VM server thread pool to maximize the number of parallel requests > Requests started later can complete earlier > The server thread automatically grabs a new one... without context switch 30

Java RTS Sun Java RTS Unique Selling Proposition Sun's Java Real-Time System absolute execution predictability with all the benefits of the Java platform Truly predictable, sample latency numbers: > RTGC: 200 microseconds > NHRT: 20 microseconds Open > Based on open, community-driven standards Standard Java SE libraries SPARC Sun Java RTS VM SOLARIS 10 x86 Java RTS libraries RTLinux 31

Java RTS Customer Evaluations Over 500 companies and universities from more than 60 countries have evaluated Sun Java Real-Time System Some data points from them: Maximum Latency Required Evaluations by Industry < 10 micros 10-100 micros 100-1000 micros 1-10 millis 10-100 millis Financial services Telecom Military/ Aerospace Automotive Other industry Educational use Maximum latency Source: Evaluation download survey for Sun Java RTS 32

Product Overview Key Benefits of RTSJ TECHNICAL Maximize system utilization Cross-platform portability Leverage standard OS's Real-time tools BUSINESS Eliminate latency outliers > Save millions of $ lost due to missed market opportunities, productivity losses etc. Eliminate risks inherent in custom and proprietary solutions Leverage investment in existing Java code, skills Increase developer productivity using Java 33

Product Overview Key Benefits of RTSJ + RTGC TECHNICAL Maximize system utilization Cross-platform portability Leverage standard OS's Real-time tools Minimize solution complexity Better design / architecture choices BUSINESS Eliminate latency outliers > Save millions of $ lost due to missed market opportunities, productivity losses etc. Eliminate risks inherent in custom and proprietary solutions Leverage investment in existing Java code, skills Increase developer productivity using Java 34

Product Overview Key Benefits of Sun Java RTS TECHNICAL Maximize system utilization even more (hard + soft RT) Cross-platform portability Leverage standard OS's Real-time tools (DTrace) Minimize solution complexity Better design / architecture choices Easy integration of hard, soft, and non time-critical design elements BUSINESS Eliminate latency outliers > Save millions of $ lost due to missed market opportunities, productivity losses etc. Eliminate risks inherent in custom and proprietary solutions Leverage investment in existing Java code, skills Increase developer productivity using Java 35

Questions? Bertrand.Delsart@Sun.COM