skip to main content
research-article

Adding dynamically-typed language support to a statically-typed language compiler: performance evaluation, analysis, and tradeoffs

Published:03 March 2012Publication History
Skip Abstract Section

Abstract

Applications written in dynamically typed scripting languages are increasingly popular for Web software development. Even on the server side, programmers are using dynamically typed scripting languages such as Ruby and Python to build complex applications quickly. As the number and complexity of dynamically typed scripting language applications grows, optimizing their performance is becoming important. Some of the best performing compilers and optimizers for dynamically typed scripting languages are developed entirely from scratch and target a specific language. This approach is not scalable, given the variety of dynamically typed scripting languages, and the effort involved in developing and maintaining separate infrastructures for each. In this paper, we evaluate the feasibility of adapting and extending an existing production-quality method-based Just-In-Time (JIT) compiler for a language with dynamic types. Our goal is to identify the challenges and shortcomings with the current infrastructure, and to propose and evaluate runtime techniques and optimizations that can be incorporated into a common optimization infrastructure for static and dynamic languages. We discuss three extensions to the compiler to support dynamically typed languages: (1) simplification of control flow graphs, (2) mapping of memory locations to stack-allocated variables, and (3) reduction of runtime overhead using language semantics. We also propose four new optimizations for Python in (2) and (3). These extensions are effective in reduction of compiler working memory and improvement of runtime performance. We present a detailed performance evaluation of our approach for Python, finding an overall improvement of 1.69x on average (up to 2.74x) over our JIT compiler without any optimization for dynamically typed languages and Python.

References

  1. Agesen, O., Detlefs, D., and Moss, J. E. Garbage collection and local variable type-precision and liveness in Java virtual machines. In Proceedings of the ACM SIGPLAN 1998 conference on Programming language design and implementation, pp.269--279, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Ancona, D., Ancona, M., Cuni, A., and Matsakis, N. D. RPython: a step towards reconciling dynamically and statically typed OO languages. In Proceedings of the 2007 Symposium on Dynamic Languages, pp.53--64, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Arnold, M., Fink S. J., Grove, D., Hind, M., and Sweeney, P. F. A Survey of Adaptive Optimization in Virtual Machines. In Proceedings of the IEEE, 93(2), 2005.Google ScholarGoogle ScholarCross RefCross Ref
  4. Barrett, K., Cassels, B., Haahr, P., Moon, D. A., Playford, K., and Withington, P. T. A monotonic superclass linearization for Dylan. In Proceedings of the ACM international Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp.69--82, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Bebenita, M., Brandner, F., Fahndrich, M., Logozzo, F., Schulte, W., Tillmann, N., and Venter, H. SPUR: a trace-based JIT compiler for CIL. In Proceedings of the ACM international Conference on Object Oriented Programming Systems Languages and Applications, pp.708--725, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Bebenita, M., Brandner, F., Fahndrich, M., Logozzo, F., Schulte, W., Tillmann, N., and Venter, H. Mozilla Foundation, https://wiki.mozilla.org/JaegerMonkey/.Google ScholarGoogle Scholar
  7. Bolz, C., Cuni, A., Fijalkowski, M., and Rigo, A. Tracing the Meta-Level: PyPy's Tracing JIT Compiler. In Proceedings of the 4th work-shop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pp.18--25, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Bolz, C., Cuni, A., Fijalkowski, M., Leuschel, M., Rigo, A., and Pedroni, S. Runtime Feedback in a Meta-Tracing JIT for Efficient Dynamic Languages, In Proceedings of the 6th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Chambers, C. and Ungar, D. and Lee, E. An efficient implementation of SELF a dynamically-typed object-oriented language based on pro-totypes, In Proceedings of the ACM international Conference on Object Oriented Programming Systems Languages and Applications, pp.49--70, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Chambers, C. and Ungar, D. Customization: optimizing compiler technology for self, a dynamically-typed object-oriented programming language. In Proceedings of the ACM SIGPLAN Conference on Programming language design and implementation, pp.146--160, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Chambers, C., Ungar, D., and Lee. E. An efficient implementation of SELF a dynamically-typed object-oriented language based on proto-types. In the ACM international Conference proceedings on Object-oriented programming systems, languages and applications. pp.49--70, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Choi, J.-D., Grove, D., Hind, M., and Sarkar, V. Efficient and precise modeling of exceptions for the analysis of Java programs. In Proceedings of the 1999 ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering, pp.21--31, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Christopher, T. W. Reference count garbage collection. Software-Practice and Experience, 14(6), pp.503--507, 1984.Google ScholarGoogle ScholarCross RefCross Ref
  14. Deutsch, L. P. and Schiffman, A. M. Efficient implementation of the smalltalk-80 system. In Proceedings of the 11th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages., pp.297--302, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Gal, A., Eich, A., et al. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pp.465--478, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Gosling, J. Java intermediate bytecodes: ACM SIGPLAN workshop on intermediate representations, pp.111--118, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Holkner, A. and Harland, J. Evaluating the dynamic behaviour of Python applications. In Proceedings of the Thirty-Second Australasian Conference on Computer Science - Volume 91, pp.19--28, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. IronPython, http://ironpython.net/.Google ScholarGoogle Scholar
  19. Joisha, P. G. Compiler optimizations for nondeferred reference: counting garbage collection. In Proceedings of the 5th international symposium on Memory management. pp.150--161, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Kulkarni, P. A. JIT compilation policy for modern machines, In Proceedings of the ACM international conference on Object oriented programming systems languages and applications, pp.773--788, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Lattner, C. and Adve, V. LLVM: A Compilation Framework for Life-long Program Analysis & Transformation. In Proceedings of the inter-national Symposium on Code Generation and Optimization: Feedback-Directed and Runtime Optimization, pp.75--86, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. LuaJIT roadmap 2008, http://lua-users.org/lists/lua-l/2008-02/msg00051.html.Google ScholarGoogle Scholar
  23. Microsoft corporation. Dynamic Language Runtime, http://dlr.codeplex.com/Google ScholarGoogle Scholar
  24. Mostafa, N., Krintz, C., Cascaval, C., Edelsohn, D., Nagpurkar, P., Wu, P. Understanding the Potential of Interpreter-based Optimizations for Python, UCSB Technical Report 2010--14, 2010.Google ScholarGoogle Scholar
  25. Muchnick, S. S. Advanced Compiler Design and Implementation. Morgan Kaufmann Publishers Inc., 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. N. Grcevski, A. Kielstra, K. Stoodley, M. G. Stoodley, and V. Sundaresan. Java just-in-time compiler and virtual machine improvements for server and middleware applications. In Proceedings of the 3rd Virtual Machine Research and Technology Symposium, pp.151--162. 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Paleczny, M., Vick, C., and Click. C. The java hotspot server compiler. In Proceedings of the Symposium on Java Virtual Machine Re-search and Technology Symposium, pp.1--12, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Python Programming Language, http://www.python.org/Google ScholarGoogle Scholar
  29. Rossum, G. van. http://mail.python.org/pipermail/python-dev/2006-December/070323.html.Google ScholarGoogle Scholar
  30. Rubinius, http://rubini.us/Google ScholarGoogle Scholar
  31. Ruby on Rails, http://rubyonrails.org/Google ScholarGoogle Scholar
  32. Shi, Y., Gregg, D., Beatty, A., and Ertl, M. A. Virtual machine show-down: stack versus registers. In Proceedings of the 1st ACM/USENIX international Conference on Virtual Execution Environments, pp.153--163, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Shire, B. PHP and Facebook, http://blog.facebook.com/blog.php?post=2356432130Google ScholarGoogle Scholar
  34. Speeding up JSON encoding in PyPy, http://morepypy.blogspot.com/2011/10/speeding-up-json-encoding-in-pypy.html.Google ScholarGoogle Scholar
  35. Suganuma, T., Ogasawara, T., Takeuchi, M., Yasue, T., Kawahito, M., Ishizaki, K., Komatsu, H., and Nakatani, T. Overview of the IBM Java just-in-time compiler. IBM System Journal, 39(1), pp.175--193, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Tamarin on LLVM - More Numbers, http://www.masonchang.com/blog/2011/4/21/tamarin-on-llvm-more-numbers.htmlGoogle ScholarGoogle Scholar
  37. Tatsubori, M., Tozawa, A., Suzumura, T., Trent, S., and Onodera, T. Evaluation of a just-in-time compiler retrofitted for PHP. In Proceedings of the 6th ACM SIGPLAN/SIGOPS international Conference on Virtual Execution Environments, pp.121--132, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. The Da Vinci Machine Project, http://openjdk.java.net/projects/mlvm/.Google ScholarGoogle Scholar
  39. The Jython Project, http://www.jython.org/Project/.Google ScholarGoogle Scholar
  40. Unladen Swallow Benchmarks, http://code.google.com/p/unladen-swallow/wiki/Benchmarks/.Google ScholarGoogle Scholar
  41. Unladen Swallow, Change log, http://code.google.com/p/unladen-swallow/source/detail?r=1102.Google ScholarGoogle Scholar
  42. Unladen Swallow, Change log, http://code.google.com/p/unladen-swallow/source/detail?r=923.Google ScholarGoogle Scholar
  43. Unladen Swallow, Change log, http://code.google.com/p/unladen-swallow/source/detail?r=957.Google ScholarGoogle Scholar
  44. Unladen Swallow, http://code.google.com/p/unladen-swallow/.Google ScholarGoogle Scholar
  45. Unladen Swallow, Optimize IMPORT_NAME, http://codereview.appspot.com/217052Google ScholarGoogle Scholar
  46. Unladen Swallow, Optimize LOAD_GLOBAL, http://codereview.appspot.com/109043Google ScholarGoogle Scholar
  47. Using tracing to jump out of a loop causes the Python object stack to overflow, http://code.google.com/p/unladen-Swallow/issues/detail?id=91Google ScholarGoogle Scholar
  48. V8 JavaScript Engine. http://code.google.com/p/v8/.Google ScholarGoogle Scholar
  49. Yermolovich, A., Wimmer, C., and Franz, M. Optimization of dynamic languages using hierarchical layering of virtual machines, In Proceedings of the 5th symposium on Dynamic languages, pp. 79-88, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Adding dynamically-typed language support to a statically-typed language compiler: performance evaluation, analysis, and tradeoffs

    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 47, Issue 7
      VEE '12
      July 2012
      229 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2365864
      Issue’s Table of Contents
      • cover image ACM Conferences
        VEE '12: Proceedings of the 8th ACM SIGPLAN/SIGOPS conference on Virtual Execution Environments
        March 2012
        248 pages
        ISBN:9781450311762
        DOI:10.1145/2151024

      Copyright © 2012 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 3 March 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!