Nothing Special   »   [go: up one dir, main page]

skip to main content
research-article
Open access

Contextual dispatch for function specialization

Published: 13 November 2020 Publication History

Abstract

In order to generate efficient code, dynamic language compilers often need information, such as dynamic types, not readily available in the program source. Leveraging a mixture of static and dynamic information, these compilers speculate on the missing information. Within one compilation unit, they specialize the generated code to the previously observed behaviors, betting that past is prologue. When speculation fails, the execution must jump back to unoptimized code. In this paper, we propose an approach to further the specialization, by disentangling classes of behaviors into separate optimization units. With contextual dispatch, functions are versioned and each version is compiled under different assumptions. When a function is invoked, the implementation dispatches to a version optimized under assumptions matching the dynamic context of the call. As a proof-of-concept, we describe a compiler for the R language which uses this approach. Our implementation is, on average, 1.7× faster than the GNU R reference implementation. We evaluate contextual dispatch on a set of benchmarks and measure additional speedup, on top of traditional speculation with deoptimization techniques. In this setting contextual dispatch improves the performance of 18 out of 46 programs in our benchmark suite.

Supplementary Material

Auxiliary Archive (oopsla20main-p502-p-archive.zip)
Appendix
Auxiliary Presentation Video (oopsla20main-p502-p-video.mp4)
In order to generate efficient code, dynamic language compilers often need information, such as dynamic types, not readily available in the program source. Within one compilation unit, they specialize the generated code to the previously observed behaviors, betting that past is prologue. In this paper, we propose an approach to further the specialization, by disentangling classes of behaviors into separate optimization units. With contextual dispatch, functions are versioned and each version is compiled under different assumptions. When a function is invoked, the implementation dispatches to a version optimized under assumptions matching the dynamic context of the call. As a proof-of-concept, we describe a compiler for the R language which uses this approach. Our implementation is, on average, 1.7× faster than the GNU R reference implementation. We evaluate contextual dispatch on a set of benchmarks and measure additional speedup, on top of traditional speculation techniques.

References

[1]
Arif Ali Ap and Erven Rohou. 2017. Dynamic Function Specialization. In International Conference on Embedded Computer Systems: Architectures, MOdeling and Simulation. https://doi.org/10.1109/SAMOS. 2017.8344624
[2]
Edd Barrett, Carl Friedrich Bolz-Tereick, Rebecca Killick, Sarah Mount, and Laurence Tratt. 2017. Virtual Machine Warmup Blows Hot and Cold. In Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/3133876
[3]
Jef Bezanson, Jiahao Chen, Ben Chung, Stefan Karpinski, Viral B. Shah, Jan Vitek, and Lionel Zoubritzky. 2018. Julia: Dynamism and Performance Reconciled by Design. Proc. ACM Program. Lang. 2, OOPSLA ( 2018 ). https://doi.org/10. 1145/3276490
[4]
Robert Cartwright and Guy L Steele Jr. 1998. Compatible genericity with run-time types for the Java programming language. Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/ 286942.286958
[5]
Craig Chambers and David Ungar. 1989. Customization: Optimizing Compiler Technology for SELF, a Dynamicallytyped Object-oriented Programming Language. In Programming Language Design and Implementation (PLDI). https: //doi.org/10.1145/73141.74831
[6]
Maxime Chevalier-Boisvert and Marc Feeley. 2015. Simple and Efective Type Check Removal through Lazy Basic Block Versioning. In European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.4230/LIPIcs.ECOOP. 2015.101
[7]
Keith D Cooper, Mary W Hall, and Ken Kennedy. 1993. A methodology for procedure cloning. Computer Languages 19 ( 1993 ). https://doi.org/10.1016/ 0096-0551 ( 93 ) 90005-L
[8]
Igor Costa, Pericles Alves, Henrique Nazaré Santos, and Fernando Magno Quintao Pereira. 2013. Just-in-time value specialization. In Symposium on Code Generation and Optimization (CGO). https://doi.org/10.1109/CGO. 2013.6495006
[9]
Jefrey Dean, Craig Chambers, and David Grove. 1995. Selective Specialization for Object-Oriented Languages. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/223428.207119
[10]
Iulian Dragos and Martin Odersky. 2009. Compiling generics through user-directed type specialization. In Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems (ICOOOLPS). https://doi.org/10.1145/1565824.1565830
[11]
Olivier Flückiger, Guido Chari, Jan Jecmen, Ming-Ho Yee, Jakob Hain, and Jan Vitek. 2019. R melts brains: an IR for ifrst-class environments and lazy efectful arguments. In International Symposium on Dynamic Languages (DLS). https: //doi.org/10.1145/3359619.3359744
[12]
Olivier Flückiger, Guido Chari, Ming-Ho Yee, Jan Jecmen, Jakob Hain, and Jan Vitek. 2020. Artifact for “Contextual Dispatch for Function Specialization”. https://doi.org/10.5281/zenodo.3973073
[13]
Olivier Flückiger, Gabriel Scherer, Ming-Ho Yee, Aviral Goel, Amal Ahmed, and Jan Vitek. 2018. Correctness of speculative optimizations with dynamic deoptimization. Proc. ACM Program. Lang. 2, POPL ( 2018 ). https://doi.org/10.1145/3158137
[14]
Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R. Haghighat, Blake Kaplan, Graydon Hoare, Boris Zbarsky, Jason Orendorf, Jesse Ruderman, Edwin W. Smith, Rick Reitmaier, Michael Bebenita, Mason Chang, and Michael Franz. 2009. Trace-based Just-in-time Type Specialization for Dynamic Languages. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/1542476.1542528
[15]
Isaac Gouy. 2020. Computer Language Benchmarks Game. https://benchmarksgame-team.pages. debian.net/ benchmarksgame/
[16]
Brian Hackett and Shu-yu Guo. 2012. Fast and Precise Hybrid Type Inference for JavaScript. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/2254064.2254094
[17]
Mary Wolcott Hall. 1991. Managing interprocedural optimization. Ph.D. Dissertation. https://hdl.handle.net/ 1911 /16446
[18]
Urs Hölzle, Craig Chambers, and David Ungar. 1991. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.1007/ BFb0057013
[19]
Urs Hölzle, Craig Chambers, and David Ungar. 1992. Debugging Optimized Code with Dynamic Deoptimization. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/143095.143114
[20]
Antony L Hosking, J Eliot, and B Moss. 1990. Towards compile-time optimisations for persistence. In International Workshop on Persistent Object Systems.
[21]
Toms Kalibera, Petr Maj, Floreal Morandat, and Jan Vitek. 2014. A Fast Abstract Syntax Tree Interpreter for R. In Conference on Virtual Execution Environments (VEE). https://doi.org/10.1145/2576195.2576205
[22]
Andrew Kennedy and Don Syme. 2001. Design and implementation of generics for the.NET Common language runtime. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/378795.378797
[23]
Chris Lattner and Vikram Adve. 2004. LLVM: A Compilation Framework for Lifelong Program Analysis and Transformation. In Symposium on Code Generation and Optimization (CGO). https://doi.org/10.1109/CGO. 2004.1281665
[24]
Friedrich Leisch. 2006. A Toolbox for K-Centroids Cluster Analysis. Computational Statistics and Data Analysis 51, 2 ( 2006 ).
[25]
Lun Liu, Todd Millstein, and Madanlal Musuvathi. 2019. Accelerating Sequential Consistency for Java with Speculative Compilation. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/3314221.3314611
[26]
Stefan Marr. 2018. ReBench: Execute and Document Benchmarks Reproducibly. https://doi.org/10.5281/zenodo. 1311762 Version 1.0.
[27]
Stefan Marr, Benoit Daloze, and Hanspeter Mössenböck. 2016. Cross-language Compiler Benchmarking: Are We Fast Yet?. In Symposium on Dynamic Languages (DLS). https://doi.org/10.1145/2989225.2989232
[28]
Floréal Morandat, Brandon Hill, Leo Osvald, and Jan Vitek. 2012. Evaluating the Design of the R Language: Objects and Functions for Data Analysis. In European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.1007/ 978-3-642-31057-7_6
[29]
Michael Paleczny, Christopher Vick, and Clif Click. 2001. The Java Hotspot Server Compiler. In Symposium on Java Virtual Machine Research and Technology (JVM).
[30]
John Plevyak and Andrew A Chien. 1995. Type directed cloning for object-oriented programs. In International Workshop on Languages and Compilers for Parallel Computing. https://doi.org/10.1007/BFb0014224
[31]
Gabriel Poesia and Fernando Magno Quint ao Pereira. 2020. Dynamic Dispatch of Context-Sensitive Optimizations. In Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/ 3428235
[32]
R Core Team. 2019. R: A Language and Environment for Statistical Computing. https://www.R-project.org
[33]
Robert W. Scheifler. 1977. An Analysis of Inline Substitution for a Structured Programming Language. Commun. ACM 20, 9 ( 1977 ). https://doi.org/10.1145/359810.359830
[34]
Lukas Stadler, Adam Welc, Christian Humer, and Mick Jordan. 2016. Optimizing R Language Execution via Aggressive Speculation. In Symposium on Dynamic Languages (DLS). https://doi.org/10.1145/2989225.2989236
[35]
Justin Talbot, Zachary DeVito, and Pat Hanrahan. 2012. Riposte: A Trace-driven Compiler and Parallel VM for Vector Code in R. In Conference on Parallel Architectures and Compilation Techniques (PACT). https://doi.org/10.1145/2370816.2370825
[36]
Luke Tierney. 2019. A Byte Code Compiler for R. www.stat.uiowa.edu/~luke/R/compiler/compiler.pdf
[37]
John Whaley. 1999. Dynamic optimization through the use of automatic runtime specialization. Ph.D. Dissertation. Stanford.

Cited By

View all
  • (2024)Reducing Feedback PollutionProceedings of the 16th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages10.1145/3689490.3690404(65-74)Online publication date: 17-Oct-2024
  • (2023)Debugging Dynamic Language Features in a Multi-tier Virtual MachineProceedings of the 15th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages10.1145/3623507.3623549(18-28)Online publication date: 18-Oct-2023
  • (2023)Reusing Just-in-Time Compiled CodeProceedings of the ACM on Programming Languages10.1145/36228397:OOPSLA2(1176-1197)Online publication date: 16-Oct-2023
  • Show More Cited By

Index Terms

  1. Contextual dispatch for function specialization

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 4, Issue OOPSLA
    November 2020
    3108 pages
    EISSN:2475-1421
    DOI:10.1145/3436718
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 13 November 2020
    Published in PACMPL Volume 4, Issue OOPSLA

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. customization
    2. specialization
    3. speculation
    4. splitting
    5. virtual machine

    Qualifiers

    • Research-article

    Funding Sources

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)195
    • Downloads (Last 6 weeks)16
    Reflects downloads up to 19 Nov 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Reducing Feedback PollutionProceedings of the 16th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages10.1145/3689490.3690404(65-74)Online publication date: 17-Oct-2024
    • (2023)Debugging Dynamic Language Features in a Multi-tier Virtual MachineProceedings of the 15th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages10.1145/3623507.3623549(18-28)Online publication date: 18-Oct-2023
    • (2023)Reusing Just-in-Time Compiled CodeProceedings of the ACM on Programming Languages10.1145/36228397:OOPSLA2(1176-1197)Online publication date: 16-Oct-2023
    • (2022)Who You Gonna Call: Analyzing the Run-Time Call-Site Behavior of Ruby ApplicationsProceedings of the 18th ACM SIGPLAN International Symposium on Dynamic Languages10.1145/3563834.3567538(15-28)Online publication date: 29-Nov-2022
    • (2022)Deoptless: speculation with dispatched on-stack replacement and specialized continuationsProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523729(749-761)Online publication date: 9-Jun-2022
    • (2021)Type stability in Julia: avoiding performance pathologies in JIT compilationProceedings of the ACM on Programming Languages10.1145/34855275:OOPSLA(1-26)Online publication date: 15-Oct-2021
    • (2021)Promises are made to be broken: migrating R to strict semanticsProceedings of the ACM on Programming Languages10.1145/34854785:OOPSLA(1-20)Online publication date: 15-Oct-2021
    • (2020)Dynamic dispatch of context-sensitive optimizationsProceedings of the ACM on Programming Languages10.1145/34282354:OOPSLA(1-28)Online publication date: 13-Nov-2020

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media