Collections Classes for Real-Time and High-Performance Applications. July 4, 2005 Jean-Marie Dautelle



Similar documents
Validating Java for Safety-Critical Applications

JAVA COLLECTIONS FRAMEWORK

Java Coding Practices for Improved Application Performance

Data Structures in the Java API

Java Software Structures

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

The Java Collections Framework

Practical Performance Understanding the Performance of Your Application

Java SE 8 Programming

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

Collections in Java. Arrays. Iterators. Collections (also called containers) Has special language support. Iterator (i) Collection (i) Set (i),

A Comparative Study on Vega-HTTP & Popular Open-source Web-servers

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

Low level Java programming With examples from OpenHFT

Symbol Tables. Introduction

JBoss Data Grid Performance Study Comparing Java HotSpot to Azul Zing

Class 32: The Java Collections Framework

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

Big O and Limits Abstract Data Types Data Structure Grand Tour.

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

Java Interview Questions and Answers

An Oracle White Paper September Oracle Database Smart Flash Cache

Scaling Objectivity Database Performance with Panasas Scale-Out NAS Storage

1 of 1 24/05/ :23 AM

Realtime Linux Kernel Features

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

Liferay Portal Performance. Benchmark Study of Liferay Portal Enterprise Edition

How To Store Data On An Ocora Nosql Database On A Flash Memory Device On A Microsoft Flash Memory 2 (Iomemory)

Programming Embedded Systems

Benchmarking Cassandra on Violin

Garbage Collection in NonStop Server for Java

Performance Analysis of Web based Applications on Single and Multi Core Servers

Cloud Computing and Robotics for Disaster Management

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.

Ryusuke KONISHI NTT Cyberspace Laboratories NTT Corporation

Instrumentation Software Profiling

An Oracle White Paper March Load Testing Best Practices for Oracle E- Business Suite using Oracle Application Testing Suite

Persistent Binary Search Trees

Designing and Implementing Scalable Applications with Memcached and MySQL

11.1 inspectit inspectit

Thesis Proposal: Improving the Performance of Synchronization in Concurrent Haskell

Summer Internship 2013 Group No.4-Enhancement of JMeter Week 1-Report-1 27/5/2013 Naman Choudhary

Efficient Data Structures for Decision Diagrams

PERFORMANCE ENHANCEMENTS IN TreeAge Pro 2014 R1.0

Original-page small file oriented EXT3 file storage system

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Job Reference Guide. SLAMD Distributed Load Generation Engine. Version 1.8.2

Enterprise Deployment: Laserfiche 8 in a Virtual Environment. White Paper

Understanding Java Garbage Collection

<Insert Picture Here> Btrfs Filesystem

Berlin Mainframe Summit. Java on z/os IBM Corporation

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

Accelerating Enterprise Applications and Reducing TCO with SanDisk ZetaScale Software

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

Oracle Database Security and Audit

Design Patterns for Packet Processing Applications on Multi-core Intel Architecture Processors

General Introduction

Node-Based Structures Linked Lists: Implementation

Performance Optimization For Operational Risk Management Application On Azure Platform

Performance Improvement In Java Application

Introduction to DISC and Hadoop

CSE 2123 Collections: Sets and Iterators (Hash functions and Trees) Jeremy Morris

No no-argument constructor. No default constructor found

OpenProdoc. Benchmarking the ECM OpenProdoc v 0.8. Managing more than documents/hour in a SOHO installation. February 2013

Data Structures in Java. Session 15 Instructor: Bert Huang

Microsoft Windows Server 2003 with Internet Information Services (IIS) 6.0 vs. Linux Competitive Web Server Performance Comparison

Lecture 2: Data Structures Steven Skiena. skiena

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

Java Virtual Machine Locks

A Randomized Dynamic Program Analysis Technique for Detecting Real Deadlocks

JProfiler: Code Coverage Analysis Tool for OMP Project

Japan Communication India Skill Development Center

Task Scheduling in Hadoop

Adobe LiveCycle Data Services 3 Performance Brief

Business white paper. HP Process Automation. Version 7.0. Server performance

Precise and Efficient Garbage Collection in VMKit with MMTk

Chapter 3. Technology review Introduction

PARALLELS CLOUD SERVER

Performance Evaluation and Optimization of A Custom Native Linux Threads Library

Delivering Quality in Software Performance and Scalability Testing

Tivoli IBM Tivoli Web Response Monitor and IBM Tivoli Web Segment Analyzer

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Computer Science 483/580 Concurrent Programming Midterm Exam February 23, 2009

A Practical Method to Diagnose Memory Leaks in Java Application Alan Yu

Java Bit Torrent Client

Real Time Cloud Computing

AgencyPortal v5.1 Performance Test Summary Table of Contents

Accelerating Hadoop MapReduce Using an In-Memory Data Grid

StreamBase White Paper StreamBase versus Native Threading. By Richard Tibbetts Co-Founder and Chief Technology Officer, StreamBase Systems, Inc.

Transcription:

Collections Classes for Real-Time and High-Performance Applications July 4, 2005 Jean-Marie Dautelle

Introduction The real-time specification for Java (RTSJ) aims to make your code more time predictable. But, this predictability can easily be ruined by using standard library classes. In this presentation we will look at potential problems with the standard Java collection framework and how these problems can be solved by using alternative implementations such as the one provided by the open-source Javolution library (http://javolution.org)

Standard Collections Overview Interface based. java.util.list java.util.map java.util.set... Interface approach allow for drop-in replacement. Generic since Java 5.0 Oriented toward throughput Time predictability and RTSJ (Real Time Specification for Java ) not taken into consideration by the implementation.

Standard Collections Timing Issues Users may encounter unexpected large delays due to: Large arrays being allocated and copied (e.g. ArrayList capacity increase). Sudden burst of computation (e.g. HashMap rehashing all its map entries). Long garbage collection pauses (full GC) due to memory fragmentation when large arrays are allocated (e.g. ArrayList)

Standard Collections Memory Issues Memory allocation might be performed surreptitiously after the collection creation and cause RTSJ memory clashes: HashMap.put(key,value) may create new entries allocated from the current memory area, resulting in memory clash when executing in ScopedMemory and the map is in ImmortalMemory/HeapMemory Iterator objects may be internally allocated, e.g. Collection.addAll(Collection), Map.putAll(Map) causing memory leak when executing in ImmortalMemory Objects may be allocated at first use only (lazy initialization), e.g. Map.keySet(), Map.values() causing further unexpected illegal access errors.

Javolution Collections Overview Provides very few classes but they are substitute for most of java.util.* collection implementations. For example: IdentityHashMap would be a FastMap with an identity key comparator. Both HashMap and LinkedHashMap can be replaced by a FastMap (same for HashSet/LinkedHashSet and FastSet) Implements standard collection interfaces. Generic when built with the ant target 1.5, but can also be built for any Java VM/Compiler or even J2ME.

Time-Predictability Collection capacity increases smoothly. Small increments (avoid large arrays allocations). Pre-allocation can be performed using profiling information from previous executions (Ref. AllocationProfile) No internal array resize or copy. FastTable (random access list) uses multi-dimensional arrays to avoid resizing and copying its internal arrays. Allocated arrays are small to avoid memory fragmentation. No rehashing. Map entries have their own entry table. When the size increases beyond capacity, new (larger) tables are allocated for the new entries (the old entries are not moved and do not need rehashing).

Memory Allocation Policy No memory allocation ever performed unless the collection size exceeds its capacity which may be specified at creation. Collections maintain internal pools of entries (map) or nodes (list). When an entry/node is removed from the collection, it is automatically restored to the pool. The initial capacity determinates the number of entries/nodes allocated at creation. Lazy initialization is forbidden. Iterations can be performed without allocating iterator objects (direct record iterations)

RTSJ - Compliance No memory clash (e.g. IllegalAssignmentError) regardless of the current memory area or the operation being performed. Collections can be allocated in ImmortalMemory (e.g. global static collections) and accessed by all threads including NoHeapRealtimeThread Integrated with Javolution real-time framework which allows for transparent object recycling. Throw-away collections can be pre-allocated in ImmortalMemory (usable by all threads) and automatically recycled (necessary as ImmortalMemory is never garbage collected).

Concurrency and Synchronization Collection classes support concurrent access and iterations without synchronization as long as the collection records are not removed (e.g. FastMap look-up table). To keep read access unsynchronized when records are deleted, applications may either: Replace the whole collection. Or (better) set the record value to null instead of removing it. A read-only view on any collections is also provided ( unmodifiable() method). This view is thread safe when the collection is thread-safe (records not removed).

Others. Support custom values comparator (collections) and key/value comparator (maps). For example, a lexical comparator can be used to retrieve objects based upon their character sequence content (regardless of their actual type). BSD-License allows applications to reuse/modify the collection source code as long as the copyright header is kept intact.

Conclusion Javolution collections behavior is highly time predictable (in the micro-second range). By favoring an incremental approach and by allocating small objects, the work and performance of concurrent / incremental garbage collectors is significantly improved. Finally, these collections are fast, very fast (as shown in the performance report in annex) proving that real-time can sometimes be real-fast.

Biography Jean-Marie holds a master degree of electrical engineering (Orsay University, France) and a post graduate degree in Information Processing and Simulation. Jean-Marie has been with Raytheon in Marlborough for 7 years. He is the project owner and main author of two opensource projects: Javolution (http://javolution.org) and JScience (http://jscience.org). Jean-Marie work has been published in several magazines such as Dr Dobbs Journal and the Java Developer Journal.

Annex: Performance Report Relative performance of Javolution Collections classes versus Standard Collections classes. The platform is a Single-CPU Intel Pentium 4 3.20GHz running Linux 2.4 The benchmark source code and executable are available from the Javolution home page. Add (new) - The collection is created (using the new keyword), populated, then discarded (throw-away collections). Add (recycled) - The collection is cleared, populated, then reused (static collections or throw-away collections in PoolContext).

List Add Performance List - Add 70 Nano-Seconds 60 50 40 30 20 10 FastTable (new) FastTable (recycled) ArrayList (new) ArrayList (recycled) FastList (new) FastList (recycled) LinkedList (new) LinkedList (recycled) 0 1 2 3 4 Log10(Size)

List Iteration Performance List - Iteration Nano-Seconds 40 35 30 25 20 15 10 FastTable - Iterator FastTable - get(i++) ArrayList - Iterator ArrayList - get(i++) FastList - Iterator 5 0 1 2 3 4 Log10(Size) FastList - getnextnode() LinkedList - Iterator

Map - Put Performance Map - put 250 Nano-Seconds 200 150 100 50 FastMap (new) FastMap (recycled) HashMap (new) HashMap (recycled) LinkedHashMap (new) 0 1 2 3 4 Log10(Size) LinkedHashMap (recycled)

Map Iteration Performance Map - Iteration Nano-Seconds 50 45 40 35 30 25 20 15 10 5 0 1 2 3 4 Log10(Size) FastMap - Iterator FastMap - getnextentry() HashMap - Iterator LinkedHashMap - Iterator

Map Get Performance Map - get 60 50 Nano-Seconds 40 30 20 10 FastMap HashMap LinkedHashMap 0 1 2 3 4 Log10(Size)

Set Add Performance Set - Add 250 Nano-Seconds 200 150 100 50 FastSet (new) FastSet (recycled) HashSet (new) HashSet (recycled) LinkedHashSet (new) 0 1 2 3 4 Log10(Size) LinkedHashSet (recycled)

Set Iteration Performance Set - Iteration 60 Nano-Seconds 50 40 30 20 10 FastSet - Iterator FastSet - getnextrecord() HashSet - Iterator LinkedHashSet - Iterator 0 1 2 3 4 Log10(Size)

Set Contains Performance Set - Contains Nano-Seconds 50 45 40 35 30 25 20 15 10 5 0 1 2 3 4 Log10(Size) FastSet HashSet LinkedHashSet