skip to main content

Thread-safe reactive programming

Published:24 October 2018Publication History
Skip Abstract Section

Abstract

The execution of an application written in a reactive language involves transfer of data and control flow between imperative and reactive abstractions at well-defined points. In a multi-threaded environment, multiple such interactions may execute concurrently, potentially causing data races and event ordering ambiguities. Existing RP languages either disable multi-threading or handle it at the cost of reducing expressiveness or weakening consistency. This paper proposes a model for thread-safe reactive programming (RP) that ensures abort-free strict serializability under concurrency while sacrificing neither expressiveness nor consistency. We also propose an architecture for integrating a corresponding scheduler into the RP language runtime, such that thread-safety is provided "out-of-the-box" to the applications.

We show the feasibility of our proposal by providing and evaluating a ready-to-use implementation integrated into the REScala programming language. The scheduling algorithm is formally proven correct. A thorough empirical evaluation shows that reactive applications build on top of it scale with multiple threads, while the scheduler incurs acceptable performance overhead in a single-threaded configuration. The scalability enabled by our scheduler is roughly on-par with that of hand-crafted application-specific locking and better than the scalability enabled by a scheduler using an off-the-shelf software transactional memory library.

Skip Supplemental Material Section

Supplemental Material

a107-drechsler.webm

References

  1. Gul Agha. 1986. Actors: A Model of Concurrent Computation in Distributed Systems. MIT Press, Cambridge, MA, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Roberto M Amadio, Gérard Boudol, Frédéric Boussinot, and Ilaria Castellani. 2006. Reactive concurrent programming revisited. Electronic Notes in Theoretical Computer Science 162 (2006), 49–60.Google ScholarGoogle ScholarCross RefCross Ref
  3. Engineer Bainomugisha, Andoni Lombide Carreton, Tom van Cutsem, Stijn Mostinckx, and Wolfgang de Meuter. 2013. A survey on reactive programming. ACM Comput. Surv. 45, 4, Article 52 (2013), 34 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Hal Berenson, Phil Bernstein, Jim Gray, Jim Melton, Elizabeth O’Neil, and Patrick O’Neil. 1995. A Critique of ANSI SQL Isolation Levels. In Proceedings of the 1995 ACM SIGMOD International Conference on Management of Data (SIGMOD ’95). ACM, New York, NY, USA, 1–10. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Philip A Bernstein, Vassos Hadzilacos, and Nathan Goodman. 1986. Concurrency Control and Recovery in Database Systems. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Pramod Bhatotia, Pedro Fonseca, Umut A. Acar, Björn B. Brandenburg, and Rodrigo Rodrigues. 2015. iThreads: A Threading Library for Parallel Incremental Computation. In Proceedings of the Twentieth International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS ’15). ACM, New York, NY, USA, 645–659. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Pramod Bhatotia, Alexander Wieder, Rodrigo Rodrigues, Umut A. Acar, and Rafael Pasquin. 2011. Incoop: MapReduce for Incremental Computations. In Proceedings of the 2Nd ACM Symposium on Cloud Computing (SOCC ’11). ACM, New York, NY, USA, Article 7, 14 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Nathan G. Bronson, Hassan Chafi, and Kunle Olukotun. 2010. CCSTM: A library-based STM for Scala. In The First Annual Scala Workshop at Scala Days.Google ScholarGoogle Scholar
  9. Sebastian Burckhardt, Daan Leijen, Caitlin Sadowski, Jaeheon Yi, and Thomas Ball. 2011. Two for the Price of One: A Model for Parallel and Incremental Computation. In Proceedings of the 2011 ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA ’11). ACM, New York, NY, USA, 427–444. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Vinay K. Chaudhri and Vassos Hadzilacos. 1995. Safe Locking Policies for Dynamic Databases. In Proceedings of the Fourteenth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (PODS ’95). ACM, New York, NY, USA, 233–244. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Gregory H. Cooper and Shriram Krishnamurthi. 2006. Embedding Dynamic Dataflow in a Call-by-value Language. In Proceedings of the 15th European Conference on Programming Languages and Systems (ESOP’06). Springer-Verlag, Berlin, Heidelberg, 294–308. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Gianpaolo Cugola and Alessandro Margara. 2012. Processing Flows of Information: From Data Stream to Complex Event Processing. ACM Comput. Surv. 44, 3, Article 15 (June 2012), 62 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Evan Czaplicki and Stephen Chong. 2013. Asynchronous Functional Reactive Programming for GUIs. In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’13). ACM, New York, NY, USA, 411–422. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Joscha Drechsler, Ragnar Mogk, Guido Salvaneschi, and Mira Mezini. 2018. Thread-Safe Reactive Programming. Technical Report.Google ScholarGoogle Scholar
  15. Joscha Drechsler, Guido Salvaneschi, Ragnar Mogk, and Mira Mezini. 2014. Distributed REScala: An Update Algorithm for Distributed Reactive Programming. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’14). ACM, New York, NY, USA, 361–376. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Conal Elliott and Paul Hudak. 1997. Functional Reactive Animation. SIGPLAN Not. 32, 8 (Aug. 1997), 263–273. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Patrick Th. Eugster, Pascal A. Felber, Rachid Guerraoui, and Anne-Marie Kermarrec. 2003. The many faces of publish/subscribe. ACM Comput. Surv. 35, 2 (June 2003), 114–131. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Guy Golan-Gueta, Nathan Bronson, Alex Aiken, G. Ramalingam, Mooly Sagiv, and Eran Yahav. 2011. Automatic Fine-grain Locking Using Shape Properties. SIGPLAN Not. 46, 10 (Oct. 2011), 225–242. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Matthew Hammer, Umut A. Acar, Mohan Rajagopalan, and Anwar Ghuloum. 2007. A Proposal for Parallel Self-adjusting Computation. In Proceedings of the 2007 Workshop on Declarative Aspects of Multicore Programming (DAMP ’07). ACM, New York, NY, USA, 3–9. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Li Haoyi. 2016. Scala.Rx Web site. https://github.com/lihaoyi/scala.rx (Web).Google ScholarGoogle Scholar
  21. Maurice P. Herlihy and Jeannette M. Wing. 1990. Linearizability: A Correctness Condition for Concurrent Objects. ACM Trans. Program. Lang. Syst. 12, 3 (July 1990), 463–492. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. C. A. R. Hoare. 1985. Communicating Sequential Processes. Prentice-Hall, Inc., Upper Saddle River, NJ, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Alan Jeffrey. 2013. Functional Reactive Programming with Liveness Guarantees. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP ’13). ACM, New York, NY, USA, 233–244. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Tetsuo Kamina and Tomoyuki Aotani. 2018. Harmonizing Signals and Events with a Lightweight Extension to Java. CoRR abs/1803.10199 (2018). arXiv: 1803.10199 http://arxiv.org/abs/1803.10199Google ScholarGoogle Scholar
  25. Neelakantan R. Krishnaswami. 2013. Higher-order Functional Reactive Programming Without Spacetime Leaks. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP ’13). ACM, New York, NY, USA, 221–232. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Neelakantan R. Krishnaswami, Nick Benton, and Jan Hoffmann. 2012. Higher-order Functional Reactive Programming in Bounded Space. In Proceedings of the 39th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’12). ACM, New York, NY, USA, 45–58. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Vladimir Lanin and Dennis Shasha. 1990. Tree locking on changing trees. Technical Report. New York University, Department of Computer Science, Courant Institute of Mathematical Science. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Jesse Liberty and Paul Betts. 2011. Programming Reactive Extensions and LINQ (1st ed.). Apress, Berkely, CA, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Andoni Lombide Carreton, Stijn Mostinckx, Tom Van Cutsem, and Wolfgang De Meuter. 2010. Loosely-Coupled Distributed Reactive Programming in Mobile Ad Hoc Networks. In Objects, Models, Components, Patterns, Jan Vitek (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 41–60. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Ingo Maier and Martin Odersky. 2012. Deprecating the Observer Pattern with Scala.React. Technical Report.Google ScholarGoogle Scholar
  31. Ingo Maier and Martin Odersky. 2013. Higher-Order Reactive Programming with Incremental Lists. In ECOOP 2013 – Object-Oriented Programming, Giuseppe Castagna (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 707–731. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Alessandro Margara and Guido Salvaneschi. 2014. We Have a DREAM: Distributed Reactive Programming with Consistency Guarantees. In Proceedings of the 8th ACM International Conference on Distributed Event-Based Systems (DEBS ’14). ACM, New York, NY, USA, 142–153. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. A. Margara and G. Salvaneschi. 2018. On the Semantics of Distributed Reactive Programming: The Cost of Consistency. IEEE Transactions on Software Engineering 44, 7 (July 2018), 689–711.Google ScholarGoogle ScholarCross RefCross Ref
  34. Leo A. Meyerovich, Arjun Guha, Jacob Baskin, Gregory H. Cooper, Michael Greenberg, Aleks Bromfield, and Shriram Krishnamurthi. 2009. Flapjax: A Programming Language for Ajax Applications. In Proceedings of the 24th ACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA ’09). ACM, New York, NY, USA, 1–20. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Ragnar Mogk, Lars Baumgärtner, Guido Salvaneschi, Bernd Freisleben, and Mira Mezini. 2018. Fault-tolerant Distributed Reactive Programming. In 32nd European Conference on Object-Oriented Programming (ECOOP 2018) (Leibniz International Proceedings in Informatics (LIPIcs)), Todd Millstein (Ed.), Vol. 109. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany, 1:1–1:26.Google ScholarGoogle Scholar
  36. Yang Ni, Vijay S. Menon, Ali-Reza Adl-Tabatabai, Antony L. Hosking, Richard L. Hudson, J. Eliot B. Moss, Bratin Saha, and Tatiana Shpeisman. 2007. Open Nesting in Software Transactional Memory. In Proceedings of the 12th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP ’07). ACM, New York, NY, USA, 68–78. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. John Peterson, Valery Trifonov, and Andrei Serjantov. 2000. Parallel Functional Reactive Programming. In Practical Aspects of Declarative Languages, Enrico Pontelli and Vítor Santos Costa (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 16–31. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. José Proença and Carlos Baquero. 2017. Quality-Aware Reactive Programming for the Internet of Things. In Fundamentals of Software Engineering, Mehdi Dastani and Marjan Sirjani (Eds.). Springer International Publishing, Cham, 180–195.Google ScholarGoogle Scholar
  39. Aleksandar Prokopec, Philipp Haller, and Martin Odersky. 2014. Containers and Aggregates, Mutators and Isolates for Reactive Programming. In Proceedings of the Fifth Annual Scala Workshop (SCALA ’14). ACM, New York, NY, USA, 51–61. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Stefan Ramson and Robert Hirschfeld. 2017. Active Expressions: Basic Building Blocks for Reactive Programming. CoRR abs/1703.10859 (2017). arXiv: 1703.10859 http://arxiv.org/abs/1703.10859Google ScholarGoogle Scholar
  41. Bob Reynders, Dominique Devriese, and Frank Piessens. 2014. Multi-Tier Functional Reactive Programming for the Web. In Proceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software (Onward! 2014). ACM, New York, NY, USA, 55–68. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Guido Salvaneschi, Sven Amann, Sebastian Proksch, and Mira Mezini. 2014a. An Empirical Study on Program Comprehension with Reactive Programming. In Proceedings of the 22Nd ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE 2014). ACM, New York, NY, USA, 564–575. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Guido Salvaneschi, Gerold Hintz, and Mira Mezini. 2014b. REScala: Bridging Between Object-oriented and Functional Style in Reactive Applications. In Proceedings of the 13th International Conference on Modularity (MODULARITY ’14). ACM, New York, NY, USA, 25–36. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Kensuke Sawada and Takuo Watanabe. 2016. Emfrp: A Functional Reactive Programming Language for Small-scale Embedded Systems. In Companion Proceedings of the 15th International Conference on Modularity (MODULARITY Companion 2016). ACM, New York, NY, USA, 36–44. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Nir Shavit and Dan Touitou. 1995. Software Transactional Memory. In Proceedings of the Fourteenth Annual ACM Symposium on Principles of Distributed Computing (PODC ’95). ACM, New York, NY, USA, 204–213. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Sagnak Tasirlar and Vivek Sarkar. 2011. Data-Driven Tasks and Their Implementation. In Proceedings of the 2011 International Conference on Parallel Processing (ICPP ’11). IEEE Computer Society, Washington, DC, USA, 652–661. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Aaron Turon. 2012. Reagents: Expressing and Composing Fine-grained Concurrency. In Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’12). ACM, New York, NY, USA, 157–168. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Pascal Weisenburger, Mirko Köhler, and Guido Salvaneschi. 2018. Distributed System Development with ScalaLoci. Proc. ACM Program. Lang. 2, OOPSLA (Nov. 2018). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Thread-safe reactive programming

          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!