skip to main content
10.1145/2384616.2384640acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Molecule: using monadic and streaming I/O to compose process networks on the JVM

Published:19 October 2012Publication History

ABSTRACT

Molecule is a domain specific language library embedded in Scala for easing the creation of scalable and modular concurrent applications on the JVM. Concurrent applications are modeled as parallel process networks that exchange information over mobile and type-safe messaging interfaces. In this paper, we present a concurrent programming environment that combines functional and imperative programming. Using a monad, we structure the sequential or parallel coordination of user-level threads, without JVM modifications or compiler support. Our mobile channel interfaces expose reusable and parallelizable higher-order functions, as if they were streams in a lazily evaluated functional programming language. The support for graceful termination of entire process networks is simplified by integrating channel poisoning with monadic exceptions and resource control. Our runtime and system-level interfaces leverage message batching and a novel flow parallel scheduler to limit expensive context switches in multicore environments. We illustrate the expressiveness and performance benefits on a 24-core AMD Opteron machine with three classical examples: a thread ring, a genuine prime sieve and a chameneos-redux.

References

  1. Agha, G. Actors: a model of concurrent computation in distributed systems. MIT Press, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Anderson, T., Bershad, B., Lazowska, E., and Levy, H. Scheduler activations: effective kernel support for the user-level management of parallelism. ACM Trans. Comput. Syst. 10 (Feb. 1992), 53--79. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Backus, J. Can programming be liberated from the von Neumann style?: a functional style and its algebra of programs. Commun. ACM 21, 8 (Aug. 1978), 613--641. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Banker, R., Davis, G., and Slaughter, S. Software development practices, software complexity, and software maintenance performance: a field study. Manage. Sci. 44 (Apr. 1998), 433--450. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Brown, N. C. C. Communicating Haskell Processes: Composable Explicit Concurrency using Monads. In Communicating Processes Architecture 2008 (Sept. 2008), pp. 67--83.Google ScholarGoogle Scholar
  6. Clinger, W., Hartheimer, A., and Ost, E. Implementation strategies for continuations. In Proceedings of the 1988 ACM conference on LISP and functional programming (July 1988), pp. 124--131. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Coutts, D., Leshchinskiy, R., and Stewart, D. Stream fusion: from lists to streams to nothing at all. SIGPLAN Not. 42 (Oct. 2007), 315--326. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Danvy, O., and Filinski, A. Representing Control: A Study of the CPS Transformation. Mathematical Structures in Computer Science 2, 4 (1992), 361--391.Google ScholarGoogle ScholarCross RefCross Ref
  9. Ganz, S., Friedman, D., and Wand, M. Trampolined style. In Proceedings of the 4th ACM SIGPLAN International Conference on Functional Programming (1999), pp. 18--27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Gelernter, D., and Carriero, N. Coordination languages and their significance. Commun. ACM 35 (Feb. 1992), 97--107. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Halen, J., Karlsson, R., and Nilsson, M. Performance measurements of threads in Java and processes in Erlang. Available at http://www.sics.se/joe/ericsson/du98024.html, Last visit April 2012.Google ScholarGoogle Scholar
  12. Haller, P., and Odersky, M. Scala actors: Unifying thread-based and event-based programming. Theoretical Computer Science (2008). Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Haller, P., and Odersky, M. Capabilities for Uniqueness and Borrowing. In Proceedings of the 24th European Conference on Object-Oriented Programming (2010). Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Hewitt, C., Bishop, P., and Steiger, R. A universal modular ACTOR formalism for artificial intelligence. In Proceedings of the 3rd international joint conference on Artificial intelligence (1973), pp. 235--245. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Hilderink, G. Managing Complexity of Control Software through Concurrency. PhD thesis, University of Twente, May 2005.Google ScholarGoogle Scholar
  16. Hoare, C. A. R. Communicating sequential processes. Commun. ACM 21 (Aug. 1978), 666--677. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Hudak, P. Modular domain specific languages and tools. In Proceedings of the 5th International Conference on Software Reuse (1998), pp. 134--. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Jones, M., and Hudak, P. Implicit and Explicit Parallel Programming in Haskell. Tech. Rep. YALEU/DCS/RR-982, Department of Computer Science, Yale University, Aug 1993.Google ScholarGoogle Scholar
  19. Kahn, G. The Semantics of a Simple Language for Parallel Programming. In Information Processing '74: Proceedings of the IFIP Congress. North-Holland, Aug. 1974, pp. 471--475.Google ScholarGoogle Scholar
  20. Kahn, G., and Macqueen, D. Coroutines and Networks of Parallel Processes. In Information Processing '77: Proceedings of the IFIP Congress. North-Holland, 1977, pp. 993--998.Google ScholarGoogle Scholar
  21. Kaiser, C., and Pradat-Peyre, J. Chameneos, a concurrency game for Java, Ada and others. Int. Conf. ACS/IEEE AICCSA (2003).Google ScholarGoogle ScholarCross RefCross Ref
  22. Karmani, R. K., Shali, A., and Agha, G. Actor frameworks for the JVM platform: a comparative analysis. In Proceedings of the 7th International Conference on Principles and Practice of Programming in Java (2009), pp. 11--20. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Lea, D. A Java fork/join framework. In Proceedings of the ACM 2000 conference on Java Grande (2000), pp. 36--43. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Li, P., and Zdancewic, S. Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives. In PLDI '07: Proceedings of the 2007 ACM SIGPLAN conference on Programming language design and implementation (2007), pp. 189--199. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Manson, J., Pugh, W., and Adve, S. V. The Java memory model. SIGPLAN Not. 40 (Jan. 2005), 378--391. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Milner, R. Communicating and Mobile Systems: the Pi-Calculus. Cambridge University Press, June 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Odersky, M., Spoon, L., and Venners, B. Programming in Scala, Second Edition. Artima, 2011.Google ScholarGoogle Scholar
  28. Oliveira, B. C., Moors, A., and Odersky, M. Type classes as objects and implicits. In Proceedings of the ACM international conference on Object oriented programming systems languages and applications (2010), pp. 341--360. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Peyton Jones, S., Gordon, A., and Finne, S. Concurrent Haskell. In 23rd ACM Symposium on Principles of Programming Languages (1996), pp. 295--308. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Peyton Jones, S., and Hughes, J. Report on the programming language Haskell 98, a non-strict, purely functional language. Tech. rep., Haskell comittee, 1999.Google ScholarGoogle Scholar
  31. Peyton Jones, S., and Wadler, P. Imperative functional programming. In Proceedings of the 20th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (1993), pp. 71--84. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Ritson, C., Sampson, A., and Barnes, F. Multicore scheduling for lightweight communicating processes. In Proceedings of the 11th international conference on Coordination Models and Languages (2009), pp. 163--183. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Rompf, T., Maier, I., and Odersky, M. Implementing First-Class Polymorphic Delimited Continuations by a Type-Directed Selective CPS-Transform. In Proceedings of the 14th ACM SIGPLAN international conference on Functional programming (2009). Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Rytz, L., Odersky, M., and Haller, P. Lightweight Polymorphic Effects. In Proceedings of the 26th European Conference on Object-Oriented Programming (2012). Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Saltzer, J. H., Reed, D. P., and Clark, D. D. End-to-end arguments in system design. ACM Trans. Comput. Syst. 2 (Nov. 1984), 277--288. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Sampson, A. Process-Oriented Patterns for Concurrent Software Engineering. PhD thesis, University of Kent, Oct. 2010.Google ScholarGoogle Scholar
  37. Sputh, B. H. C., and Allen, A. R. JCSP-Poison: Safe termination of CSP process networks. In Proceedings of the 28th conference on Communicating Process Architectures (2005), pp. 71--107.Google ScholarGoogle Scholar
  38. Srinivasan, S. Kilim: A server framework with lightweight actors, isolation types and zero-copy messaging. Tech. Rep. UCAM-CL-TR-769, University of Cambridge, Computer Laboratory, Feb. 2010.Google ScholarGoogle Scholar
  39. Syme, D., Petricek, T., and Lomov, D. The F# Asynchronous Programming Model. In Proceedings of the 13th International Symposium on Practical Aspects of Declarative Languages (2011), pp. 175--189. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Torgersen, M. Asynchronous Programming in C# and Visual Basic. White paper, Microsoft, Oct. 2010. Available online.Google ScholarGoogle Scholar
  41. and Williams}Armstrong:1996:CPE:229883 Virding, R., Wikström, C., and Williams, M. Concurrent programming in ERLANG (2nd ed.). Prentice Hall International (UK) Ltd., 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. von Behren, J. R., Condit, J., and Brewer, E. A. Why Events Are a Bad Idea (for High-Concurrency Servers). In Proceedings of the 2003 HotOS Workshop (May 2003), pp. 19--24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Wadler, P. Deforestation: transforming programs to eliminate trees. Theor. Comput. Sci. 73 (Jan. 1988), 231--248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Wadler, P. Monads for functional programming. In Advanced Functional Programming, First International Spring School on Advanced Functional Programming Techniques-Tutorial Text (1995), pp. 24--52. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Wadler, P. An angry half-dozen. SIGPLAN Not. 33 (Feb. 1998), 25--30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Welch, P., and Barnes, F. Communicating mobile processes: introducing occam-pi. In 25 Years of CSP (Apr. 2005), pp. 175--210. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Welch, P. H. Graceful Termination -- Graceful Resetting. In Applying Transputer-Based Parallel Machines, Proceedings of OUG 10 (Apr. 1989), pp. 310--317.Google ScholarGoogle Scholar

Index Terms

  1. Molecule: using monadic and streaming I/O to compose process networks on the JVM

            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
            • Published in

              cover image ACM Conferences
              OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applications
              October 2012
              1052 pages
              ISBN:9781450315616
              DOI:10.1145/2384616
              • cover image ACM SIGPLAN Notices
                ACM SIGPLAN Notices  Volume 47, Issue 10
                OOPSLA '12
                October 2012
                1011 pages
                ISSN:0362-1340
                EISSN:1558-1160
                DOI:10.1145/2398857
                Issue’s Table of Contents

              Copyright © 2012 ACM

              Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 19 October 2012

              Permissions

              Request permissions about this article.

              Request Permissions

              Check for updates

              Qualifiers

              • research-article

              Acceptance Rates

              Overall Acceptance Rate268of1,244submissions,22%

              Upcoming Conference

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader