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.
Supplemental Material
Available for Download
This is the supplementary material and annex for the paper Parallelization of Dynamic Languages: Synchronizing Built-in Collections. It complements the paper by reasoning about the correctness of the Lightweight Layout Lock, discussing safe publication of shared collections and adding a table of raw data.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Carl Friedrich Bolz and Laurence Tratt. 2013. The Impact of Meta-Tracing on VM Design and Implementation. Science of Computer Programming (2013).Google Scholar
- Gregory Brown, Brad Ediger, Alexander Mankuta, et al. 2017a. Prawn: Fast, Nimble PDF Generation For Ruby. http: //prawnpdf.org/Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Jerry D’Antonio and Petr Chalupa. 2017. Concurrent Ruby – Modern concurrency tools for Ruby. http://www. concurrent-ruby.comGoogle Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Tim Harris, James Larus, and Ravi Rajwar. 2010. Transactional Memory, 2nd Edition (2nd ed.). Morgan and Claypool Publishers. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Maurice Herlihy and Nir Shavit. 2011. The Art of Multiprocessor Programming. Morgan Kaufmann. Google Scholar
Digital Library
- JRuby. 2008. JRuby’s threaded-reverse benchmark. https://github.com/jruby/jruby/blob/a0a3e4bd22/test/bench/bench_ threaded_reverse.rbGoogle Scholar
- Josh Juneau, Jim Baker, Frank Wierzbicki, Leo Soto, and Victor Ng. 2010. The Definitive Guide to Jython: Python for the Java Platform. Apress. Google Scholar
Digital Library
- Hemant Kumar. 2013. Bug report on the RubyGems project: Thread issues with JRuby. https://github.com/rubygems/ rubygems/issues/597Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Mozilla. 2018. SharedArrayBuffer Documentation. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ Global_Objects/SharedArrayBufferGoogle Scholar
- 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 Scholar
Digital Library
- Takafumi Nose. 2013. Ruby version of NAS Parallel Benchmarks 3.0. https://github.com/plus7/npb_rubyGoogle Scholar
- Charles Nutter, Thomas Enebo, Ola Bini, Nick Sieger, et al. 2018. JRuby – The Ruby Programming Language on the JVM. http://jruby.org/Google Scholar
- 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 Scholar
Digital Library
- Tim Peierls, Brian Goetz, Joshua Bloch, Joseph Bowbeer, Doug Lea, and David Holmes. 2005. Java Concurrency in Practice. Addison-Wesley Professional. Google Scholar
Digital Library
- Mike Perham. 2017. Sidekiq – Simple, efficient background processing for Ruby. https://sidekiq.org/Google Scholar
- 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 Scholar
- Filip Pizlo. 2017. Concurrent JavaScript: It can work! https://webkit.org/blog/7846/concurrent-javascript-it-can-work/Google Scholar
- William Pugh et al. 2004. JSR 133 - Java Memory Model and Thread Specification Revision. http://www.cs.umd.edu/~pugh/ java/memoryModel/jsr133.pdfGoogle Scholar
- Rails Project. 2018. Threading and Code Execution in Rails. http://edgeguides.rubyonrails.org/threading_and_code_ execution.htmlGoogle Scholar
- 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 Scholar
- Brian Shirai. 2016. Bug report on the Bundler project: Unsynchronized, concurrent modification of Set instance. https: //github.com/bundler/bundler/issues/5142Google Scholar
- Brian Shirai. 2018. Bug report on the Bundler project: Unsychronized concurrent updates of Hash. https://github.com/ bundler/bundler/issues/6274Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Parallelization of dynamic languages: synchronizing built-in collections
Recommendations
Efficient and thread-safe objects for dynamically-typed languages
OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and ApplicationsWe 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 ...
Efficient and thread-safe objects for dynamically-typed languages
OOPSLA '16We 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 ...
Debugging native extensions of dynamic languages
ManLang '18: Proceedings of the 15th International Conference on Managed Languages & RuntimesMany dynamic programming languages such as Ruby and Python enable developers to use so called native extensions, code implemented in typically statically compiled languages like C and C++. However, debuggers for these dynamic languages usually lack ...






Comments