skip to main content
research-article

Pycket: a tracing JIT for a functional language

Published:29 August 2015Publication History
Skip Abstract Section

Abstract

We present Pycket, a high-performance tracing JIT compiler for Racket. Pycket supports a wide variety of the sophisticated features in Racket such as contracts, continuations, classes, structures, dynamic binding, and more. On average, over a standard suite of benchmarks, Pycket outperforms existing compilers, both Racket's JIT and other highly-optimizing Scheme compilers. Further, Pycket provides much better performance for Racket proxies than existing systems, dramatically reducing the overhead of contracts and gradual typing. We validate this claim with performance evaluation on multiple existing benchmark suites. The Pycket implementation is of independent interest as an application of the RPython meta-tracing framework (originally created for PyPy), which automatically generates tracing JIT compilers from interpreters. Prior work on meta-tracing focuses on bytecode interpreters, whereas Pycket is a high-level interpreter based on the CEK abstract machine and operates directly on abstract syntax trees. Pycket supports proper tail calls and first-class continuations. In the setting of a functional language, where recursion and higher-order functions are more prevalent than explicit loops, the most significant performance challenge for a tracing JIT is identifying which control flows constitute a loop---we discuss two strategies for identifying loops and measure their impact.

References

  1. A. Appel and D. MacQueen. Standard ML of New Jersey. In J. Maluszy´nski and M. Wirsing, editors, Programming Language Implementation and Logic Programming, volume 528 of Lecture Notes in Computer Science, pages 1–13. Springer Berlin Heidelberg, 1991.Google ScholarGoogle Scholar
  2. H. Ardö, C. F. Bolz, and M. Fijakowski. Loop-aware optimizations in PyPy’s tracing JIT. In Proceedings of the 8th Symposium on Dynamic Languages, DLS ’12, pages 63–72, New York, NY, USA, 2012. ACM. J. Aycock. A brief history of just-in-time. ACM Comput. Surv., 35(2):97–113, June 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: A transparent dynamic optimization system. In Proceedings of the ACM SIGPLAN 2000 Conference on Programming Language Design and Implementation, PLDI ’00, pages 1–12, New York, NY, USA, 2000. ACM. M. Bebenita, F. Brandner, M. Fahndrich, F. Logozzo, W. Schulte, N. Tillmann, and H. Venter. SPUR: A trace-based JIT compiler for CIL. In Proc. OOPSLA, pages 708–725, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. C. F. Bolz and L. Tratt. The impact of meta-tracing on VM design and implementation. Science of Computer Programming, 2013.Google ScholarGoogle Scholar
  5. C. F. Bolz, A. Cuni, M. Fijakowski, and A. Rigo. Tracing the meta-level: PyPy’s tracing JIT compiler. In Proc. ICOOOLPS, pages 18–25, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. C. F. Bolz, A. Cuni, M. Fijakowski, M. Leuschel, S. Pedroni, and A. Rigo. Allocation removal by partial evaluation in a tracing JIT. Proc. PEPM, pages 43–52, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. F. Bolz, L. Diekmann, and L. Tratt. Storage strategies for collections in dynamically typed languages. In Proc. OOPSLA, pages 167–182, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. C. F. Bolz, T. Pape, J. G. Siek, and S. Tobin-Hochstadt. Meta-tracing makes a fast Racket. In Workshop on Dynamic Languages and Applications, 2014.Google ScholarGoogle Scholar
  9. C. Chambers and D. Ungar. Iterative type analysis and extended message splitting: optimizing dynamically-typed object-oriented programs. Lisp Symb. Comput., 4(3):283–310, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. Chambers, D. Ungar, and E. Lee. An efficient implementation of SELF a dynamically-typed object-oriented language based on prototypes. In Proc. OOPSLA, pages 49–70, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Chang, B. Mathiske, E. Smith, A. Chaudhuri, A. Gal, M. Bebenita, C. Wimmer, and M. Franz. The impact of optional type information on JIT compilation of dynamically typed languages. In Symposium on Dynamic Languages, DLS ’11, pages 13–24, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Clements. Portable and high-level access to the stack with Continuation Marks. PhD thesis, Citeseer, 2006.Google ScholarGoogle Scholar
  13. D. Clifford, H. Payer, M. Stanton, and B. L. Titzer. Memento Mori: Dynamic allocation-site-based optimizations. In Proc. ISMM, pages 105–117. ACM, 2015. ISBN 978-1-4503-3589-8. W. D. Clinger and L. T. Hansen. Lambda, the ultimate label or a simple optimizing compiler for Scheme. In Proc. LFP, pages 128–139, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems, 13(4):451490, Oct. 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. O. Danvy. Three steps for the CPS transformation. Technical Report CIS- 92-02, Kansas State University, 1991.Google ScholarGoogle Scholar
  16. A. C. Davison and D. V. Hinkley. Bootstrap Methods and Their Application, chapter 5. Cambridge, 1997.Google ScholarGoogle ScholarCross RefCross Ref
  17. J. W. Demmel. Applied Numerical Linear Algebra. SIAM, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. L. P. Deutsch and A. M. Schiffman. Efficient implementation of the Smalltalk-80 system. In Proc. POPL, pages 297–302, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. T. Disney, C. Flanagan, and J. McCarthy. Temporal higher-order contracts. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming, ICFP ’11, pages 176–188, New York, NY, USA, 2011. ACM. R. K. Dybvig. Chez Scheme version 8 user’s guide. Technical report, Cadence Research Systems, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Feeley. Gambit-C: A portable implementation of Scheme. Technical Report v4.7.2, Universite de Montreal, February 2014.Google ScholarGoogle Scholar
  21. M. Felleisen and D. P. Friedman. Control operators, the SECD-machine and the lambda-calculus. In Working Conf. on Formal Description of Programming Concepts - III, pages 193–217. Elsevier, 1987.Google ScholarGoogle Scholar
  22. R. B. Findler and M. Felleisen. Contracts for higher-order functions. In International Conference on Functional Programming, ICFP, pages 48– 59, October 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. R. B. Findler, S.-y. Guo, and A. Rogers. Lazy contract checking for immutable data structures. In Implementation and Application of Functional Languages, pages 111–128. Springer, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In Proc. PLDI, pages 502–514, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. M. Flatt. Composable and compilable macros: you want it when? In ICFP ’02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programming, pages 72–83. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. A. Gal and M. Franz. Incremental dynamic code generation with trace trees. Technical Report ICS-TR-06-16, University of California, Irvine, 2006.Google ScholarGoogle Scholar
  27. A. Gal, C. W. Probst, and M. Franz. HotpathVM: an effective JIT compiler for resource-constrained devices. In Proc. VEE, pages 144–153, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M. R. Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman, E. W. Smith, R. Reitmaier, M. Bebenita, M. Chang, and M. Franz. Trace-based justin-time type specialization for dynamic languages. In Proc. PLDI, pages 465–478. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. A. Gill, J. Launchbury, and S. L. Peyton Jones. A short cut to deforestation. In Proc. FPCA, pages 223–232, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. M. Hölttä. Crankshafting from the ground up. Technical report, Google, August 2013.Google ScholarGoogle Scholar
  31. M. N. Kedlaya, J. Roesch, B. Robatmili, M. Reshadi, and B. Hardekopf. Improved type specialization for dynamic scripting languages. In Proceedings of the 9th Symposium on Dynamic Languages, DLS ’13, pages 37–48. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. J. Launchbury. A natural semantics for lazy evaluation. In Proc. POPL, pages 144–154, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. Marr, T. Pape, and W. De Meuter. Are we there yet? Simple language implementation techniques for the 21st century. IEEE Software, 31(5): 6067, Sept. 2014.Google ScholarGoogle ScholarCross RefCross Ref
  34. B. Meurer. OCamlJIT 2.0 - Faster Objective Caml. CoRR, abs/1011.1783, 2010.Google ScholarGoogle Scholar
  35. J. G. Mitchell. The Design and Construction of Flexible and Efficient Interactive Programming Systems. PhD thesis, Carnegie Mellon University, 1970. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. M. Paleczny, C. Vick, and C. Click. The Java Hotspot server compiler. In Proc. JVM, pages 1–1. USENIX Association, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. T. Schilling. Challenges for a Trace-Based Just-In-Time Compiler for Haskell. In Implementation and Application of Functional Languages, volume 7257 of LNCS, pages 51–68. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. T. Schilling. Trace-based Just-in-time Compilation for Lazy Functional Programming Languages. PhD thesis, University of Kent, 2013.Google ScholarGoogle Scholar
  39. M. Serrano and P. Weis. Bigloo: a portable and optimizing compiler for strict functional languages. In Static Analysis, volume 983 of LNCS, pages 366–381. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. J. M. Siskind. Flow-directed lightweight closure conversion. Technical Report 99-190R, NEC Research Institute, Inc., 1999.Google ScholarGoogle Scholar
  41. M. Sperber, R. K. Dybvig, M. Flatt, A. van Straaten, R. Findler, and J. Matthews. Revised 6 Report on the Algorithmic Language Scheme. Cambridge, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. V. St-Amour, S. Tobin-Hochstadt, and M. Felleisen. Optimization coaching: Optimizers learn to communicate with programmers. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’12, pages 163–178, New York, NY, USA, 2012. ACM. B. Starynkevitch. OCAMLJIT – A faster just-in-time OCaml implementation. In First MetaOCaml Workshop, Oct. 20 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. G. L. Steele. Rabbit: A compiler for Scheme. Technical Report AI-474, MIT, 1978. Google ScholarGoogle Scholar
  44. T. S. Strickland, S. Tobin-Hochstadt, R. B. Findler, and M. Flatt. Chaperones and impersonators: run-time support for reasonable interposition. In Object Oriented Programming Systems Languages and Applications, OOPSLA ’12, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. G. T. Sullivan, D. L. Bruening, I. Baron, T. Garnett, and S. Amarasinghe. Dynamic native optimization of interpreters. In Proc. IVME, pages 50–57, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. E. W. Thomassen. Trace-based just-in-time compiler for Haskell with RPython. Master’s thesis, Norwegian University of Science and Technology Trondheim, 2013.Google ScholarGoogle Scholar
  47. S. Tobin-Hochstadt and M. Felleisen. The design and implementation of typed scheme. In Proceedings of the 35th Annual ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, POPL ’08, pages 395–406, New York, NY, USA, 2008. ACM. S. Tobin-Hochstadt, V. St-Amour, R. Culpepper, M. Flatt, and M. Felleisen. Languages as libraries. In Proceedings of the 32nd ACM SIGPLAN conference on Programming language design and implementation, PLDI ’11, pages 132–141. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. T. Van Cutsem and M. S. Miller. Proxies: Design principles for robust object-oriented intercession apis. In Proceedings of the 6th Symposium on Dynamic Languages, DLS ’10, pages 59–72, New York, NY, USA, 2010. ACM. P. Wadler. Deforestation: transforming programs to eliminate trees. In Proc. ESOP, pages 231–248, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Pycket: a tracing JIT for a functional language

        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 50, Issue 9
          ICFP '15
          September 2015
          436 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2858949
          • Editor:
          • Andy Gill
          Issue’s Table of Contents
          • cover image ACM Conferences
            ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming
            August 2015
            436 pages
            ISBN:9781450336697
            DOI:10.1145/2784731

          Copyright © 2015 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 29 August 2015

          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!