skip to main content
10.1145/944705.944731acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Optimistic evaluation: an adaptive evaluation strategy for non-strict programs

Published:25 August 2003Publication History

ABSTRACT

Lazy programs are beautiful, but they are slow because they build many thunks. Simple measurements show that most of these thunks are unnecessary: they are in fact always evaluated, or are always cheap. In this paper we describe Optimistic Evaluation --- an evaluation strategy that exploits this observation. Optimistic Evaluation complements compile-time analyses with run-time experiments: it evaluates a thunk speculatively, but has an abortion mechanism to back out if it makes a bad choice. A run-time adaption mechanism records expressions found to be unsuitable for speculative evaluation, and arranges for them to be evaluated more lazily in the future.We have implemented optimistic evaluation in the Glasgow Haskell Compiler. The results are encouraging: many programs speed up significantly (5-25%), some improve dramatically, and none go more than 15% slower.

References

  1. L. Augustsson and T. Johnsson. The chalmers lazy-ML compiler. The Computer Journal, 32(2):127--141, Apr. 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. T. Ball and J. R. Larus. Branch prediction for free. In ACM Conference on Programming Languages Design and Implementation (PLDI'93), pages 300--313. ACM, June 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. U. Boquist. Code Optimisation Techniques for Lazy Functional Languages. PhD thesis, Chalmers University of Technology, Sweden, April 1999.Google ScholarGoogle Scholar
  4. M. G. Burke, J.-D. Choi, S. Fink, D. Grove, M. Hind, V. Sarkar, M. J. Serrano, V. Sreedhar, H. Srinivasan, and J. Whaley. The Jalapeno dynamic optimizing compiler for Java. In Proceedings of the ACM Java Grande Conference, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. F. W. Burton. Speculative computation, parallelism and functional programming. IEEE Trans Computers, C-34(12):1190--1193, Dec. 1985.Google ScholarGoogle ScholarCross RefCross Ref
  6. M. M. T. Chakravarty. Lazy thread and task creation in parallel graph reduction. In International Workshop on Implementing Functional Languages, Lecture Notes in Computer Science. Springer Verlag, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K.-F. Faxén. Cheap eagerness: Speculative evaluation in a lazy functional language. In ACM SIGPLAN International Conference on Functional Programming (ICFP'00), Montreal, Sept. 2000. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. K.-F. Faxén. Dynamic cheap eagerness. In Proceedings of the 2001 Workshop on Implementing Functional Languages. Springer Verlag, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. ACM Workshop on Feedback Directed and Dynamic Optimization (FDDO), 2001.Google ScholarGoogle Scholar
  10. M. Frigo, C. E. Leiserson, and K. H. Randall. The implementation of the Cilk-5 multithreaded language. In ACM Conference on Programming Languages Design and Implementation (PLDI'98), volume~33, pages 212--223, Atlanta, May 1998. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. Gustavsson. A type-based sharing analysis for update avoidance and optimisation. In ACM SIGPLAN International Conference on Functional Programming (ICFP'98), volume 34(1) of ACM SIGPLAN Notices, Baltimore, 1998. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. R. H. Halstead. Multilisp - a language for concurrent symbolic computation. ACM Transactions on Programming Languages and Systems, 7(4):501--538, Oct. 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. K. Hammond and J. O'Donnell, editors. Functional Programming, Glasgow 1993, Workshops in Computing. Springer Verlag, 1993.Google ScholarGoogle Scholar
  14. C. Haynes and D. Friedman. Engines build process abstractions. In Conference Record of the 1984 ACM Symposium on Lisp and Functional Programming, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. U. Hölzle. Adaptive optimization for Self: reconciling high performance with exploratory programming. Ph.D. thesis, Computer Science Department, Stanford University, Mar. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Hughes. Why functional programming matters. The Computer Journal, 32(2):98--107, Apr. 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. M. Huntback. Speculative computation and priorities in concurrent logic languages. In ALPUK Conference, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. H. M. J. Gosling. The Java Language Environment: a White Paper. Technical report, Sun Microsystems, 1996.Google ScholarGoogle Scholar
  19. J.-W. Maessen. Eager Haskell: Resource-bounded execution yields efficient iteration. In The Haskell Workshop, Pittsburgh, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. J.-W. Maessen. Hybrid Eager and Lazy Evaluation for Efficient Compilation of Haskell. PhD thesis, Massachusetts Institute of Technology, June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. S. Marlow, S. Peyton Jones, A. Moran, and J. Reppy. Asynchronous exceptions in Haskell. In ACM Conference on Programming Languages Design and Implementation (PLDI'01), pages 274--285, Snowbird, Utah, June 2001. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. Mattson. An effective speculative evaluation technique for parallel supercombinator graph reduction. Ph.D. thesis, Department of Computer Science and Engineering, University of California, San Diego, Feb. 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. J. S. Mattson Jr and W. G. Griswold. Local Speculative Evaluation for Distributed Graph Reduction. In Hammond and O'Donnell {13}, pages 185--192. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. L. Maurer. Isn't this tail recursive? Message posted to the Haskell mailing list: http://haskell.org/pipermail/haskell/2002-March/009126.html, Mar. 2002.Google ScholarGoogle Scholar
  25. E. Mohr, D. Kranz, and R. Halstead. Lazy task creation - a technique for increasing the granularity of parallel programs. IEEE Transactions on Parallel and Distributed Systems, 2(3), July 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. A. Moran, S. Lassen, and S. Peyton Jones. Imprecise exceptions, co-inductively. In Higher Order Operational Techniques in Semantics: Third International Workshop, number~26 in Electronic Notes in Theoretical Computer Science, pages 137--156. Elsevier, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  27. R. Osbourne. Speculative computation in Multilisp. PhD thesis, MIT Lab for Computer Science, Dec. 1989.Google ScholarGoogle Scholar
  28. W. Partain. The nofib benchmark suite of Haskell programs. In J. Launchbury and P. Sansom, editors, Functional Programming, Glasgow 1992, Workshops in Computing, pages 195--202. Springer Verlag, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. Peyton Jones, C. Hall, K. Hammond, W. Partain, and P. Wadler. The Glasgow Haskell Compiler: a technical overview. In Proceedings of Joint Framework for Information Technology Technical Conference, Keele, pages 249--257. DTI/SERC, Mar. 1993.Google ScholarGoogle Scholar
  30. S. Peyton Jones, S. Marlow, and A. Reid. The STG runtime system (revised). Technical report, Microsoft Research, February 1999. Part of GHC source package.Google ScholarGoogle Scholar
  31. S. Peyton Jones and W. Partain. Measuring the effectiveness of a simple strictness analyser. In Hammond and O'Donnell {13}, pages 201--220.Google ScholarGoogle Scholar
  32. S. Peyton Jones, A. Reid, C. Hoare, S. Marlow, and F. Henderson. A semantics for imprecise exceptions. In ACM Conference on Programming Languages Design and Implementation (PLDI'99), pages 25--36, Atlanta, May 1999. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. Peyton Jones and P. Wadler. Imperative functional programming. In 20th ACM Symposium on Principles of Programming Languages (POPL'93), pages 71--84. ACM, Jan. 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. K. Schauser, D. Culler, and S. Goldstein. Separation constraint partitioning: a new algorithm for partitioning non-strict programs into sequential threads. In 22nd ACM Symposium on Principles of Programming Languages (POPL'95), pages 259--271. ACM, Jan. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. P. Sestoft. Deriving a lazy abstract machine. Journal of Functional Programming, 7, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. J. E. Smith. A study of branch prediction strategies. In International Symposium on Computer Architecture, 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Sun Microsystems. The Java HotSpot Virtual machine, White Paper, 2001.Google ScholarGoogle Scholar
  38. K. Traub. Sequential implementation of lenient programming languages. Ph.D. thesis, MIT Lab for Computer Science, 1988.Google ScholarGoogle Scholar
  39. C. von Dorrien. Stingy evaluation. Licentiate thesis, Chalmers University of Technology, May 1989.Google ScholarGoogle Scholar
  40. P. Wadler and J. Hughes. Projections for strictness analysis. In G. Kahn, editor, Functional Programming Languages and Computer Architecture. Springer Verlag LNCS 274, Sept. 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Optimistic evaluation: an adaptive evaluation strategy for non-strict programs

      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
        ICFP '03: Proceedings of the eighth ACM SIGPLAN international conference on Functional programming
        August 2003
        310 pages
        ISBN:1581137567
        DOI:10.1145/944705
        • cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 38, Issue 9
          September 2003
          289 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/944746
          Issue’s Table of Contents

        Copyright © 2003 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: 25 August 2003

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • Article

        Acceptance Rates

        ICFP '03 Paper Acceptance Rate24of95submissions,25%Overall Acceptance Rate333of1,064submissions,31%

        Upcoming Conference

        ICFP '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader