skip to main content
10.1145/2384577.2384586acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Loop-aware optimizations in PyPy's tracing JIT

Published: 22 October 2012 Publication History

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.
[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.
[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.
[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.
[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.
[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.
[7]
C. F. Bolz, M. Leuschel, and D. Schneider. Towards a jitting VM for Prolog execution. In PPDP, Hagenberg, Austria, 2010. ACM.
[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.
[9]
F. C.-T. Chow. A portable machine-independent global optimizer--design and measurements. PhD thesis, Stanford University, Stanford, CA, USA, 1984. AAI8408268.
[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.
[11]
A. Diwan, K. S. McKinley, and J. E. B. Moss. Type-based alias analysis. SIGPLAN Not., 33(5):106--117, May 1998.
[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.
[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.
[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.
[15]
J. Knoop, O. Rüthing, and B. Steffen. Lazy code motion. SIGPLAN Not., 27(7):224--234, July 1992.
[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.
[17]
E. Morel and C. Renvoise. Global optimization by suppression of partial redundancies. Commun. ACM, 22(2):96--103, Feb. 1979.
[18]
S. S. Muchnick and Muchnick. Advanced Compiler Design and Implementation. Morgan Kaufmann, Sept. 1997.
[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.
[20]
A. Rigo and S. Pedroni. PyPy's approach to virtual machine construction. In DLS, Portland, Oregon, USA, 2006. ACM.

Cited By

View all
  • (2024)Pronghorn: Effective Checkpoint Orchestration for Serverless Hot-StartsProceedings of the Nineteenth European Conference on Computer Systems10.1145/3627703.3629556(298-316)Online publication date: 22-Apr-2024
  • (2020)Intrepydd: performance, productivity, and portability for data science application kernelsProceedings of the 2020 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3426428.3426915(65-83)Online publication date: 18-Nov-2020
  • (2017)Sound gradual typing: only mostly deadProceedings of the ACM on Programming Languages10.1145/31338781:OOPSLA(1-24)Online publication date: 12-Oct-2017
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
DLS '12: Proceedings of the 8th symposium on Dynamic languages
October 2012
128 pages
ISBN:9781450315647
DOI:10.1145/2384577
  • 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
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 22 October 2012

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. loop-invariant code motion
  2. optimization
  3. tracing JIT

Qualifiers

  • Research-article

Conference

SPLASH '12
Sponsor:

Acceptance Rates

Overall Acceptance Rate 32 of 77 submissions, 42%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)11
  • Downloads (Last 6 weeks)0
Reflects downloads up to 24 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Pronghorn: Effective Checkpoint Orchestration for Serverless Hot-StartsProceedings of the Nineteenth European Conference on Computer Systems10.1145/3627703.3629556(298-316)Online publication date: 22-Apr-2024
  • (2020)Intrepydd: performance, productivity, and portability for data science application kernelsProceedings of the 2020 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3426428.3426915(65-83)Online publication date: 18-Nov-2020
  • (2017)Sound gradual typing: only mostly deadProceedings of the ACM on Programming Languages10.1145/31338781:OOPSLA(1-24)Online publication date: 12-Oct-2017
  • (2014)Just-in-time Length Specialization of Dynamic Vector CodeProceedings of ACM SIGPLAN International Workshop on Libraries, Languages, and Compilers for Array Programming10.1145/2627373.2627377(20-25)Online publication date: 9-Jun-2014
  • (2022)Automatic Parallelization of Python Programs for Distributed Heterogeneous ComputingEuro-Par 2022: Parallel Processing10.1007/978-3-031-12597-3_22(350-366)Online publication date: 22-Aug-2022

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media