10.1145/1565824.1565827acmotherconferencesArticle/Chapter ViewAbstractPublication PagesecoopConference Proceedingsconference-collections
research-article

Tracing the meta-level: PyPy's tracing JIT compiler

Published:06 July 2009Publication History

ABSTRACT

We attempt to apply the technique of Tracing JIT Compilers in the context of the PyPy project, i.e., to programs that are interpreters for some dynamic languages, including Python. Tracing JIT compilers can greatly speed up programs that spend most of their time in loops in which they take similar code paths. However, applying an unmodified tracing JIT to a program that is itself a bytecode interpreter results in very limited or no speedup. In this paper we show how to guide tracing JIT compilers to greatly improve the speed of bytecode interpreters. One crucial point is to unroll the bytecode dispatch loop, based on two kinds of hints provided by the implementer of the bytecode interpreter. We evaluate our technique by applying it to two PyPy interpreters: one is a small example, and the other one is the full Python interpreter.

References

  1. D. Ancona, M. Ancona, A. Cuni, and N. D. Matsakis. RPython: a step towards reconciling dynamically and statically typed OO languages. In Proceedings of the 2007 Symposium on Dynamic Languages, pages 53--64, Montreal, Quebec, Canada, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: a transparent dynamic optimization system. ACM SIGPLAN Notices, 35(5):1--12, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. C. F. Bolz. Automatic JIT Compiler Generation with Runtime Partial Evaluation. Master thesis, Heinrich-Heine-Universität Düsseldorf, 2008.Google ScholarGoogle Scholar
  4. C. F. Bolz, A. Kuhn, A. Lienhard, N. Matsakis, O. Nierstrasz, L. Renggli, A. Rigo, and T. Verwaest. Back to the Future in One Week --- Implementing a Smalltalk VM in PyPy, pages 123--139. 2008.Google ScholarGoogle Scholar
  5. C. F. Bolz and A. Rigo. How to not write a virtual machine. In Proceedings of the 3rd Workshop on Dynamic Languages and Applications (DYLA), 2007.Google ScholarGoogle Scholar
  6. C. Bruni and T. Verwaest. PyGirl: generating Whole-System VMs from High-Level prototypes using PyPy. In Tools, accepted for publication, 2009.Google ScholarGoogle Scholar
  7. S. Brunthaler. Virtual-Machine abstraction and optimization techniques. In Proceedings of the 4th International Workshop on Bytecode Semantics, Verification, Analysis and Transformation, 2009. to appear.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Chang, M. Bebenita, A. Yermolovich, A. Gal, and M. Franz. Efficient Just-In-Time execution of dynamically typed languages via code specialization using precise runtime type inference. Technical Report ICS-TR-07-10, Donald Bren School of Information and Computer Science, University of California, Irvine, 2007.Google ScholarGoogle Scholar
  9. M. Chang, E. Smith, R. Reitmaier, M. Bebenita, A. Gal, C. Wimmer, B. Eich, and M. Franz. Tracing for Web 3.0: Trace compilation for the next generation web applications. In Proceedings of the 2009 ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, pages 71--80, Washington, DC, USA, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. Consel, L. Hornof, F. Noël, J. Noyé, and N. Volanschi. A uniform approach for compile-time and run-time specialization. Dagstuhl Seminar on Partial Evaluation, pages 54--72, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. C. Consel and F. Noël. A general approach for run-time specialization and its application to C. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 145--156, St. Petersburg Beach, Florida, United States, 1996. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. A. Cuni, D. Ancona, and A. Rigo. Faster than C#: Efficient implementation of dynamic languages on .NET. Accepted at ICOOOLPS'09. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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):451--490, Oct. 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. M. A. Ertl and D. Gregg. Retargeting JIT compilers by using C-Compiler generated executable code. In Proceedings of the 13th International Conference on Parallel Architectures and Compilation Techniques, pages 41--50. IEEE Computer Society, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Y. Futamura. Partial evaluation of computation process - an approach to a Compiler-Compiler. Higher-Order and Symbolic Computation, 12(4):381--391, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. A. Gal, B. Eich, M. Shaver, D. Anderson, B. Kaplan, G. Hoare, D. Mandelin, B. Zbarsky, J. Orendorff, M. Bebenita, M. Chang, M. Franz, E. Smith, R. Reitmaier, and M. Haghighat. Trace-based Just-in-Time type specialization for dynamic languages. In PLDI, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. A. Gal and M. Franz. Incremental dynamic code generation with trace trees. Technical Report ICS-TR-06-16, University of California, Irvine, Nov. 2006.Google ScholarGoogle Scholar
  18. A. Gal, C. W. Probst, and M. Franz. HotpathVM: an effective JIT compiler for resource-constrained devices. In Proceedings of the 2nd International Conference on Virtual Execution Environments, pages 144--153, Ottawa, Ontario, Canada, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. B. Grant, M. Mock, M. Philipose, C. Chambers, and S. J. Eggers. DyC: an expressive annotation-directed dynamic compiler for C. Theoretical Computer Science, 248(1--2):147--199, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. U. Hölzle. Adaptive optimization for SELF: reconciling high performance with exploratory programming. Technical report, Stanford University, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. N. D. Jones, C. K. Gomard, and P. Sestoft. Partial evaluation and Automatic Program Generation. Prentice-Hall, Inc., 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. I. Piumarta and F. Riccardi. Optimizing direct threaded code by selective inlining. SIGPLAN Not., 33(5):291--300, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. A. Rigo. Representation-based just-in-time specialization and the Psyco prototype for Python. In Proceedings of the 2004 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 15--26, Verona, Italy, 2004. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. A. Rigo and S. Pedroni. PyPy's approach to virtual machine construction. In Companion to the 21st ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 944--953, Portland, Oregon, USA, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. A. Rigo and S. Pedroni. JIT compiler architecture. Technical Report D08.2, PyPy, May 2007.Google ScholarGoogle Scholar
  26. G. T. Sullivan. Dynamic partial evaluation. In Proceedings of the Second Symposium on Programs as Data Objects, pages 238--256. Springer-Verlag, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. G. T. Sullivan, D. L. Bruening, I. Baron, T. Garnett, and S. Amarasinghe. Dynamic native optimization of interpreters. In Proceedings of the 2003 Workshop on Interpreters, Virtual Machines and Emulators, pages 50--57, San Diego, California, 2003. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Tracing the meta-level: PyPy's tracing JIT compiler

          Reviews

          R. Clayton

          Making sure that the cobbler's children are well shod has been a fruitful research line in programming language processing. Bolz et al. consider in this paper how the tracing just-in-time (JIT) compilation techniques used in language interpreters can be applied to the interpreters themselves, and what happens as a result. JIT compilation translates interpreted bytecode into native code, reducing interpretation overhead. Tracing identifies frequently executed code (hot spots), highlighting the program parts that would benefit most from JIT compilation. The PyPy project is a Python-based framework for implementing language interpreters. Embedding tracing JIT compilation techniques in the framework makes it possible to apply those techniques to the interpreter. However, the interpreter structure and execution have properties that frustrate both tracing and JIT compilation. This paper covers the method used to apply tracing JIT techniques to an interpreter implementation, and how to adjust interpreter design to better exploit the techniques. The heart of the method involves unrolling the bytecode dispatch loop, based on annotations added to the interpreter by the implementer. The paper also explains the tracing interpretations used to identify interpreter hot spots. Benchmark evaluations show that tracing JIT techniques improve an interpreter's performance on simple functions 2.8 to 4.7 times, over simply translating the interpreter to native code. The paper reads well, but requires careful attention to identify the appropriate processing level being described. Knowing Python is not necessary, but basic knowledge of interpreters would be helpful. The bibliography and related works section could, as always, be larger, but they are adequate. Online Computing Reviews Service

          Access critical reviews of Computing literature here

          Become a reviewer for Computing Reviews.

          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 Other conferences
            ICOOOLPS '09: Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems
            July 2009
            73 pages
            ISBN:9781605585413
            DOI:10.1145/1565824

            Copyright © 2009 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 6 July 2009

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article

            Acceptance Rates

            Overall Acceptance Rate 6 of 8 submissions, 75%

          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!