Dr Wenowdis: Specializing dynamic language C extensions using type information

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Bernstein, Maxwell, Bolz-Tereick, CF
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866929334515662848
author Bernstein, Maxwell
Bolz-Tereick, CF
author_facet Bernstein, Maxwell
Bolz-Tereick, CF
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2403_02420
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Dr Wenowdis: Specializing dynamic language C extensions using type information
Bernstein, Maxwell
Bolz-Tereick, CF
Programming Languages
D.3.4
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.
title Dr Wenowdis: Specializing dynamic language C extensions using type information
topic Programming Languages
D.3.4
url https://arxiv.org/abs/2403.02420