Abstract
Generators offer an elegant way to express iterators. However, their performance has always been their Achilles heel and has prevented widespread adoption. We present techniques to efficiently implement and optimize generators.
We have implemented our optimizations in ZipPy, a modern, light-weight AST interpreter based Python 3 implementation targeting the Java virtual machine. Our implementation builds on a framework that optimizes AST interpreters using just-in-time compilation. In such a system, it is crucial that AST optimizations do not prevent subsequent optimizations. Our system was carefully designed to avoid this problem. We report an average speedup of 3.58x for generator-bound programs. As a result, using generators no longer has downsides and programmers are free to enjoy their upsides.
- Project Euler: Python Solutions. http://http://www.s-anand.net/euler.html/.Google Scholar
- Unladen Swallow. http://code.google.com/p/unladen-swallow/, August 2010.Google Scholar
- R. R. Atkinson, B. H. Liskov, and R. W. Scheifler. Aspects Of Implementing CLU. In Proceedings of the 1978 Annual Conference, ACM '78, pages 123--129, New York, NY, USA, 1978. ACM. ISBN 0-89791-000-1. doi: 10.1145/800127.804079. Google Scholar
Digital Library
- C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the Meta-level: PyPy's Tracing JIT Compiler. In Proceedings of the 4th Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, ICOOOLPS '09, pages 18--25, New York, NY, USA, 2009. ACM. ISBN 978-1-60558-541-3. doi: 10.1145/1565824.1565827. Google Scholar
Digital Library
- S. Brunthaler. Inline Caching Meets Quickening. In T. D'Hondt, editor, ECOOP 2010 - Object-Oriented Programming, volume 6183 of Lecture Notes in Computer Science, pages 429--451. Springer Berlin Heidelberg, 2010 ISBN 978-3-642-14106-5. doi: 10.1007/978-3-642-14107-2_21. Google Scholar
Digital Library
- S. Brunthaler. Efficient Interpretation Using Quickening. In Proceedings of the 6th Symposium on Dynamic Languages, DLS '10, pages 1--14, New York, NY, USA, 2010. ACM. ISBN 978-1-4503-0405-4. doi: 10.1145/1869631.1869633. Google Scholar
Digital Library
- L. P. Deutsch and A. M. Schiffman. Efficient implementation of the smalltalk-80 system. In Proceedings of the 11th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, POPL '84, pages 297--302, New York, NY, USA, 1984. ACM. ISBN 0-89791-125-3. doi: 10.1145/800017.800542. Google Scholar
Digital Library
- ECMA. Standard ECMA-262: ECMAScript Language Specification 6th Edition Draft. http://people.mozilla.org/~jorendorff/es6-draft.html, 2014.Google Scholar
- D. Eppstein. PADS, a library of Python Algorithms and Data Structures. http://www.ics.uci.edu/~eppstein/PADS/.Google Scholar
- B. Fulgham. The Computer Language Benchmarks Game. http://shootout.alioth.debian.org/.Google Scholar
- GitHub. http://github.com/.Google Scholar
- D. Grune. A View of Coroutines. SIGPLAN Not., 12 (7): 75--81, July 1977. ISSN 0362-1340. doi: 10.1145/954639.954644. Google Scholar
Digital Library
- Jython. http://www.jython.org/.Google Scholar
- B. Liskov, A. Snyder, R. Atkinson, and C. Schaffert. Abstraction Mechanisms in CLU. Communications of the ACM, 20 (8): 564--576, Aug. 1977. ISSN 0001-0782. doi: 10.1145/359763.359789. Google Scholar
Digital Library
- J. Liu, A. Kimball, and A. C. Myers. Interruptible Iterators. In Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '06, pages 283--294, New York, NY, USA, 2006. ACM. ISBN 1-59593-027-2. doi: 10.1145/1111037.1111063. Google Scholar
Digital Library
- A. L. D. Moura and R. Ierusalimschy. Revisiting Coroutines. ACM Transactions on Programming Languages and Systems, 31 (2): 6:1--6:31, Feb. 2009. ISSN 0164-0925. doi: 10.1145/1462166.1462167. Google Scholar
Digital Library
- S. Murer, S. Omohundro, D. Stoutamire, and C. Szyperski. Iteration Abstraction in Sather. ACM Transactions on Programming Languages and Systems, 18 (1): 1--15, Jan. 1996. ISSN 0164-0925. doi: 10.1145/225540.225541. Google Scholar
Digital Library
- PyPI Ranking. PyPI Python modules ranking. http://pypi-ranking.info/.Google Scholar
- PyPy. http://www.pypy.org/.Google Scholar
- Python. http://www.python.org/.Google Scholar
- A. Rigo and S. Pedroni. PyPy's Approach to Virtual Machine Construction. In Companion to the 21st ACM SIGPLAN Symposium on Object-oriented Programming Systems, Languages, and Applications, OOPSLA '06, pages 944--953, New York, NY, USA, 2006. ACM. ISBN 1-59593-491-X. doi: 10.1145/1176617.1176753. Google Scholar
Digital Library
- Ruby. http://www.ruby-lang.org/.Google Scholar
- L. Stadler, T. Würthinger, and C. Wimmer. Efficient Coroutines for the Java Platform. In Proceedings of the 8th International Conference on the Principles and Practice of Programming in Java, PPPJ '10, pages 20--28, New York, NY, USA, 2010. ACM. ISBN 978-1-4503-0269-2. doi: 10.1145/1852761.1852765. Google Scholar
Digital Library
- S. M. Watt. A Technique for Generic Iteration and Its Optimization. In Proceedings of the 2006 ACM SIGPLAN Workshop on Generic Programming, WGP '06, pages 76--86, New York, NY, USA, 2006. ACM. ISBN 1-59593-492-8. doi: 10.1145/1159861.1159872. Google Scholar
Digital Library
- T. Würthinger, A. Wöß, L. Stadler, G. Duboscq, D. Simon, and C. Wimmer. Self-optimizing AST Interpreters. In Proceedings of the 8th Symposium on Dynamic Languages, DLS '12, pages 73--82, New York, NY, USA, 2012. ACM. ISBN 978-1-4503-1564-7. doi: 10.1145/2384577.2384587. Google Scholar
Digital Library
- T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to Rule Them All. In Proceedings of the 2013 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software, Onward! '13, pages 187--204, New York, NY, USA, 2013. ACM. ISBN 978-1-4503-2472-4. doi: 10.1145/2509578.2509581. Google Scholar
Digital Library
Index Terms
Accelerating iterators in optimizing AST interpreters
Recommendations
Practical partial evaluation for high-performance dynamic language runtimes
PLDI 2017: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and ImplementationMost high-performance dynamic language virtual machines duplicate language semantics in the interpreter, compiler, and runtime system. This violates the principle to not repeat yourself. In contrast, we define languages solely by writing an ...
A domain-specific language for building self-optimizing AST interpreters
GPCE 2014: Proceedings of the 2014 International Conference on Generative Programming: Concepts and ExperiencesSelf-optimizing AST interpreters dynamically adapt to the provided input for faster execution. This adaptation includes initial tests of the input, changes to AST nodes, and insertion of guards that ensure assumptions still hold. Such specialization ...
Accelerating iterators in optimizing AST interpreters
OOPSLA '14: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & ApplicationsGenerators offer an elegant way to express iterators. However, their performance has always been their Achilles heel and has prevented widespread adoption. We present techniques to efficiently implement and optimize generators.
We have implemented our ...







Comments