skip to main content
research-article
Open Access

Parallelization of dynamic languages: synchronizing built-in collections

Published:24 October 2018Publication History
Skip Abstract Section

Abstract

Dynamic programming languages such as Python and Ruby are widely used, and much effort is spent on making them efficient. One substantial research effort in this direction is the enabling of parallel code execution. While there has been significant progress, making dynamic collections efficient, scalable, and thread-safe is an open issue. Typical programs in dynamic languages use few but versatile collection types. Such collections are an important ingredient of dynamic environments, but are difficult to make safe, efficient, and scalable.

In this paper, we propose an approach for efficient and concurrent collections by gradually increasing synchronization levels according to the dynamic needs of each collection instance. Collections reachable only by a single thread have no synchronization, arrays accessed in bounds have minimal synchronization, and for the general case, we adopt the Layout Lock paradigm and extend its design with a lightweight version that fits the setting of dynamic languages. We apply our approach to Ruby's Array and Hash collections. Our experiments show that our approach has no overhead on single-threaded benchmarks, scales linearly for Array and Hash accesses, achieves the same scalability as Fortran and Java for classic parallel algorithms, and scales better than other Ruby implementations on Ruby workloads.

Skip Supplemental Material Section

Supplemental Material

a108-daloze.webm

References

  1. David H. Bailey, Eric Barszcz, John T. Barton, David S. Browning, Robert L. Carter, Leonardo Dagum, Rod A. Fatoohi, Paul O. Frederickson, Thomas A. Lasinski, Rob S. Schreiber, et al. 1991. The NAS Parallel Benchmarks. The International Journal of Supercomputing Applications 5, 3 (1991), 63–73. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski, and Armin Rigo. 2009. 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). ACM, 18–25. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Carl Friedrich Bolz, Lukas Diekmann, and Laurence Tratt. 2013. 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). ACM, 167–182. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Carl Friedrich Bolz and Laurence Tratt. 2013. The Impact of Meta-Tracing on VM Design and Implementation. Science of Computer Programming (2013).Google ScholarGoogle Scholar
  5. Gregory Brown, Brad Ediger, Alexander Mankuta, et al. 2017a. Prawn: Fast, Nimble PDF Generation For Ruby. http: //prawnpdf.org/Google ScholarGoogle Scholar
  6. Gregory Brown, Brad Ediger, Alexander Mankuta, et al. 2017b. Prawn::SynchronizedCache with a Mutex for JRuby. https://github.com/prawnpdf/prawn/blob/61d46791/lib/prawn/utilities.rbGoogle ScholarGoogle Scholar
  7. Craig Chambers, David Ungar, and Elgin Lee. 1989. An Efficient Implementation of SELF a Dynamically-Typed ObjectOriented Language Based on Prototypes. In Proceedings on Object-Oriented Programming Systems, Languages and Applications (OOPSLA’89). ACM, 49–70. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Daniel Clifford, Hannes Payer, Michael Stanton, and Ben L. Titzer. 2015. Memento Mori: Dynamic Allocation-site-based Optimizations. In Proceedings of the 2015 International Symposium on Memory Management (ISMM ’15). ACM, 105–117. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Nachshon Cohen, Arie Tal, and Erez Petrank. 2017. Layout Lock: A Scalable Locking Paradigm for Concurrent Data Layout Modifications. In Proceedings of the 22Nd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP ’17). ACM, 17–29. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Diego Costa, Artur Andrzejak, Janos Seboek, and David Lo. 2017. Empirical Study of Usage and Performance of Java Collections. In Proceedings of the 8th ACM/SPEC on International Conference on Performance Engineering (ICPE’17). ACM, 389–400. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Benoit Daloze, Stefan Marr, Daniele Bonetta, and Hanspeter Mössenböck. 2016. Efficient and Thread-Safe Objects for Dynamically-Typed Languages. In Proceedings of the 2016 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’16). ACM, 642–659. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Benoit Daloze, Chris Seaton, Daniele Bonetta, and Hanspeter Mössenböck. 2015. Techniques and Applications for GuestLanguage Safepoints. In Proceedings of the 10th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems (ICOOOLPS ’15). 1–10. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Benoit Daloze, Arie Tal, Stefan Marr, Hanspeter Mössenböck, and Erez Petrank. 2018. Supplementary Material for: Parallelization of Dynamic Languages: Synchronizing Built-in Collections. In Proceedings of the 2018 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA’18).Google ScholarGoogle Scholar
  14. Jerry D’Antonio and Petr Chalupa. 2017. Concurrent Ruby – Modern concurrency tools for Ruby. http://www. concurrent-ruby.comGoogle ScholarGoogle Scholar
  15. Mattias De Wael, Stefan Marr, Joeri De Koster, Jennifer B. Sartor, and Wolfgang De Meuter. 2015. Just-in-Time Data Structures. In Proceedings of the 2015 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software (Onward! ’15). ACM, 61–75. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Ulan Degenbaev, Jochen Eisinger, Manfred Ernst, Ross McIlroy, and Hannes Payer. 2016. Idle Time Garbage Collection Scheduling. In Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’16). ACM, 570–583. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Liang Gong, Michael Pradel, and Koushik Sen. 2015. JITProf: Pinpointing JIT-unfriendly JavaScript Code. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (ESEC/FSE 2015). ACM, 357–368. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. David Heinemeier Hansson et al. 2018. Ruby on Rails - A web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern. http://rubyonrails.org/Google ScholarGoogle Scholar
  19. Tim Harris, James Larus, and Ravi Rajwar. 2010. Transactional Memory, 2nd Edition (2nd ed.). Morgan and Claypool Publishers. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Timothy L. Harris. 2001. A Pragmatic Implementation of Non-Blocking Linked-Lists. In Proceedings of the 15th International Conference on Distributed Computing (DISC ’01). Springer, 300–314. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Maurice Herlihy and Nir Shavit. 2011. The Art of Multiprocessor Programming. Morgan Kaufmann. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. JRuby. 2008. JRuby’s threaded-reverse benchmark. https://github.com/jruby/jruby/blob/a0a3e4bd22/test/bench/bench_ threaded_reverse.rbGoogle ScholarGoogle Scholar
  23. Josh Juneau, Jim Baker, Frank Wierzbicki, Leo Soto, and Victor Ng. 2010. The Definitive Guide to Jython: Python for the Java Platform. Apress. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Hemant Kumar. 2013. Bug report on the RubyGems project: Thread issues with JRuby. https://github.com/rubygems/ rubygems/issues/597Google ScholarGoogle Scholar
  25. Yi Lin, Kunshan Wang, Stephen M. Blackburn, Antony L. Hosking, and Michael Norrish. 2015. Stop and Go: Understanding Yieldpoint Behavior. In Proceedings of the 2015 International Symposium on Memory Management (ISMM ’15). ACM, 70–80. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Stefan Marr and Benoit Daloze. 2018. Few Versatile vs. Many Specialized Collections – How to design a collection library for exploratory programming?. In Proceedings of the 4th Programming Experience Workshop (PX/18). ACM.Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Stefan Marr, Benoit Daloze, and Hanspeter Mössenböck. 2016. Cross-Language Compiler Benchmarking—Are We Fast Yet?. In Proceedings of the 12th Symposium on Dynamic Languages (DLS’16). ACM, 120–131. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Remigius Meier, Armin Rigo, and Thomas R. Gross. 2016. Parallel Virtual Machines with RPython. In Proceedings of the 12th Symposium on Dynamic Languages (DLS ’16). ACM, 48–59. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Remigius Meier, Armin Rigo, and Thomas R. Gross. 2018. Virtual Machine Design for Parallel Dynamic Programming Languages. In Proceedings of the 2018 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’18). ACM.Google ScholarGoogle Scholar
  30. Mozilla. 2018. SharedArrayBuffer Documentation. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ Global_Objects/SharedArrayBufferGoogle ScholarGoogle Scholar
  31. Ryan R. Newton, Peter P. Fogg, and Ali Varamesh. 2015. Adaptive Lock-Free Maps: Purely-Functional to Scalable. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP 2015). ACM, 218–229. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Takafumi Nose. 2013. Ruby version of NAS Parallel Benchmarks 3.0. https://github.com/plus7/npb_rubyGoogle ScholarGoogle Scholar
  33. Charles Nutter, Thomas Enebo, Ola Bini, Nick Sieger, et al. 2018. JRuby – The Ruby Programming Language on the JVM. http://jruby.org/Google ScholarGoogle Scholar
  34. Rei Odaira, Jose G. Castanos, and Hisanobu Tomari. 2014. Eliminating Global Interpreter Locks in Ruby Through Hardware Transactional Memory. In Proceedings of the 19th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP ’14). ACM, 131–142. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Tim Peierls, Brian Goetz, Joshua Bloch, Joseph Bowbeer, Doug Lea, and David Holmes. 2005. Java Concurrency in Practice. Addison-Wesley Professional. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Mike Perham. 2017. Sidekiq – Simple, efficient background processing for Ruby. https://sidekiq.org/Google ScholarGoogle Scholar
  37. Evan Phoenix, Brian Shirai, Ryan Davis, Dirkjan Bussink, et al. 2018. Rubinius – An Implementation of Ruby Using the Smalltalk-80 VM Design. https://rubinius.com/Google ScholarGoogle Scholar
  38. Filip Pizlo. 2017. Concurrent JavaScript: It can work! https://webkit.org/blog/7846/concurrent-javascript-it-can-work/Google ScholarGoogle Scholar
  39. William Pugh et al. 2004. JSR 133 - Java Memory Model and Thread Specification Revision. http://www.cs.umd.edu/~pugh/ java/memoryModel/jsr133.pdfGoogle ScholarGoogle Scholar
  40. Rails Project. 2018. Threading and Code Execution in Rails. http://edgeguides.rubyonrails.org/threading_and_code_ execution.htmlGoogle ScholarGoogle Scholar
  41. Chris Seaton, Benoit Daloze, Kevin Menard, Petr Chalupa, Brandon Fish, and Duncan MacGregor. 2017. TruffleRuby – A High Performance Implementation of the Ruby Programming Language. https://github.com/graalvm/trufflerubyGoogle ScholarGoogle Scholar
  42. Brian Shirai. 2016. Bug report on the Bundler project: Unsynchronized, concurrent modification of Set instance. https: //github.com/bundler/bundler/issues/5142Google ScholarGoogle Scholar
  43. Brian Shirai. 2018. Bug report on the Bundler project: Unsychronized concurrent updates of Hash. https://github.com/ bundler/bundler/issues/6274Google ScholarGoogle Scholar
  44. Vincent St-Amour and Shu-yu Guo. 2015. Optimization Coaching for JavaScript. In 29th European Conference on ObjectOriented Programming (ECOOP 2015) (LIPIcs), Vol. 37. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 271–295.Google ScholarGoogle Scholar
  45. Lukas Stadler, Thomas Würthinger, and Hanspeter Mössenböck. 2014. Partial Escape Analysis and Scalar Replacement for Java. In Proceedings of Annual IEEE/ACM International Symposium on Code Generation and Optimization (CGO ’14). ACM, 165–174. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Håkan Sundell and Philippas Tsigas. 2005. Lock-Free and Practical Doubly Linked List-Based Deques Using Single-Word Compare-and-Swap. Principles of Distributed Systems (2005), 240–255. arXiv: arXiv:cs/0408016v1 Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. James Swaine, Kevin Tew, Peter Dinda, Robert Bruce Findler, and Matthew Flatt. 2010. Back to the Futures: Incremental Parallelization of Existing Sequential Runtime Systems. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA ’10). ACM, 583–597. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Kevin Tew, James Swaine, Matthew Flatt, Robert Bruce Findler, and Peter Dinda. 2011. Places: Adding Message-Passing Parallelism to Racket. In Proceedings of the 7th Symposium on Dynamic Languages (DLS ’11). ACM, 85–96. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Thomas Würthinger, Christian Wimmer, Christian Humer, Andreas Wöß, Lukas Stadler, Chris Seaton, Gilles Duboscq, Doug Simon, and Matthias Grimmer. 2017. Practical Partial Evaluation for High-performance Dynamic Language Runtimes. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). ACM, 662–676. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Andreas Wöß, Christian Wirth, Daniele Bonetta, Chris Seaton, Christian Humer, and Hanspeter Mössenböck. 2014. 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). ACM, 133–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Thomas Würthinger, Andreas Wöß, Lukas Stadler, Gilles Duboscq, Doug Simon, and Christian Wimmer. 2012. SelfOptimizing AST Interpreters. In Proceedings of the 8th Dynamic Languages Symposium (DLS ’12). 73–82. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Guoqing Xu. 2013. CoCo: Sound and Adaptive Replacement of Java Collections. In Proceedings of the 27th European Conference on Object-Oriented Programming (ECOOP’13). Springer-Verlag, 1–26. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Parallelization of dynamic languages: synchronizing built-in collections

        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!