Abstract
Memoization is a well-known optimization technique used to eliminate redundant calls for pure functions. If a call to a function f with argument v yields result r, a subsequent call to f with v can be immediately reduced to r without the need to re-evaluate f's body. Understanding memoization in the presence of concurrency and communication is significantly more challenging. For example, if f communicates with other threads, it is not sufficient to simply record its input/output behavior; we must also track inter-thread dependencies induced by these communication actions. Subsequent calls to f can be elided only if we can identify an interleaving of actions from these call-sites that lead to states in which these dependencies are satisfied. Similar issues arise if f spawns additional threads. In this paper, we consider the memoization problem for a higher-order concurrent language whose threads may communicate through synchronous message-based communication. To avoid the need to perform unbounded state space search that may be necessary to determine if all communication dependencies manifest in an earlier call can be satisfied in a later one, we introduce a weaker notion of memoization called partial memoization that gives implementations the freedom to avoid performing some part, if not all, of a previously memoized call. To validate the effectiveness of our ideas, we consider the benefits of memoization for reducing the overhead of recomputation for streaming, server-based, and transactional applications executed on a multi-core machine. We show that on a variety of workloads, memoization can lead to substantial performance improvements without incurring high memory costs.
Supplemental Material
- Umut A. Acar, Guy E. Blelloch, and Robert Harper. Selective Memoization. In POPL, pages 14--25, 2003. Google Scholar
Digital Library
- Umut A. Acar, Amal Ahmed, and Matthias Blume. Imperative Self-Adjusting Computation. In POPL, pages 309--322, 2008. Google Scholar
Digital Library
- Ali-Reza Adl-Tabatabai, Brian T. Lewis, Vijay Menon, Brian R. Murphy, Bratin Saha, and Tatiana Shpeisman. Compiler and Runtime Support for Efficient Software Transactional Memory. In PLDI, pages 26--37, 2006. Google Scholar
Digital Library
- Michael J. Carey, David J. DeWitt, and Jeffrey F. Naughton. The 007 benchmark. SIGMOD Record, 22 (2): 12--21, 1993. Google Scholar
Digital Library
- Kevin Donnelly and Matthew Fluet. Transactional Events. In ICFP, pages 124--135, 2006. Google Scholar
Digital Library
- Laura Effinger-Dean, Matthew Kehrt, and Dan Grossman. Transactional events for ml. In ICFP '08, pages 103--114, 2008. ISBN 978-1-59593-919-7. Google Scholar
Digital Library
- Michael I. Gordon, William Thies, and Saman Amarasinghe. Exploiting Coarse-Grained Task, Data, and Pipeline Parallelism in Stream Programs. In ASPLOS-XII, pages 151--162, 2006. Google Scholar
Digital Library
- Rachid Guerraoui, Michal Kapalka, and Jan Vitek. STMBench7: A Benchmark for Software Transactional Memory. In EuroSys, pages 315--324, 2007. Google Scholar
Digital Library
- Matthew Hammer, Umut A. Acar, Mohan Rajagopalan, and Anwar Ghuloum. A Proposal for Parallel Self-Adjusting Computation. In Workshop on Declarative Aspects of Multicore Programming, 2007. Google Scholar
Digital Library
- Tim Harris and Keir Fraser. Language support for lightweight transactions. In OOPSLA, pages 388--402, 2003. Google Scholar
Digital Library
- Tim Harris, Simon Marlow, Simon Peyton-Jones, and Maurice Herlihy. Composable Memory Transactions. In Proceedings of the ACM Conference on Principles and Practice of Parallel Programming, pages 48--60, 2005. Google Scholar
Digital Library
- Allan Heydon, Roy Levin, and Yuan Yu. Caching function calls using precise dependencies. In PLDI, pages 311--320, 2000. Google Scholar
Digital Library
- Ruy Ley-Wild, Matthew Fluet, and Umut A. Acar. Compiling self-adjusting programs with continuations. In ICFP, pages 321--334, 2008. Google Scholar
Digital Library
- Yanhong A. Liu and Tim Teitelbaum. Caching Intermediate Results for Program Improvement. In PEPM, pages 190--201, 1995. Google Scholar
Digital Library
- Richard Matthew Mccutchen and Samir Khuller. Streaming algorithms for k-center clustering with outliers and with anonymity. In APPROX '08 / RANDOM '08, pages 165--178, 2008. Google Scholar
Digital Library
- MLton. http://www.mlton.org.Google Scholar
- Christopher J. F. Pickett and Clark Verbrugge. Software Thread Level Speculation for the Java Language and Virtual Machine Environment. In Proceedings of the International Workshop on Languages and Compilers for Parallel Computing, 2005. Google Scholar
Digital Library
- W. Pugh and T. Teitelbaum. Incremental Computation via Function Caching. In POPL, pages 315--328, 1989. Google Scholar
Digital Library
- William Pugh. An Improved Replacement Strategy for Function Caching. In LFP, pages 269--276, 1988. Google Scholar
Digital Library
- Shaz Qadeer, Sriram K. Rajamani, and Jakob Rehof. Summarizing procedures in concurrent programs. In POPL, pages 245--255, 2004. Google Scholar
Digital Library
- John Reppy and Yingqi Xiao. Towards a Parallel Implementation of Concurrent ML. In DAMP 2008, January 2008.Google Scholar
- John H. Reppy. Concurrent Programming in ML. Cambridge University Press, 1999. Google Scholar
Digital Library
- Michael F. Ringenburg and Dan Grossman. AtomCaml: First-Class Atomicity via Rollback. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming, pages 92--104, 2005. Google Scholar
Digital Library
- Bratin Saha, Ali-Reza Adl-Tabatabai, Richard L. Hudson, Chi Cao Minh, and Benjamin Hertzberg. McRT-STM: a High-Performance Software Transactional Memory system for a Multi-Core Runtime. In PPoPP, pages 187--197, 2006. Google Scholar
Digital Library
- Kedar Swadi, Walid Taha, Oleg Kiselyov, and Emir Pasalic. A Monadic Approach for Avoiding Code Duplication When Staging Memoized Functions. In PEPM, pages 160--169, 2006. Google Scholar
Digital Library
- Lukasz Ziarek, Philip Schatz, and Suresh Jagannathan. Stabilizers: A Modular Checkpointing Abstraction for Concurrent Functional Programs. In ACM International Conference on Functional Programming, pages 136--147, 2006. Google Scholar
Digital Library
Index Terms
Partial memoization of concurrency and communication
Recommendations
Partial memoization of concurrency and communication
ICFP '09: Proceedings of the 14th ACM SIGPLAN international conference on Functional programmingMemoization is a well-known optimization technique used to eliminate redundant calls for pure functions. If a call to a function f with argument v yields result r, a subsequent call to f with v can be immediately reduced to r without the need to re-...
Modular Checkpointing for Atomicity
Transient faults that arise in large-scale software systems can often be repaired by re-executing the code in which they occur. Ascribing a meaningful semantics for safe re-execution in multi-threaded code is not obvious, however. For a thread to ...







Comments