skip to main content
research-article

Efficient and thread-safe objects for dynamically-typed languages

Published:19 October 2016Publication History
Skip Abstract Section

Abstract

We are in the multi-core era. Dynamically-typed languages are in widespread use, but their support for multithreading still lags behind. One of the reasons is that the sophisticated techniques they use to efficiently represent their dynamic object models are often unsafe in multithreaded environments.

This paper defines safety requirements for dynamic object models in multithreaded environments. Based on these requirements, a language-agnostic and thread-safe object model is designed that maintains the efficiency of sequential approaches. This is achieved by ensuring that field reads do not require synchronization and field updates only need to synchronize on objects shared between threads.

Basing our work on JRuby+Truffle, we show that our safe object model has zero overhead on peak performance for thread-local objects and only 3% average overhead on parallel benchmarks where field updates require synchronization. Thus, it can be a foundation for safe and efficient multithreaded VMs for a wide range of dynamic languages.

References

  1. A.-R. Adl-Tabatabai, B. T. Lewis, V. Menon, B. R. Murphy, B. Saha, and T. Shpeisman. Compiler and Runtime Support for Efficient Software Transactional Memory. In Proceedings of the 27th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’06, pages 26–37. ACM, 2006. doi: 10.1145/1133981.1133985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. C. F. Bolz and L. Tratt. The Impact of Meta-Tracing on VM Design and Implementation. Science of Computer Programming, pages 408–421, Feb. 2015. doi: 10.1016/j.scico.2013.02.001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the Meta-level: PyPy’s Tracing JIT Compiler. In Proceedings of the 4th Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, ICOOOLPS ’09, pages 18–25. ACM, 2009. doi: 10.1145/1565824.1565827. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. C. F. Bolz, L. Diekmann, and L. Tratt. Storage Strategies for Collections in Dynamically Typed Languages. In Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA ’13, pages 167–182. ACM, 2013. doi: 10.1145/2509136.2509531. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. C. Chambers, D. Ungar, and E. Lee. An Efficient Implementation of SELF a Dynamically-Typed Object-Oriented Language Based on Prototypes. In Proceedings on Object-Oriented Programming Systems, Languages and Applications, OOPSLA, pages 49–70. ACM, October 1989. doi: 10.1145/74878.74884. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. D. Clifford, H. Payer, M. Stanton, and B. L. Titzer. Memento Mori: Dynamic Allocation-site-based Optimizations. In Proceedings of the 2015 International Symposium on Memory Management, ISMM ’15, pages 105–117. ACM, 2015. ISBN 978-1-4503-3589-8. doi: 10.1145/2754169.2754181. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. B. Daloze, C. Seaton, D. Bonetta, and H. Mössenböck. Techniques and Applications for Guest-Language Safepoints. In Proceedings of the 10th International Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, ICOOOLPS ’15, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. D. Dice. Implementing Fast Java Monitors with Relaxedlocks. In Proceedings of the 2001 Symposium on Java Virtual Machine Research and Technology Symposium - Volume 1, JVM’01, page 13. USENIX Association, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. T. Domani, G. Goldshtein, E. K. Kolodner, E. Lewis, E. Petrank, and D. Sheinwald. Thread-Local Heaps for Java. In Proceedings of the 3rd International Symposium on Memory Management, ISMM ’02, pages 76–87. ACM, 2002. ISBN 1-58113-539-4. doi: 10.1145/512429.512439. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. R. W. Floyd. Algorithm 97: Shortest Path. Commun. ACM, 5 (6):345, Jun. 1962. doi: 10.1145/367766.368168. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Google. V8 – Google’s JavaScript engine, 2015. https://developers.google.com/v8/.Google ScholarGoogle Scholar
  12. U. Hölzle, C. Chambers, and D. Ungar. Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches. In ECOOP ’91: European Conference on Object-Oriented Programming, volume 512 of LNCS, pages 21–38. Springer, 1991. doi: 10.1007/BFb0057013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. M. Imam and V. Sarkar. Savina - An Actor Benchmark Suite: Enabling Empirical Evaluation of Actor Libraries. In Proceedings of the 4th International Workshop on Programming Based on Actors Agents & Decentralized Control, AGERE! ’14, pages 67–80. ACM, 2014. doi: 10.1145/2687357.2687368. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J. Juneau, J. Baker, F. Wierzbicki, L. Soto, and V. Ng. The Definitive Guide to Jython: Python for the Java platform. Apress, 2010. doi: 10.1007/978-1-4302-2528-7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. T. Kalibera, M. Mole, R. Jones, and J. Vitek. A Blackbox Approach to Understanding Concurrency in DaCapo. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’12, pages 335–354. ACM, 2012. doi: 10.1145/ 2384616.2384641. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Laskey. Nashorn Multithreading and MT-safety, 2013. https://blogs.oracle.com/nashorn/entry/nashorn_ multi_threading_and_mt.Google ScholarGoogle Scholar
  17. J. Manson, W. Pugh, and S. V. Adve. The Java Memory Model. In Proceedings of the 32nd Symposium on Principles of Programming Languages, POPL ’05, pages 378–391. ACM, 2005. doi: 10.1145/1040305.1040336. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. V. J. Marathe, M. F. Spear, C. Heriot, A. Acharya, D. Eisenstat, W. N. Scherer III, and M. L. Scott. Lowering the Overhead of Nonblocking Software Transactional Memory. Technical report, Department of Computer Science, University of Rochester, 2006.Google ScholarGoogle Scholar
  19. S. Marr, C. Seaton, and S. Ducasse. Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and without Compromises. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’15, pages 545–554. ACM, 2015. doi: 10.1145/2737924.2737963. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Marr, B. Daloze, and H. Mössenböck. Cross-Language Compiler Benchmarking—Are We Fast Yet? In Proceedings of the 12th Symposium on Dynamic Languages, DLS 2016. ACM, 2016. doi: 10.1145/2989225.2989232. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. F. Morandat, B. Hill, L. Osvald, and J. Vitek. Evaluating the Design of the R Language: Objects and Functions for Data Analysis. In Proceedings of the 26th European Conference on Object-Oriented Programming, ECOOP’12, pages 104–131. Springer-Verlag, 2012. doi: 10.1007/978-3-642-31057-7_6. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Mozilla. SpiderMonkey – Mozilla’s JavaScript engine, 2015. https://developer.mozilla.org/en-US/docs/Mozilla/ Projects/SpiderMonkey.Google ScholarGoogle Scholar
  23. Mozilla Developer Network. JS-THREADSAFE, 2015.Google ScholarGoogle Scholar
  24. https://developer.mozilla.org/en-US/docs/Mozilla/ Projects/SpiderMonkey/JSAPI_reference/JS_THREADSAFE.Google ScholarGoogle Scholar
  25. Nashorn authors. Project Nashorn, 2016. http://openjdk. java.net/projects/nashorn/.Google ScholarGoogle Scholar
  26. C. Nutter, T. Enebo, O. Bini, N. Sieger, et al. JRuby, 2016. http://jruby.org/.Google ScholarGoogle Scholar
  27. Oracle Labs. GraalVM: New JIT Compiler and Polyglot Runtime for the JVM, 2016. http://www.oracle.com/ technetwork/oracle-labs/program-languages/overview/ index.html.Google ScholarGoogle Scholar
  28. T. Pape, T. Felgentreff, R. Hirschfeld, A. Gulenko, and C. F. Bolz. Language-independent Storage Strategies for Tracing-JIT-based Virtual Machines. In Proceedings of the 11th Symposium on Dynamic Languages, DLS 2015, pages 104– 113. ACM, 2015. doi: 10.1145/2816707.2816716. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. E. Phoenix, B. Shirai, R. Davis, D. Bussink, et al. Rubinius, 2016. http://rubini.us/.Google ScholarGoogle Scholar
  30. K. Russell and D. Detlefs. Eliminating Synchronization-related Atomic Operations with Biased Locking and Bulk Rebiasing. In Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-oriented Programming Systems, Languages, and Applications, OOPSLA ’06, pages 263–272. ACM, 2006. doi: 10.1145/1167473.1167496. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. C. Seaton, B. Daloze, K. Menard, P. Chalupa, T. Würthinger, et al. JRuby+Truffle – a High-Performance Truffle Backend for JRuby, 2016.Google ScholarGoogle Scholar
  32. https://github.com/jruby/jruby/wiki/ Truffle.Google ScholarGoogle Scholar
  33. V8 authors. V8 Design Elements - Hidden Classes, 2012. https://developers.google.com/v8/design#prop_access.Google ScholarGoogle Scholar
  34. N. Vasudevan, K. S. Namjoshi, and S. A. Edwards. Simple and Fast Biased Locks. In Proceedings of the 19th International Conference on Parallel Architectures and Compilation Techniques, PACT ’10, pages 65–74. ACM, 2010. doi: 10.1145/1854273.1854287. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. M. Wolczko. Benchmarking Java with Richards and Deltablue, 2013. http://www.wolczko.com/java_benchmarking.html.Google ScholarGoogle Scholar
  36. T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to Rule Them All. In Proceedings of the 2013 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software, Onward!’13, pages 187–204. ACM, 2013. doi: 10.1145/2509578.2509581. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. A. Wöß, C. Wirth, D. Bonetta, C. Seaton, C. Humer, and H. Mössenböck. An Object Storage Model for the Truffle Language Implementation Framework. In Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools, PPPJ ’14, pages 133–144. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. doi: 10.1145/2647508.2647517.Google ScholarGoogle Scholar
  39. T. Würthinger, A. Wöß, L. Stadler, G. Duboscq, D. Simon, and C. Wimmer. Self-Optimizing AST Interpreters. In Proceedings of the 8th Dynamic Languages Symposium, DLS’12, pages 73– 82, October 2012. doi: 10.1145/2384577.2384587. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. M. Zhang, J. Huang, M. Cao, and M. D. Bond. Low-overhead Software Transactional Memory with Progress Guarantees and Strong Semantics. In Proceedings of the 20th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, PPoPP 2015, pages 97–108. ACM, 2015. doi: 10.1145/2688500.2688510. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Efficient and thread-safe objects for dynamically-typed languages

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!