Marcel Mitran – STSM, Architect Java on System zmmitran@ca.ibm.comNovember 20th, 2012IBM Java PackedObjects: An OverviewIB...
Important DisclaimersTHE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSESONLY.WHILST EFFO...
PackedObject Delivery and Intended UsePackedObject is an experimental feature in IBM J9 Virtual Machine.Goal(s) of Feature...
PackedObjects for IBMs Java        Features of todays Java work well in certain     ...changing how Java data is represent...
Speak to me in Java, I dont speak Native■   Java only speaks ‘Java’…      – Data typically must be copied/(de)serialized/m...
On-Heap PackedObjects Example■   Allows controlled layout of storage of data structures on the Java heap      – Reduces fo...
Off-Heap Packed Objects Example■   Enable Java to talk directly to the native data structure     – Avoid overhead of data ...
Example: Distributed Computing High-Level Architecture                                     Communication between nodes    ...
© 2012 IBM CorporationPage 9 Example: Inter-language CommunicationJava requires datacopies, marshalling and   COBOL     Ja...
PackedObjects 101■    A new PackedObject type for the Java language, which allows for:      – Direct access of data locate...
Scope of Implementation■    “@Packed” class annotation used to define a PackedObject class■    “@Length” field annotation ...
Code Snippets■    Packed class definition      ■   On-Heap Packed Allocation■    Off-heap Packed Allocation12             ...
Functionality Changes                    Current Java                                    PackedObjectData Field      ■   O...
Off Heap Benefit: Lowers Memory Footprint, increases performanceBefore                                                    ...
Copyright and Trademarks© IBM Corporation 2012. All Rights Reserved.IBM, the IBM logo, and ibm.com are trademarks or regis...
Upcoming SlideShare
Loading in …5
×

IBM Java PackedObjects

10,556 views

Published on

PackedObject is an experimental feature in IBM J9 Virtual Machine. Goal(s) of Feature: Improve serialization and I/O of Java objects Allow direct access to “native” (off-heap) data Allow for explicit source-level representation of compact data-structure Intended Use: Provide an opportunity for feedback and experimentation Not meant for production support Not a committed language change

Published in: Technology
2 Comments
17 Likes
Statistics
Notes
No Downloads
Views
Total views
10,556
On SlideShare
0
From Embeds
0
Number of Embeds
218
Actions
Shares
0
Downloads
116
Comments
2
Likes
17
Embeds 0
No embeds

No notes for slide

IBM Java PackedObjects

  1. 1. Marcel Mitran – STSM, Architect Java on System zmmitran@ca.ibm.comNovember 20th, 2012IBM Java PackedObjects: An OverviewIBM Software Group: Java Technology Centre © 2012 IBM Corporation
  2. 2. Important DisclaimersTHE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSESONLY.WHILST EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATIONCONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED.ALL PERFORMANCE DATA INCLUDED IN THIS PRESENTATION HAVE BEEN GATHERED IN A CONTROLLEDENVIRONMENT. YOUR OWN TEST RESULTS MAY VARY BASED ON HARDWARE, SOFTWARE ORINFRASTRUCTURE DIFFERENCES.ALL DATA INCLUDED IN THIS PRESENTATION ARE MEANT TO BE USED ONLY AS A GUIDE.IN ADDITION, THE INFORMATION CONTAINED IN THIS PRESENTATION IS BASED ON IBM’S CURRENTPRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE.IBM AND ITS AFFILIATED COMPANIES SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OFTHE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION.NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF:- CREATING ANY WARRANT OR REPRESENTATION FROM IBM, ITS AFFILIATED COMPANIES OR ITS ORTHEIR SUPPLIERS AND/OR LICENSORS2 © 2012 IBM Corporation
  3. 3. PackedObject Delivery and Intended UsePackedObject is an experimental feature in IBM J9 Virtual Machine.Goal(s) of Feature:■ Improve serialization and I/O of Java objects■ Allow direct access to “native” (off-heap) data■ Allow for explicit source-level representation of compact data-structureIntended Use:■ Provide an opportunity for feedback and experimentation – Not meant for production support – Not a committed language change3 © 2012 IBM Corporation
  4. 4. PackedObjects for IBMs Java Features of todays Java work well in certain ...changing how Java data is represented and Present data is accessed and used introduces native l scenarios, poorly in others... new efficiencies into the Java language ● Bloated Objects: Data headers and ● Shared Headers & No References references required to access and use data stored outside of Java ● No direct access to off-heap data: Java Native Interface or Direct Byte Buffers ● Direct access to native stored off-heap required when accessing. ● Redundant Data Copying: Copies of off- heap data required to incorporate/act-on ● Elimination of data copies changes to source data ● Suboptimal heap placement: Non- adjacent placement of objects in memory ● In-lined data allows for optimal caching slows down serialization, garbage collection4 © 2012 IBM Corporation
  5. 5. Speak to me in Java, I dont speak Native■ Java only speaks ‘Java’… – Data typically must be copied/(de)serialized/marshalled onto/off Java heap – Costly in path-length and footprint5 © 2012 IBM Corporation
  6. 6. On-Heap PackedObjects Example■ Allows controlled layout of storage of data structures on the Java heap – Reduces footprint of data on Java heap – No (de)serialization required I/O Native storage (20 bytes) Java heap JVM6 © 2012 IBM Corporation
  7. 7. Off-Heap Packed Objects Example■ Enable Java to talk directly to the native data structure – Avoid overhead of data copy onto/off Java heap – No (de)serialization required I/O Native storage (20 bytes) Meta Data JVM Java heap7 © 2012 IBM Corporation
  8. 8. Example: Distributed Computing High-Level Architecture Communication between nodes (RDMA, hyper-sockets, ORB, etc): Using Java packed objects, data can ● Data copy be moved between the ● (De)Serialization persistency and communication layers without being copied or (de)serialized onto/off the Java Data persistency on each heap node (DB, file-system, etc): ● Data copy ● (De)serialization DB DB JVM JVM App. App. Server Server Node Node8 © 2012 IBM Corporation
  9. 9. © 2012 IBM CorporationPage 9 Example: Inter-language CommunicationJava requires datacopies, marshalling and COBOL Java C/C++serialization acrosslanguage boundaries foo(…){ goo(…){ loo(…){ … … … goo(); loo(); } } }Java packed objectsavoids data copies, COBOL Java C/C++marshaling andserialization foo(…){ goo(…){ loo(…){ … … … goo(); loo(); } } }
  10. 10. PackedObjects 101■ A new PackedObject type for the Java language, which allows for: – Direct access of data located outside of the Java heap – Contiguous allocation of all objects data (objects and arrays) – Is not derived from Object, and hence dis-allows assignment and casting – Special BoxingPackedObject is glue to reference a PackedObject from Object java/lang/object java/lang/PackedObject java/math/BigDecimal etc… java/lang/PackedArray etc… java/lang/String java/lang/PackedString java/lang/HashMapEntry java/lang/BoxedPackedObject java/lang/PackedHashMapEntry■ Current Java Capabilities – Current Java logic requires language interpreters and data copies for execution. – PackedObjects eliminate data copies across the Java Native Interface and the need to design and maintain Direct Byte Buffers■ Using PackedObjects: annotation-based (or later a packed key word) above a class definition is required to create a packed class. The class instances can be accessed and modified identically to current Java objects10 © 2012 IBM Corporation
  11. 11. Scope of Implementation■ “@Packed” class annotation used to define a PackedObject class■ “@Length” field annotation used to specify length of PackedObject arraysProposed Initial Rules■ Packed types must directly subclass PackedObject■ Packed inlining can only happen for field declarations which are primitives, PackedObjects or arrays of PackedObjects■ Fields made up of arrays must provide a length that is a compile time constant■ Regular Java primitive types cannot be used to declare a PackedObject array. Boxed types for primitive arrays must be used instead.■ A field declaration cannot introduce a circular class dependency■ When a PackedObject is instantiated, only the constructor for the top-level PackedObject is called■ Local variable assignment and parameter passing of a PackedObject is copy-by-reference■ BoxedPackedObject is used to box a PackedObject with an Object reference■ Allocating a PackedObject using the new keyword creates an on-heap PackedObject■ Off-heap PackedObject creation is done using factory method provided in the class library11 © 2012 IBM Corporation
  12. 12. Code Snippets■ Packed class definition ■ On-Heap Packed Allocation■ Off-heap Packed Allocation12 © 2012 IBM Corporation
  13. 13. Functionality Changes Current Java PackedObjectData Field ■ Object fields limited to primitives or ■ When allocating a PackedObject, allAllocation references to other objects; non- corresponding data fields get allocatedand Storage primitives must be initialized and copied simultaneously and packed into a single into a format understood by Java. contiguous object (rather than referenced). ■ Headers for child objects copied onto ■ No headers for child objects which allChild objects the Java heap when accessed. share global header on the PackedObject. Arrays ■ For arrays of objects each element in an ■ Arrays packed together contiguously array has its own header and a under one common header; array length reference to it. The elements are not marked in PackedObject header. Full contiguous in memory. access to elements in array and bounds checking still performed.Off-heap ■ Data can not be accessed or modified ■ Data that does not exist in Java can be outside of the Java heap. Data must be accessed and modified directly by using converted into a Java version and then the datas memory location. The Java this copy can then be accessed and Virtual Machine takes care of the manipulated. accessors and modifiers internally.13 © 2012 IBM Corporation
  14. 14. Off Heap Benefit: Lowers Memory Footprint, increases performanceBefore Native memory ● Java requires objects to be in primitive form to be Header accessed directly* Header Hea ● If objects are not in primitive form, references and Header Data der Data copies required to access data; time-consuming Data conversion process Data reference ● When objects are graphed onto the heap, they reference reference reference are placed randomly and occupy more space than is needed He Java Heap ad HEADER Da e er Header ta C r d Memory bloat occurs due to data copies (data ● Data Copy Hea opy opy must be accessed and copied, including headers) Header taC Data Copy Da *without the use of JNI or DBB After ● PackedObjects eliminate requirement for objects to be in primitive form ● PackedObjects can be accessed directly from source without the redundant copying; no conversion ● PackedObject allocates and packs all data fields HEADER (including other PackedObject and arrays) into a Direct Access, No Copy single well defined contiguous storage area14 © 2012 IBM Corporation
  15. 15. Copyright and Trademarks© IBM Corporation 2012. All Rights Reserved.IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of InternationalBusiness Machines Corp., and registered in many jurisdictions worldwide.Other product and service names might be trademarks of IBM or other companies.A current list of IBM trademarks is available on the Web – see the IBM “Copyright andtrademark information” page at URL: www.ibm.com/legal/copytrade.shtml15 © 2012 IBM Corporation

×