1 Java Subtype Tests in Real-Time Krzysztof Palacz, Jan Vitek University of Purdue Presented by: Itay Maman.

Slides:



Advertisements
Similar presentations
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Advertisements

DBMS 2001Notes 4.2: Hashing1 Principles of Database Management Systems 4.2: Hashing Techniques Pekka Kilpeläinen (after Stanford CS245 slide originals.
Sorting Comparison-based algorithm review –You should know most of the algorithms –We will concentrate on their analyses –Special emphasis: Heapsort Lower.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
Advanced Database Discussion B Trees. Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if.
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
TREES Chapter 6. Trees - Introduction  All previous data organizations we've studied are linear—each element can have only one predecessor and successor.
CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking.
Incremental Algorithms for Dispatching in Dynamically Typed Languages Yoav Zibin Technion—Israel Institute of Technology Joint work with: Yossi (Joseph)
CS 206 Introduction to Computer Science II 09 / 24 / 2008 Instructor: Michael Eckmann.
Trees Chapter 8.
Multiversion Access Methods - Temporal Indexing. Basics A data structure is called : Ephemeral: updates create a new version and the old version cannot.
BTrees & Bitmap Indexes
Fall 2007CS 2251 Trees Chapter 8. Fall 2007CS 2252 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
Temporal Indexing MVBT. Temporal Indexing Transaction time databases : update the last version, query all versions Queries: “Find all employees that worked.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part B Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
Efficient Parallelization for AMR MHD Multiphysics Calculations Implementation in AstroBEAR.
B + -Trees (Part 1) Lecture 20 COMP171 Fall 2006.
B + -Trees (Part 1). Motivation AVL tree with N nodes is an excellent data structure for searching, indexing, etc. –The Big-Oh analysis shows most operations.
B + -Trees (Part 1) COMP171. Slide 2 Main and secondary memories  Secondary storage device is much, much slower than the main RAM  Pages and blocks.
General Trees and Variants CPSC 335. General Trees and transformation to binary trees B-tree variants: B*, B+, prefix B+ 2-4, Horizontal-vertical, Red-black.
Chapter 12 Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define trees as data structures Define the terms.
B + -Trees COMP171 Fall AVL Trees / Slide 2 Dictionary for Secondary storage * The AVL tree is an excellent dictionary structure when the entire.
CS4432: Database Systems II
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
Chapter 61 Chapter 6 Index Structures for Files. Chapter 62 Indexes Indexes are additional auxiliary access structures with typically provide either faster.
Data Structures Arrays both single and multiple dimensions Stacks Queues Trees Linked Lists.
Trees. Tree Terminology Chapter 8: Trees 2 A tree consists of a collection of elements or nodes, with each node linked to its successors The node at the.
1 Efficient Subtyping Tests with PQ-Encoding Jan Vitek University of Purdue work of: Yoav Zibin and Yossi Gil Technion — Israel Institute of Technology.
1 Trees Tree nomenclature Implementation strategies Traversals –Depth-first –Breadth-first Implementing binary search trees.
The X-Tree An Index Structure for High Dimensional Data Stefan Berchtold, Daniel A Keim, Hans Peter Kriegel Institute of Computer Science Munich, Germany.
Chapter 5 Binary Trees. Definitions and Properties A binary tree is made up of a finite set of elements called nodes A binary tree is made up of a finite.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Spring 2010CS 2251 Trees Chapter 6. Spring 2010CS 2252 Chapter Objectives Learn to use a tree to represent a hierarchical organization of information.
TECH Computer Science Dynamic Sets and Searching Analysis Technique  Amortized Analysis // average cost of each operation in the worst case Dynamic Sets.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Computer Science CPSC 322 Lecture 9 (Ch , 3.7.6) Slide 1.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
ICOM 4035 – Data Structures Lecture 3 – Bag ADT Manuel Rodriguez Martinez Electrical and Computer Engineering University of Puerto Rico, Mayagüez ©Manuel.
Trees – Chapter 9 Slides courtesy of Dr. Michael P. Frank University of Florida Dept. of Computer & Information Science & Engineering.
Starting at Binary Trees
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture17.
Data Structures Trees Phil Tayco Slide version 1.0 Apr. 23, 2015.
Chapter 11 Hash Tables © John Urrutia 2014, All Rights Reserved1.
Space-Efficient Online Computation of Quantile Summaries SIGMOD 01 Michael Greenwald & Sanjeev Khanna Presented by ellery.
ICOM 4035 – Data Structures Lecture 4 – Set ADT Manuel Rodriguez Martinez Electrical and Computer Engineering University of Puerto Rico, Mayagüez ©Manuel.
Spatial Indexing Techniques Introduction to Spatial Computing CSE 5ISC Some slides adapted from Spatial Databases: A Tour by Shashi Shekhar Prentice Hall.
R-Trees: A Dynamic Index Structure For Spatial Searching Antonin Guttman.
Chapter 10: Trees A tree is a connected simple undirected graph with no simple circuits. Properties: There is a unique simple path between any 2 of its.
Chapter 8 Binary Search Trees. Chapter 8: Binary Search Trees 8.1 – Trees 8.2 – The Logical Level 8.3 – The Application Level 8.4 – The Implementation.
CSE 2331/5331 Topic 8: Binary Search Tree Data structure Operations.
Monte Carlo Linear Algebra Techniques and Their Parallelization Ashok Srinivasan Computer Science Florida State University
Course: Programming II - Abstract Data Types HeapsSlide Number 1 The ADT Heap So far we have seen the following sorting types : 1) Linked List sort by.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
(c) University of Washington20-1 CSC 143 Java Trees.
1 Trees. 2 Trees Trees. Binary Trees Tree Traversal.
Contents. Goal and Overview. Ingredients. The Page Model.
Data Structures: Disjoint Sets, Segment Trees, Fenwick Trees
Multiway Search Trees Data may not fit into main memory
Computational Models Database Lab Minji Jo.
Extra: B+ Trees CS1: Java Programming Colorado State University
Temporal Indexing MVBT.
Binary Tree and General Tree
Data Structures and Database Applications Binary Trees in C#
CPSC-310 Database Systems
B+-Trees and Static Hashing
Introduction to Data Structure
Presentation transcript:

1 Java Subtype Tests in Real-Time Krzysztof Palacz, Jan Vitek University of Purdue Presented by: Itay Maman

2 Outline Subtyping tests Previous work R&B Overview Ranges (SI test) Buckets (MI test) Results Conclusions & Future Research

3 Given a hierarchy (T, ≺ ) T is a set of types ≺ is a partial order over T (reflexive, transitive and anti- symmetric) called subtype relation The query c ≺ p is a subtype test In the above test, C is the Client type, while P is the Provider type Java: Class inheritance test ( “ extends ” ) is an SI subtype test Interface inheritance test ( “ implements ” ) is an MI subtype test Subtyping tests Does a type extend a given class? Does a type implement a given interface?

4 Subtyping tests - Requirements Queries must run in constant time Space overhead must not significantly increase system footprint Size of emitted code Memory needed for the data structure Support for dynamic loading of classes Ideally, should be able to load a class without blocking concurrent subtype queries, invoked by other threads

5 Na ï ve solution subtypeOf(type_info cl, type_info pr) { if(cl == pr || cl.cache == pr) return true; if(pr.isInterface return implements(cl, pr); else return extends(cl, pr); } implements(type_info cl, type_info pr) { for(int i = 0; i < pr.interfaces.length; ++i) if(cl == pr.interfaces[i]) { cl.cache = pr; return true; } return false; } extends(type_info cl, type_info pr) { for(type_info t = cl.parent; t != null; t = t.parent) if(t == pr) { cl.cache = pr; return true; } return false; }

6 Previous Work SI (single inheritance) hierarchies Bit matrix – Space inefficient Relative numbering [Schubert ’ 83] Cohen's algorithm [Cohen ’ 91] MI (multiple inheritance) hierarchies Packed Encoding (PE) - generalization of Cohen's algorithm [Krall, Vitek and Horspool ’ 97] Bit-vectors [Krall, Vitek and Horspool ’ 97a] PQ Encoding – Adapts Relative numbering to MI [Zibin, Gil ’ 01] Incremental technique in production JVMs (HotSpot, Jalapeno) SI: Cohen ’ s algorithm with arrays of a fixed size (inlined) MI: Linear search over a list of displays

7 Ranges (SI test): The basics Based on Scubert ’ s technique 1) Ranges of children are subranges of their parents ’ 2) Ranges of siblings are disjoint Range assignment: Via a pre-order walk c ≺ p  p.low ≤ c.low < p.high [0,8] A B D C E F [4,7] [6,0] [5,0] [1,3] [2,0]

8 Only the low bound is observed for the client A leaf type can reuse its parent ’ s low bound Ranges (SI test): Refinements Reminder: c ≺ p  p.low ≤ c.low < p.high insert(type_info t) { t.high = 0; t.low = (t.parent == null) ? 1 : t.parent.low; } The high bound can be calculated on-demand. When a type is loaded it is initialized with 0 Conclusion:

9 Ranges (SI test): extends() extends() implements an SI test If the provider ’ s high bound is not present, its value is computed by invoking promote() extends(type_info cl, type_info pr) { if(pr.low <= cl.low && cl.low < pr.high) return true; if(pr.high != 0) return false; promote(pr); return (pr.low <= cl.low && cl.low < pr.high); }

10 Steps for computing range assignments: Step 1. Place all type_info items in an array using a pre-order walk Leaf types are stored once Non-leaves are stored twice: once before all their subtypes, and once after Ranges (SI test): promote(), 1/3 ABDBCEFCA type_info: A B D C E F

11 order: Step 2. Perform a left-to-right iteration over the array. Compute order[i] for each index Start with 1 Increase whenever a non-leaf type is encountered Ranges (SI test): promote(), 2/3 A B D C E F ABDBCEFCA type_info:

12 [1,6] Perform a right-to-left iteration over the array (end to beginning) Right position of a non-leaf type: assign order[i] to its high bound Left position of a non-leaf type: assign order[i] to its low bound Leaf type: assign order[i] to its low bound order: Ranges (SI test): promote(), 3/3 ABDBCEFCA type_info: A B D C E F A.h = 6C.h = 5F.l = 4E.l = 4B.h = 3C.l = 4D.l = 2B.l = 2A.l = 1 [4,0] [2,0] [4,5] [2,3]

13 Given the following properties of the promote() algorithm … A type ’ s high bound is updated before its subtypes are processed A type ’ s high bound is updated before its low bound Sibling types are processed on a descending order of their low bounds … It is guaranteed that the invariants of Scubert ’ s technique are kept at any given point during its operation: 1) Ranges of children are subranges of their parents ’ 2) Ranges of siblings are disjoint Ranges (SI test): Thread-safety Promote() is thread-safe Conclusion:

14 Low, constant memory demands (32 bits per class) Query time Is constant in vast majority of the tests In RT systems, promote() can be used eagerly (invoked on class load), to ensure constant query time Code is thread-safe => can handle dynamically loaded classes. No need to “ stop the world ” Performance improvement of: ** ??? ** Ranges (SI test): Summary

15 Buckets (MI test): The basics Based on the Packed-Encoding algorithm (PE) Each interface is assigned to a bucket, and receives a unique id (iid) within that bucket Two interfaces in a bucket do not have a common subtype c ≺ p  c.display[p.bucket] == p.iid type_info { … byte[] display; } interface_info { byte iid; byte bucket; }

16 Buckets (MI test): assignment 1/3 Computing bucket assignments: Case 1. Loading an interface. If all buckets are full or no bucket exists, create a new bucket Choose the bucket with the fewest interfaces among ‘ M ’ most recently created buckets. (Typically, M = 5) Create a new iid value for the interface, which is unique within the bucket. A bucket cannot reuse ‘ old ’ (i.e: previously used) iid-s

17 Buckets (MI test): assignment 2/3 Case 2. Loading a class. If the interfaces implemented by the class are of different buckets, initialize the array of displays: cl.display[i.bucket] = i.iid; // for each implemented interface i Otherwise, the class is a subtype of (at least) two interfaces of the same bucket. These interfaces must be reassigned to other buckets (Details on the next slide)

18 Case 2 contd. Loading a class/Reassignment 1) For each bucket b, with k interfaces implemented by a class C: a) Create k-1 new buckets b) k-1 interfaces are assigned to the new buckets c) Remaining interfaces from b are evenly spread among b and the new buckets An interface ’ s iid is not changed when the interface is reassigned A bucket cannot reuse an iid of an interfaces that was reassigned 2) Iterate over all loaded classes and update their display[] array: Existing entries remain unchanged New entries are added for the new buckets Consequently, in a given class ’ s display[] an iid of the same interface may appear more than once. 3) Iterate over all reassigned interfaces, update their bucket value Buckets (MI test): assignment 3/3

19 Buckets (MI test): Thread-safety Given the following properties of the Buckets algorithm … An interface never changes its iid A bucket cannot reuse an ‘ old ’ iid Updated display[] arrays contain the old entries as well as the new ones An interface ’ s bucket value is changed only after display[] s are updated … It is guaranteed that an implements() query will always yield the correct result

20 The END

21 Definitions ≺ d is the transitive reduction of ≺ ≺ is the transitive closure of ≺ d Formally, a ≺ d b iff a ≺ b and there is no c such that a ≺ c ≺ b, a≠c≠b. Also, ancestors(a) ≡ {b ∈ T| a ≺ b}, descendants(a) ≡ {b ∈ T| b ≺ a} parents(a) ≡ {b ∈ T| a ≺ d b}, children(a) ≡ {b ∈ T| b ≺ d a} roots ≡ {a ∈ T| parents(a)= ∅ }, leaves ≡ {a ∈ T| children(a)= ∅ } level(a) ≡ 1+max{level(b)| b ∈ parents(a)} Single inheritance (SI) vs. multiple inheritance (MI) In SI, for each a ∈ T, |parents(a)|≤1

22 Cohen's algorithm Partition the hierarchy into levels a ≺ b  l b ≤ l a and r a [l b ] = id b l b is level(b), id b is a unique identifier within the level

23 Range compression Apply postorder on some spanning forest a ≺ b  l b [i] ≤ id a ≤ r b [i], for some i {2,5,6}{1,2,3}

24 Ranges (SI test): promote() Computes range assignments: Place all types in an array using a pre-order walk Leaf types are stored once Non-leaves are stored twice: once before all their subtypes, and once after Perform a left-to-right iteration over the array. Compute order[i] for each index Start with 1 Increase whenever a non-leaf type is encountered Perform a right-to-left iteration over the array (end to beginning) Leaf type: assign (order[i], 0) to (low, high) Right position of a non-leaf type: assign order[i] to its high bound Left position of a non-leaf type: assign order[i] to its low bound