skip to main content
research-article

Compiling self-adjusting programs with continuations

Authors Info & Claims
Published:20 September 2008Publication History
Skip Abstract Section

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).

Skip Supplemental Material Section

Supplemental Material

Video

References

  1. MLton. http://mlton.org/.Google ScholarGoogle Scholar
  2. Flapjax programming language. www.flapjax-lang.org.Google ScholarGoogle Scholar
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Umut A. Acar, Alexander Ihler, Ramgopal Mettu, and Özgür Sümer. Adaptive Bayesian Inference. In Neural Information Processing Systems (NIPS), 2007.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle Scholar
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. Richard Bellman. Dynamic Programming. Princeton University Press, 1957. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. Olivier Danvy and John Hatcliff. CPS Transformation after Strictness Analysis. Letters on Programming Languages and Systems (LOPLS), 1 (3): 195--212, 1993a. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. Conal Elliott. Functional Implementations of Continuous Modeled Animation. Lecture Notes in Computer Science, 1490: 284--299, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. Matthew Hammer and Umut A. Acar. Memory Management for Self-Adjusting Computation. In The 2008 International Symposium on Memory Management, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle Scholar
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle Scholar
  29. 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 ScholarGoogle Scholar
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarCross RefCross Ref
  32. D. Michie. "Memo" Functions and Machine Learning. Nature, 218: 19--22, 1968.Google ScholarGoogle Scholar
  33. 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 ScholarGoogle Scholar
  34. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  35. F. P. Preparata and M. I. Shamos. Computational Geometry. Springer-Verlag Inc., 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  37. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  38. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  40. Hayo Thielecke. Comparing Control Constructs by Double-barrelled CPS. Higher-Order and Symbolic Computation, 15 (2/3): 367--412, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Compiling self-adjusting programs with continuations

    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

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 43, Issue 9
      ICFP '08
      September 2008
      399 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1411203
      Issue’s Table of Contents
      • cover image ACM Conferences
        ICFP '08: Proceedings of the 13th ACM SIGPLAN international conference on Functional programming
        September 2008
        422 pages
        ISBN:9781595939197
        DOI:10.1145/1411204

      Copyright © 2008 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 20 September 2008

      Check for updates

      Qualifiers

      • research-article

    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!