APrioriInvestments / typed_python

An llvm-based framework for generating and calling into high-performance native code from Python.
Apache License 2.0
197 stars 8 forks source link

Prune the graph of inflight functions to not include the ones we don't need #438

Open wllgrnt opened 1 year ago

wllgrnt commented 1 year ago

(by @braxtonmckee)

Motivation and Context

When we first call a python function 'f' with a specific set of arguments, we may not know its return type the first time we try to convert it. To ensure we have a stable typing graph, we repeatedly update the active functions in our graph until the type graph is stable.

This can lead to many copies of the same function, or even multiple signatures of the same function, only one of which we'll use.

This change prunes those away before we submit them to the LLVM layer.

How Has This Been Tested?

Running test_dispatch_to_function_overload with TP_COMPILER_VERBOSE=1with and without this commit causes 13 functions to be converted rather than 17, with a slight speedup.

Types of changes

Checklist: