Font Size: a A A

Implementation and optimization of thread-local variables for a race-free Java dialect

Posted on:2013-12-23Degree:M.ScType:Thesis
University:McGill University (Canada)Candidate:Zhang, YiFull Text:PDF
GTID:2458390008488882Subject:Computer Science
Abstract/Summary:
Despite the popularity of Java, problems may arise from potential data-race conditions during execution of a Java program. Data-races are considered errors in concurrent programming languages and greatly complicate both programming and runtime optimization efforts. A race-free version of Java is therefore desirable as a way of avoiding this complexity and simplifying the programming model.;This thesis is part of work trying to build a race-free version of Java. It implements and optimizes thread-local accesses and comes up with a new semantics for this language. An important part of implementing a language without races is to distinguish thread-local data from shared data because these two groups of data need to be treated differently. This is complex in Java because in the current Java semantics all objects are allocated on a single heap and implicitly shared by multiple threads. Furthermore, while Java does provide a mechanism for thread-local storage, it is awkward to use and inefficient.;Many of the new concurrent programming languages, such as OpenMP, UPC, and D, use "sharing directives" to distinguish shared data from thread-local data, and have features that make heavy use of thread-local data. Our goal here is to apply some of these language ideas to a Java context in order to provide a simpler and less error-prone programming model. When porting such features as part of a language extension to Java, however, performance can suffer due to the simple, map-based implementation of Java's built-in ThreadLocal class. We implement an optimized mechanism based on programmer annotations that can efficiently ensure class and instance variables are only accessed by their owner thread. Both class and instance variables inherit values from the parent thread through deep copying, allowing all the reachable objects of child threads to have local copies if syntactically specified. In particular, class variable access involves direct access to thread-local variables through a localized heap, which is faster and easier than the default map mechanism defined for ThreadLocal objects. Our design improves performance significantly over the traditional thread-local access method for class variables and provides a simplified and more appealing syntax for doing so. We further evaluate our approach by modifying non-trivial, existing benchmarks to make better use of thread-local features, illustrating feasibility and allowing us to measure the performance in realistic contexts. This work is intended to bring us closer to designs for a complete race-free version of Java, as well as show how improved support for use of thread-local data could be implemented in other languages.
Keywords/Search Tags:Java, Thread-local, Data, Variables, Race-free, Language
Related items