skip to main content
research-article

Loop-aware optimizations in PyPy's tracing JIT

Published:22 October 2012Publication History
Skip Abstract Section

Abstract

One of the nice properties of a tracing just-in-time compiler (JIT) is that many of its optimizations are simple, requiring one forward pass only. This is not true for loop-invariant code motion which is a very important optimization for code with tight kernels. Especially for dynamic languages that typically perform quite a lot of loop invariant type checking, boxed value unwrapping and virtual method lookups. In this paper we explain a scheme pioneered within the context of the LuaJIT project for making basic optimizations loop-aware by using a simple pre-processing step on the trace without changing the optimizations themselves.

We have implemented the scheme in RPython's tracing JIT compiler. PyPy's Python JIT executing simple numerical kernels can become up to two times faster, bringing the performance into the ballpark of static language compilers.

References

  1. F. Allen and J. Cocke. A catalogue of optimizing transformations. In R. Rustin, editor, Design and Optimization of Compilers, pages 1--30. Prentice-Hall, 1971.Google ScholarGoogle Scholar
  2. D. Ancona, M. Ancona, A. Cuni, and N. D. Matsakis. RPython: a step towards reconciling dynamically and statically typed OO languages. In DLS, Montreal, Quebec, Canada, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. Bebenita, F. Brandner, M. Fahndrich, F. Logozzo, W. Schulte, N. Tillmann, and H. Venter. SPUR: a trace-based JIT compiler for CIL. In OOPSLA, Reno/Tahoe, Nevada, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. C. F. Bolz, A. Cuni, M. FijaBkowski, M. Leuschel, S. Pedroni, and A. Rigo. Allocation removal by partial evaluation in a tracing JIT. In PEPM, Austin, Texas, USA, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. C. F. Bolz, A. Cuni, M. FijaBkowski, M. Leuschel, A. Rigo, and S. Pedroni. Runtime feedback in a meta-tracing JIT for efficient dynamic languages. In ICOOOLPS, Lancaster, UK, 2011. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. C. F. Bolz, A. Cuni, M. FijaBkowski, and A. Rigo. Tracing the meta-level: PyPy's tracing JIT compiler. In ICOOOLPS, pages 18--25, Genova, Italy, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. F. Bolz, M. Leuschel, and D. Schneider. Towards a jitting VM for Prolog execution. In PPDP, Hagenberg, Austria, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. F. Chow, S. Chan, R. Kennedy, S.-M. Liu, R. Lo, and P. Tu. A new algorithm for partial redundancy elimination based on SSA form. In Proceedings of the ACM SIGPLAN 1997 conference on Programming language design and implementation, PLDI '97, page 273--286, New York, NY, USA, 1997. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. F. C.-T. Chow. A portable machine-independent global optimizer--design and measurements. PhD thesis, Stanford University, Stanford, CA, USA, 1984. AAI8408268. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. D. M. Dhamdhere. Practical adaption of the global optimization algorithm of Morel and Renvoise. ACM Trans. Program. Lang. Syst., 13(2):291--294, Apr. 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. A. Diwan, K. S. McKinley, and J. E. B. Moss. Type-based alias analysis. SIGPLAN Not., 33(5):106--117, May 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 just-in-time type specialization for dynamic languages. In PLDI, PLDI '09, New York, New York, 2009. ACM. ACM ID: 1542528. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. A. Gal and M. Franz. Incremental dynamic code generation with trace trees. Technical Report ICS-TR-06--16, Donald Bren School of Information and Computer Science, University of California, Irvine, Nov. 2006.Google ScholarGoogle Scholar
  14. A. Gal, C. W. Probst, and M. Franz. HotpathVM: an effective JIT compiler for resource-constrained devices. In VEE, Ottawa, Ontario, Canada, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Knoop, O. Rüthing, and B. Steffen. Lazy code motion. SIGPLAN Not., 27(7):224--234, July 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. T. Kotzmann and H. Mössenböck. Escape analysis in the context of dynamic compilation and deoptimization. In Proceedings of the 1st ACM/USENIX international conference on Virtual execution environments, VEE '05, page 111--120, New York, NY, USA, 2005. ACM. ACM ID: 1064996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. E. Morel and C. Renvoise. Global optimization by suppression of partial redundancies. Commun. ACM, 22(2):96--103, Feb. 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. S. S. Muchnick and Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmann, Sept. 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. M. Pall. LuaJIT 2.0 intellectual property disclosure and research opportunities, Nov. 2009.texttthttp://lua-users.org/lists/lua-l/2009--11/ msg00089.html.Google ScholarGoogle Scholar
  20. A. Rigo and S. Pedroni. PyPy's approach to virtual machine construction. In DLS, Portland, Oregon, USA, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Loop-aware optimizations in PyPy's tracing JIT

          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 48, Issue 2
            DLS '12
            February 2013
            114 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/2480360
            Issue’s Table of Contents
            • cover image ACM Conferences
              DLS '12: Proceedings of the 8th symposium on Dynamic languages
              October 2012
              128 pages
              ISBN:9781450315647
              DOI:10.1145/2384577

            Copyright © 2012 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 22 October 2012

            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!