Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
175 tokens/sec
GPT-4o
7 tokens/sec
Gemini 2.5 Pro Pro
42 tokens/sec
o3 Pro
4 tokens/sec
GPT-4.1 Pro
38 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Dr Wenowdis: Specializing dynamic language C extensions using type information (2403.02420v1)

Published 4 Mar 2024 in cs.PL

Abstract: C-based interpreters such as CPython make extensive use of C "extension" code, which is opaque to static analysis tools and faster runtimes with JIT compilers, such as PyPy. Not only are the extensions opaque, but the interface between the dynamic language types and the C types can introduce impedance. We hypothesise that frequent calls to C extension code introduce significant overhead that is often unnecessary. We validate this hypothesis by introducing a simple technique, "typed methods", which allow selected C extension functions to have additional metadata attached to them in a backward-compatible way. This additional metadata makes it much easier for a JIT compiler (and as we show, even an interpreter!) to significantly reduce the call and return overhead. Although we have prototyped typed methods in PyPy, we suspect that the same technique is applicable to a wider variety of language runtimes and that the information can also be consumed by static analysis tooling.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (35)
  1. [n. d.]. HPy - A better C API for Python. https://hpyproject.org/
  2. RPython: a step towards reconciling dynamically and statically typed OO languages. In DLS. ACM, Montreal, Quebec, Canada. https://doi.org/10.1145/1297081.1297091
  3. Gergö Barany. 2014. Python interpreter performance deconstructed. In Proceedings of the Workshop on Dynamic Languages and Applications. 1–9. https://dl.acm.org/doi/10.1145/2617548.2617552
  4. Cython: The best of both worlds. Computing in Science & Engineering 13, 2 (2010), 31–39.
  5. Allocation removal by partial evaluation in a tracing JIT. In PEPM. Austin, Texas, USA.
  6. Tracing the meta-level: PyPy’s tracing JIT compiler. In ICOOOLPS. ACM, Genova, Italy, 18–25. https://doi.org/10.1145/1565824.1565827
  7. Carl Friedrich Bolz and Laurence Tratt. 2015. The impact of meta-tracing on VM design and implementation. Science of Computer Programming 98 (Feb. 2015), 408–421. https://doi.org/10.1016/j.scico.2013.02.001
  8. Stefan Brunthaler. 2010a. Efficient inline caching without dynamic translation. In Proceedings of the 2010 ACM Symposium on Applied Computing (SAC), Sierre, Switzerland, March 22-26, 2010, Sung Y. Shin, Sascha Ossowski, Michael Schumacher, Mathew J. Palakal, and Chih-Cheng Hung (Eds.). ACM, 2155–2156. https://doi.org/10.1145/1774088.1774542
  9. Stefan Brunthaler. 2010b. Efficient interpretation using quickening. In Proceedings of the 6th Symposium on Dynamic Languages, DLS 2010, October 18, 2010, Reno, Nevada, USA, William D. Clinger (Ed.). ACM, 1–14. https://doi.org/10.1145/1869631.1869633
  10. Stefan Brunthaler. 2010c. Inline Caching Meets Quickening. In ECOOP 2010 - Object-Oriented Programming, 24th European Conference, Maribor, Slovenia, June 21-25, 2010. Proceedings (Lecture Notes in Computer Science, Vol. 6183), Theo D’Hondt (Ed.). Springer, 429–451. https://doi.org/10.1007/978-3-642-14107-2_21
  11. Stefan Brunthaler. 2021. Multi-Level Quickening: Ten Years Later. CoRR abs/2109.02958 (2021). arXiv:2109.02958 https://arxiv.org/abs/2109.02958
  12. Brandt Bucher. 2023. https://github.com/python/cpython/pull/113465.
  13. An efficient implementation of SELF a dynamically-typed object-oriented language based on prototypes. In OOPSLA, Vol. 24. https://doi.org/10.1145/74878.74884
  14. Evaluating YJIT’s Performance in a Production Context: A Pragmatic Approach. In Proceedings of the 20th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes (Cascais, Portugal) (MPLR 2023). Association for Computing Machinery, New York, NY, USA, 20–33. https://doi.org/10.1145/3617651.3622982
  15. Antonio Cuni. 2018. Inside cpyext: Why emulating CPython C API is so Hard. https://www.pypy.org/posts/2018/09/inside-cpyext-why-emulating-cpython-c-8083064623681286567.html
  16. MicroPython Developers. 2024a. smallint.h. https://github.com/micropython/micropython/blob/master/py/smallint.h.
  17. PyO3 Developers. 2024b. The PyO3 user guide. https://pyo3.rs/v0.20.2/.
  18. Skybison Developers. 2024c. objects.h. https://github.com/tekknolagi/skybison/blob/trunk/runtime/objects.h.
  19. Jake Edge. 2021. Making CPython faster. https://lwn.net/Articles/857754/
  20. Larry Hastings. 2024. Argument Clinic How-To. https://docs.python.org/3.10/howto/clinic.html.
  21. Static Type Inference for Foreign Functions of Python. In 32nd International Symposium on Software Reliability Engineering (ISSRE 2021). IEEE, 423–433.
  22. Greg Kroah-Hartman. 2005. container_of(). http://www.kroah.com/log/linux/container_of.html
  23. Chris Lattner and Vikram Adve. 2004. LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. In Proceedings of the 2004 International Symposium on Code Generation and Optimization (CGO’04). Palo Alto, California.
  24. Jukka Lehtosalo. [n. d.]. mypy - About. https://mypy-lang.org/about.html.
  25. Siliang Li and Gang Tan. 2011. JET: exception checking in the Java native interface. In Proceedings of the 2011 ACM International Conference on Object Oriented Programming Systems Languages and Applications (Portland, Oregon, USA) (OOPSLA ’11). Association for Computing Machinery, New York, NY, USA, 345–358. https://doi.org/10.1145/2048066.2048095
  26. Siliang Li and Gang Tan. 2014. Exception analysis in the Java Native Interface. Science of Computer Programming 89 (2014), 273–297. https://doi.org/10.1016/j.scico.2014.01.018
  27. Gradual Soundness: Lessons from Static Python. The Art, Science, and Engineering of Programming 7, 1 (June 2022), 2:1–2:40. https://doi.org/10.22152/programming-journal.org/2023/7/2
  28. Kate McKinnon and Colin Jost. [n. d.]. Weekend Update: Dr. Wenowdis on Trump’s Televised Health Exam - SNL. Saturday Night Live. https://www.youtube.com/watch?v=2kQxVwYwrME
  29. Raphaël Monat. 2021. Static type and value analysis by abstract interpretation of Python programs with native C libraries. PhD thesis. Sorbonne Université. https://theses.hal.science/tel-03533030/document
  30. A Multilanguage Static Analysis of Python Programs with Native C Extensions. In Static Analysis: 28th International Symposium, SAS 2021, Chicago, IL, USA, October 17–19, 2021, Proceedings (Chicago, IL, USA). Springer-Verlag, Berlin, Heidelberg, 323–345. https://doi.org/10.1007/978-3-030-88806-0_16
  31. Russell Power and Alex Rubinsteyn. 2013. How fast can we make interpreted Python? CoRR abs/1306.6047 (2013). arXiv:1306.6047 http://arxiv.org/abs/1306.6047
  32. Bringing low-level languages to the JVM: efficient execution of LLVM IR on Truffle. In Proceedings of the 8th International Workshop on Virtual Machines and Intermediate Languages (VMIL 2016). Association for Computing Machinery, New York, NY, USA, 6–15. https://doi.org/10.1145/2998415.2998416
  33. Improving performance of JNA by using LLVM JIT compiler. In 2013 IEEE/ACIS 12th International Conference on Computer and Information Science (ICIS). 483–488. https://doi.org/10.1109/ICIS.2013.6607886
  34. 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! 2013). Association for Computing Machinery, New York, NY, USA, 187–204. https://doi.org/10.1145/2509578.2509581
  35. Haoran Xu and Fredrik Kjolstad. 2021. Copy-and-patch compilation: a fast compilation algorithm for high-level languages and bytecode. Proceedings of the ACM on Programming Languages 5, OOPSLA (Oct. 2021), 1–30. https://doi.org/10.1145/3485513
Citations (1)

Summary

We haven't generated a summary for this paper yet.