skip to main content
10.1145/1565824.1565827acmotherconferencesArticle/Chapter ViewAbstractPublication PagesisstaConference Proceedingsconference-collections
research-article

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

Published: 06 July 2009 Publication 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.
[2]
V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: a transparent dynamic optimization system. ACM SIGPLAN Notices, 35(5):1--12, 2000.
[3]
C. F. Bolz. Automatic JIT Compiler Generation with Runtime Partial Evaluation. Master thesis, Heinrich-Heine-Universität Düsseldorf, 2008.
[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.
[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.
[6]
C. Bruni and T. Verwaest. PyGirl: generating Whole-System VMs from High-Level prototypes using PyPy. In Tools, accepted for publication, 2009.
[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.
[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.
[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.
[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.
[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.
[12]
A. Cuni, D. Ancona, and A. Rigo. Faster than C#: Efficient implementation of dynamic languages on .NET. Accepted at ICOOOLPS'09.
[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.
[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.
[15]
Y. Futamura. Partial evaluation of computation process - an approach to a Compiler-Compiler. Higher-Order and Symbolic Computation, 12(4):381--391, 1999.
[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.
[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.
[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.
[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.
[20]
U. Hölzle. Adaptive optimization for SELF: reconciling high performance with exploratory programming. Technical report, Stanford University, 1994.
[21]
N. D. Jones, C. K. Gomard, and P. Sestoft. Partial evaluation and Automatic Program Generation. Prentice-Hall, Inc., 1993.
[22]
I. Piumarta and F. Riccardi. Optimizing direct threaded code by selective inlining. SIGPLAN Not., 33(5):291--300, 1998.
[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.
[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.
[25]
A. Rigo and S. Pedroni. JIT compiler architecture. Technical Report D08.2, PyPy, May 2007.
[26]
G. T. Sullivan. Dynamic partial evaluation. In Proceedings of the Second Symposium on Programs as Data Objects, pages 238--256. Springer-Verlag, 2001.
[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.

Cited By

View all
  • (2024)MAGPYProceedings of the 2024 USENIX Conference on Usenix Annual Technical Conference10.5555/3691992.3692034(683-698)Online publication date: 10-Jul-2024
  • (2024)ALAAMEE: Open-source software for fitting autologistic actor attribute modelsPLOS Complex Systems10.1371/journal.pcsy.00000211:4(e0000021)Online publication date: 5-Dec-2024
  • (2024)Automatically Generating an Abstract Interpretation-Based Optimizer from a DSLCompanion Proceedings of the 2024 ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity10.1145/3689491.3689968(28-30)Online publication date: 20-Oct-2024
  • Show More Cited By

Recommendations

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

Information & Contributors

Information

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
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]

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 06 July 2009

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Research-article

Conference

ECOOP '09

Acceptance Rates

Overall Acceptance Rate 11 of 14 submissions, 79%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)112
  • Downloads (Last 6 weeks)19
Reflects downloads up to 20 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)MAGPYProceedings of the 2024 USENIX Conference on Usenix Annual Technical Conference10.5555/3691992.3692034(683-698)Online publication date: 10-Jul-2024
  • (2024)ALAAMEE: Open-source software for fitting autologistic actor attribute modelsPLOS Complex Systems10.1371/journal.pcsy.00000211:4(e0000021)Online publication date: 5-Dec-2024
  • (2024)Automatically Generating an Abstract Interpretation-Based Optimizer from a DSLCompanion Proceedings of the 2024 ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity10.1145/3689491.3689968(28-30)Online publication date: 20-Oct-2024
  • (2024)Accelerate RISC-V Instruction Set Simulation by Tiered JIT CompilationProceedings of the 16th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages10.1145/3689490.3690399(12-22)Online publication date: 17-Oct-2024
  • (2024)Query Compilation Without RegretsProceedings of the ACM on Management of Data10.1145/36549682:3(1-28)Online publication date: 30-May-2024
  • (2024)Dr Wenowdis: Specializing Dynamic Language C Extensions using Type InformationProceedings of the 13th ACM SIGPLAN International Workshop on the State Of the Art in Program Analysis10.1145/3652588.3663316(1-8)Online publication date: 20-Jun-2024
  • (2024)Type-Based Gradual Typing Performance OptimizationProceedings of the ACM on Programming Languages10.1145/36329318:POPL(2667-2699)Online publication date: 5-Jan-2024
  • (2023)Pyccel: a Python-to-X transpiler for scientific high-performance computingJournal of Open Source Software10.21105/joss.049918:83(4991)Online publication date: Mar-2023
  • (2023)Hybrid Execution: Combining Ahead-of-Time and Just-in-Time CompilationProceedings of the 15th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages10.1145/3623507.3623554(39-49)Online publication date: 18-Oct-2023
  • (2023)An Executable Semantics for Faster Development of Optimizing Python CompilersProceedings of the 16th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3623476.3623529(15-28)Online publication date: 23-Oct-2023
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media