A Comprehensive Evaluation of Object Scanning Techniques ∗

A Comprehensive Evaluation of Object Scanning Techniques ∗

A Comprehensive Evaluation of Object Scanning Techniques ∗ Robin Garner Stephen M Blackburn Daniel Frampton Research School of Computer Science Australian National University Canberra, ACT, 0200, Australia fRobin.Garner,Steve.Blackburn,[email protected] Abstract to identify and then follow all reference fields within every reach- At the heart of all garbage collectors lies the process of identifying able object. For reference counting collectors, once an object’s ref- and processing reference fields within an object. Despite its key erence count falls to zero, each of its referents must be identified role, and evidence of many different implementation approaches, and have its reference count decremented. The process of reference to our knowledge no comprehensive quantitative study of this de- field identification is known as object scanning. In order to be pre- sign space exists. The lack of such a study means that implementers cise in the absence of hardware support, object scanning requires must rely on ‘conventional wisdom’, hearsay, and their own costly assistance from the language runtime. Otherwise, tracing must con- analysis. Starting with mechanisms described in the literature and servatively assume all fields are references [6, 7, 14]. This paper a variety of permutations of these, we explore the impact of a quantitatively explores the design tradeoffs for object scanning in number of dimensions including: a) the choice of data structure, precise garbage collectors. b) levels of indirection from object to metadata, and c) specializa- Object scanning is performance-critical since it constitutes the tion of scanning code. We perform a comprehensive examination of backbone of the tracing mechanism, and therefore may be exe- these tradeoffs on four different architectures using eighteen bench- cuted millions of times for each garbage collection. The extensive marks and hardware performance counters. We inform the choice literature on garbage collection records a variety of object scan- of mechanism with a detailed study of heap composition and object ning mechanisms, but despite its performance-critical role, to our structure as seen by the garbage collector on these benchmarks. Our knowledge there has been no prior study quantitatively evaluating results show that choice of scanning mechanism is important. We the various approaches. As we show here, a detailed understanding find that a careful choice of scanning mechanism alone can im- of these tradeoffs informs the design of the best performing object prove garbage collection performance by 16% and total time by scanning mechanisms. 2.5%, on average, over a well tuned baseline. We observe sub- The mechanism for scanning an object typically involves pars- stantial variation in performance among architectures, and find that ing metadata that is explicitly or implicitly associated with the ob- some mechanisms–particularly specialization, layout of reference ject. The means of parsing and the form of the metadata can vary fields in objects, and encoding metadata in object headers–yield widely from one implementation to another. We identify four ma- consistent, significant advantages. jor dimensions in the design space: i) compiled versus interpreted evaluation of metadata, ii) encoding and packing of metadata, iii) levels of indirection between each object and its metadata, and iv) Categories and Subject Descriptors D.3.4 [Programming Lan- variations in object layout. guages]: Processors—Memory management (garbage collection) To inform our study of design tradeoffs, we first perform a de- tailed analysis of heap composition and object structure as seen by General Terms Design, Performance, Algorithms the garbage collector. We conduct our study within Jikes RVM [1], Keywords Java, Mark-Sweep a high performance research JVM with a well tuned garbage collec- tion infrastructure [4]. First, to characterize the workload seen by any scanning mechanism, we execute eighteen benchmarks from 1. Introduction the DaCapo [5] and SPEC [16, 17] suites, and at regular intervals Enumerating object reference fields is key to all precise garbage examine the heap and establish the distribution of object layouts collectors. For tracing collectors, liveness is established via a tran- among traced objects. We were not surprised to find that a rela- sitive closure from some set of roots. This requires the collector tively small number of object layout patterns account for the vast majority of scanned objects. We include in this study the extent to ∗ This work is supported by ARC DP0452011 and DP0666059. Any opin- which packing of reference fields within objects changes the distri- ions, findings and conclusions expressed herein are those of the authors and bution of layout patterns. do not necessarily reflect those of the sponsors. Guided by this information, we conduct a performance anal- ysis of various object scanning implementation alternatives. We evaluate each alternative on four architectures against the DaCapo and SPEC suites. We observe substantial variation in performance Permission to make digital or hard copies of all or part of this work for personal or among architectures but find that some mechanisms yield consis- classroom use is granted without fee provided that copies are not made or distributed tent, significant advantages, averaging 16% or more relative to a for profit or commercial advantage and that copies bear this notice and the full citation well tuned baseline. Specifically, we find that metadata encoding on the first page. To copy otherwise, to republish, to post on servers or to redistribute offers consistent modest advantages, object field reordering gives to lists, requires prior specific permission and/or a fee. little measurable advantage (but improves the effectiveness of other ISMM’11, June 4–5, 2011, San Jose, California, USA. Copyright c 2011 ACM 978-1-4503-0263-0/11/06. $10.00 optimizations), and that specialized compiled scanning code for common cases significantly outperforms interpretation of metadata. We use the term reference to describe a language-level refer- The most effective scheme uses a small amount of metadata en- ence to an object. The live object graph is defined as the set of coded cheaply into the object header to encode the most common objects that are transitively referenced from some set of roots. By object patterns. contrast, we use the term pointer as an implementation-level ad- We also implement and evaluate the bidirectional object lay- dress (‘void *’) which may or may not point to an object. We out used by SableVM [9] and find that it performs well compared define the reference pattern of an object to be the number and lo- to orthodox object layout schemes. The Sable object model com- cation of reference fields within the object. All objects of a given bined with specialization of object scanning code outperforms the class have the same reference pattern, and two classes may have alternatives in almost all benchmarks. There is however a small but the same pattern even though they differ in such aspects as size (in consistent overhead in mutator time for this object model, giving it bytes), number of fields, or inheritance depth. an advantage in overall time when the heap is small, and a slight Because the policy for the layout of references within an object disadvantage in large heaps. will affect the distribution of reference patterns, we consider two This study is the first in-depth evaluation of object scanning key object layout regimes; declaration order, and references first. techniques and the tradeoffs they are exposed to. As far as we These alternatives are straightforward design choices and were de- know, our findings are the first to provide a quantitative foundation scribed in Etienne Gagnon’s PhD work as ‘naive’ and ‘traditional’ for the design and implementation of tracing, the performance- layouts respectively [8]. In the first case object fields appear within critical mechanism at the heart of all modern garbage collection the object in the order in which they are statically declared (with implementations. minor adjustments to ensure efficient packing in the face of align- ment requirements). This is the approach used by Jikes RVM. In the second case, references are packed together before non-reference 2. Related Work fields, at each level of the inheritance tree for each class. Note that Sansom [15] appears to have been the first to propose compiling for efficiency reasons, language implementations generally require specialized code for scanning objects (see Section 4.2), although he that field offsets are fixed across an inheritance hierarchy, allow- did not perform a performance analysis of the benefits of this tech- ing the same code to access fields of a class and all of its sub- nique. Jones and Lins [14], authors of the standard text on garbage classes. So in practice, the field layout for any subclass may only collection, make reference to Sansom’s work and subsequent work, be additive with respect to its super class. Thus the ‘references first’ but do not directly discuss the question of design options for scan- layout will typically result in alternating regions of references and ning mechanisms. Grove and Cheng did a proof-of-concept imple- non-references corresponding to levels of inheritance for the given mentation of scanning specialization for Jikes RVM and concluded type. Gagnon’s bidirectional object layout [8] avoids this problem that it was a profitable idea, but did not publish this work or incor- by growing the object layout in two directions, with references on porate it into the main code base [12]. David Grove kindly provided one side and non-references on the other. Thus references will al- us with their implementation, which we forward-ported and used as ways be packed on one side of the object header regardless of in- the basis for our implementation of specialization. This implemen- heritance. tation has been the default scanning mechanism in Jikes RVM since A minor variant on the ‘references first’ scheme involves al- 2007.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us