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

  • Authors:
  • Robert Ennals;Simon Peyton Jones

  • Affiliations:
  • University of Cambridge, Cambridge, UK;Microsoft Research Ltd, Cambridge, UK

  • Venue:
  • ICFP '03 Proceedings of the eighth ACM SIGPLAN international conference on Functional programming
  • Year:
  • 2003

Quantified Score

Hi-index 0.00

Visualization

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.