NVIDIA / NVIDIA/cuda-python

[PERF]: Measure the performance potential of caching pre-converted arguments at the call site

オープン
#1,655 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

@mdboom がすでに取り組んでいます。

2026年2月27日 から。

cuda.bindings experiment performance triage
主要言語
Cython
スター
3.4k
フォーク
329
平均マージ
1日 23時間
マージ済み PR(30日)
116

説明

I first came across the idea presented here in this paper: https://drops.dagstuhl.de/storage/00lipics/lipics-vol313-ecoop2024/LIPIcs.ECOOP.2024.6/LIPIcs.ECOOP.2024.6.pdf

The idea is that function calls across a language boundary spend a lot of time converting data structures from one form to another. Particulary in dynamic languages, there are many different code paths to handle many supported data types, but in practice, the types are quite stable between calls even in as the values change. The general idea is that once a particular call gets "hot", you replace a general function that handles all types with one that is specialized for specific types.

If you suppose the following times:

  • T: The total time to convert any acceptable types in a dynamic and fully safe way
  • H: The time to hash the types of the arguments
  • F: The time to convert specific types, in a less safe way

In order for this to work, H + F should be significantly less than T, and the rate at which you see the same types at the same call site needs to be high enough that (T + H)x + (H + F)(1 - x) amortizes to less than T.

We can start by building a prototype to measure T, H, F, and x, and then decide whether it is worth the effort to proceed further.

The best solution is to add support for this "call site caching" to the CPython interpreter (though there are object lifetime issues that made that tricky). It is also possible to do this outside of the CPython interpreter by creating a call-site-to-cache mapping (at the expense of some performance).

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。