Abstract
Self-adjusting programs respond automatically and efficiently to input changes by tracking the dynamic data dependences of the computation and incrementally updating the output as needed. In order to identify data dependences, previously proposed approaches require the user to make use of a set of monadic primitives. Rewriting an ordinary program into a self-adjusting program with these primitives, however, can be difficult and error-prone due to various monadic and proper-usage restrictions, some of which cannot be enforced statically. Previous work therefore suggests that self-adjusting computation would benefit from direct language and compiler support.
In this paper, we propose a language-based technique for writing and compiling self-adjusting programs from ordinary programs. To compile self-adjusting programs, we use a continuation-passing style (cps) transformation to automatically infer a conservative approximation of the dynamic data dependences. To prevent the inferred, approximate dependences from degrading the performance of change propagation, we generate memoized versions of cps functions that can reuse previous work even when they are invoked with different continuations. The approach offers a natural programming style that requires minimal changes to existing code, while statically enforcing the invariants required by self-adjusting computation.
We validate the feasibility of our proposal by extending Standard ML and by integrating the transformation into MLton, a whole-program optimizing compiler for Standard ML. Our experiments indicate that the proposed compilation technique can produce self-adjusting programs whose performance is consistent with the asymptotic bounds and experimental results obtained via manual rewriting (up to a constant factor).
Supplemental Material
Available for Download
Supplemental material for: Compiling self-adjusting programs with continuations
- MLton. http://mlton.org/.Google Scholar
- Flapjax programming language. www.flapjax-lang.org.Google Scholar
- Martín Abadi, Butler W. Lampson, and Jean-Jacques Lévy. Analysis and Caching of Dependencies. In Proceedings of the International Conference on Functional Programming (ICFP), pages 83--91, 1996. Google Scholar
Digital Library
- Umut A. Acar, Guy E. Blelloch, and Robert Harper. Adaptive Functional Programming. In Proceedings of the 29th Annual ACM Symposium on Principles of Programming Languages, pages 247--259, 2002. Google Scholar
Digital Library
- Umut A. Acar, Guy E. Blelloch, and Robert Harper. Selective memoization. In Proceedings of the 30th Annual ACM Symposium on Principles of Programming Languages (POPL), 2003. Google Scholar
Digital Library
- Umut A. Acar, Guy E. Blelloch, Matthias Blume, Robert Harper, and Kanat Tangwongsan. A Library for Self-Adjusting Computation. Electronic Notes in Theoretical Computer Science, 148(2), 2006a. Google Scholar
Digital Library
- Umut A. Acar, Guy E. Blelloch, Matthias Blume, and Kanat Tangwongsan. An experimental analysis of self-adjusting computation. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2006b. Google Scholar
Digital Library
- Umut A. Acar, Guy E. Blelloch, Kanat Tangwongsan, and Jorge L. Vittes. Kinetic Algorithms via Self-Adjusting Computation. In Proceedings of the 14th Annual European Symposium on Algorithms (ESA), pages 636--647, September 2006c. Google Scholar
Digital Library
- Umut A. Acar, Alexander Ihler, Ramgopal Mettu, and Özgür Sümer. Adaptive Bayesian Inference. In Neural Information Processing Systems (NIPS), 2007.Google Scholar
- Umut A. Acar, Amal Ahmed, and Matthias Blume. Imperative self-adjusting computation. In Proceedings of the 25th Annual ACM Symposium on Principles of Programming Languages (POPL), 2008a. Google Scholar
Digital Library
- Umut A. Acar, Guy E. Blelloch, Kanat Tangwongsan, and Duru Türkoglu. Robust Kinetic Convex Hulls in 3D. In Proceedings of the 16th Annual European Symposium on Algorithms (ESA), September 2008b. Google Scholar
Digital Library
- Umut A. Acar, Alexander Ihler, Ramgopal Mettu, and Özgür Sümer. Adaptive Inference on General Graphical Models. In Uncertainty in Artificial Intelligence (UAI), 2008c.Google Scholar
- C. Bradford Barber, David P. Dobkin, and Hannu Huhdanpaa. The Quickhull Algorithm for Convex Hulls. ACM Trans. Math. Softw., 22 (4): 469--483, 1996. Google Scholar
Digital Library
- Richard Bellman. Dynamic Programming. Princeton University Press, 1957. Google Scholar
Digital Library
- Kimberley Burchett, Gregory H. Cooper, and Shriram Krishnamurthi. Lowering: A Static Optimization Technique for Transparent Functional Reactivity. In PEPM '07: Proceedings of the 2007 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation, pages 71--80. ACM, 2007. Google Scholar
Digital Library
- Magnus Carlsson. Monads for Incremental Computing. In Proceedings of the 7th ACM SIGPLAN International Conference on Functional programming (ICFP), pages 26--35. ACM Press, 2002. Google Scholar
Digital Library
- Gregory H. Cooper and Shriram Krishnamurthi. FrTime: Functional Reactive Programming in PLT Scheme. Technical Report CS-03-20, Department of Computer Science, Brown University, April 2004.Google Scholar
- Gregory H. Cooper and Shriram Krishnamurthi. Embedding Dynamic Dataflow in a Call-by-Value Language. In Proceedings of the 15th Annual European Symposium on Programming (ESOP), 2006. Google Scholar
Digital Library
- Antony Courtney. Frappé: Functional Reactive Programming in Java. In PADL '01: Proceedings of the Third International Symposium on Practical Aspects of Declarative Languages, pages 29--44. Springer-Verlag, 2001. Google Scholar
Digital Library
- Olivier Danvy and John Hatcliff. CPS Transformation after Strictness Analysis. Letters on Programming Languages and Systems (LOPLS), 1 (3): 195--212, 1993a. Google Scholar
Digital Library
- Olivier Danvy and John Hatcliff. On the Transformation between Direct and Continuation Semantics. In Proceedings of the Ninth Conference on Mathematical Foundations of Programming Semantics (MFPS), pages 627--648, 1993b. Google Scholar
Digital Library
- Alan Demers, Thomas Reps, and Tim Teitelbaum. Incremental Evaluation of Attribute Grammars with Application to Syntax-directed Editors. In Proceedings of the 8th Annual ACM Symposium on Principles of Programming Languages, pages 105--116, 1981. Google Scholar
Digital Library
- Conal Elliott. Functional Implementations of Continuous Modeled Animation. Lecture Notes in Computer Science, 1490: 284--299, 1998. Google Scholar
Digital Library
- Conal Elliott and Paul Hudak. Functional Reactive Animation. In ICFP '97: Proceedings of the second ACM SIGPLAN international conference on Functional programming, pages 263--273. ACM, 1997. Google Scholar
Digital Library
- Matthew Hammer and Umut A. Acar. Memory Management for Self-Adjusting Computation. In The 2008 International Symposium on Memory Management, 2008. Google Scholar
Digital Library
- Fritz Henglein, Henning Makholm, and Henning Niss. Effect Types and Region-based Memory Management. In Benjamin Pierce, editor, Advanced Topics in Types and Programming Languages, chapter 3, pages 87--135. MIT Press, Cambridge, MA, 2005.Google Scholar
- Allan Heydon, Roy Levin, and Yuan Yu. Caching Function Calls Using Precise Dependencies. In Proceedings of the 2000 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 311--320, 2000. Google Scholar
Digital Library
- Jung-taek Kim and Kwangkeun Yi. Interconnecting Between CPS Terms and Non-CPS Terms. In Proceedings of the Third ACM SIGPLAN Workshop on Continuations (CW), pages 7--16, 2001.Google Scholar
- Jung-taek Kim, Kwangkeun Yi, and Olivier Danvy. Assessing the Overhead of ML Exceptions. In Proceedings of the ACM SIGPLAN Workshop on ML, pages 112--119, 1998.Google Scholar
- Yanhong A. Liu, Scott Stoller, and Tim Teitelbaum. Static Caching for Incremental Computation. ACM Transactions on Programming Languages and Systems, 20 (3): 546--585, 1998. Google Scholar
Digital Library
- John McCarthy. A Basis for a Mathematical Theory of Computation. In P. Braffort and D. Hirschberg, editors, Computer Programming and Formal Systems, pages 33--70. North-Holland, Amsterdam, 1963.Google Scholar
Cross Ref
- D. Michie. "Memo" Functions and Machine Learning. Nature, 218: 19--22, 1968.Google Scholar
- Lasse Nielsen. A Selective CPS Transformation. In Proceedings of the Seventeenth Conference on the Mathematical Foundations of Programming Semantics (MFPS), volume 45 of Electronic Notes in Theoretical Computer Science (ENTCS), pages 311--331. Elsevier, November 2001.Google Scholar
- Henrik Nilsson, Antony Courtney, and John Peterson. Functional Reactive Programming, Continued. In Proceedings of the 2002 ACM SIGPLAN Haskell Workshop (Haskell'02), pages 51--64, Pittsburgh, Pennsylvania, USA, October 2002. ACM Press. Google Scholar
Digital Library
- F. P. Preparata and M. I. Shamos. Computational Geometry. Springer-Verlag Inc., 1985. Google Scholar
Digital Library
- William Pugh and Tim Teitelbaum. Incremental computation via function caching. In Proceedings of the 16th Annual ACM Symposium on Principles of Programming Languages, pages 315--328, 1989. Google Scholar
Digital Library
- G. Ramalingam and T. Reps. A Categorized Bibliography on Incremental Computation. In Proceedings of the 20th Annual ACM Symposium on Principles of Programming Languages (POPL), pages 502--510, 1993. Google Scholar
Digital Library
- Thomas Reps. Optimal-time incremental semantic analysis for syntax-directed editors. In Proceedings of the 9th Annual Symposium on Principles of Programming Languages (POPL), pages 169--176, 1982. Google Scholar
Digital Library
- Ajeet Shankar and Rastislav Bodik. DITTO: Automatic Incrementalization of Data Structure Invariant Checks (in Java). In Proceedings of the ACM SIGPLAN 2007 Conference on Programming language Design and Implementation (PLDI), 2007. Google Scholar
Digital Library
- Hayo Thielecke. Comparing Control Constructs by Double-barrelled CPS. Higher-Order and Symbolic Computation, 15 (2/3): 367--412, 2002. Google Scholar
Digital Library
- D. M. Yellin and R. E. Strom. INC: A Language for Incremental Computations. ACM Transactions on Programming Languages and Systems, 13 (2): 211--236, April 1991. Google Scholar
Digital Library
Index Terms
Compiling self-adjusting programs with continuations
Recommendations
Compiling self-adjusting programs with continuations
ICFP '08: Proceedings of the 13th ACM SIGPLAN international conference on Functional programmingSelf-adjusting programs respond automatically and efficiently to input changes by tracking the dynamic data dependences of the computation and incrementally updating the output as needed. In order to identify data dependences, previously proposed ...
Imperative self-adjusting computation
POPL '08Self-adjusting computation enables writing programs that can automatically and efficiently respond to changes to their data (e.g., inputs). The idea behind the approach is to store all data that can change over time in modifiable references and to let ...
Imperative self-adjusting computation
POPL '08: Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesSelf-adjusting computation enables writing programs that can automatically and efficiently respond to changes to their data (e.g., inputs). The idea behind the approach is to store all data that can change over time in modifiable references and to let ...







Comments