Smaller objects for the free-threading build using smaller integer types for refcount
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
The literature on reference counting for JVM and other GCs show that very few reference counts get to more than 7. This matches up with our stats that should the ratio of refcount ops to object allocations is about 6/7 to 1.
With that in mind, it would make sense to make the C ints used to represent refcounts smaller.
Instead of:
uint32_t ob_ref_local; // local reference count
Py_ssize_t ob_ref_shared; // shared (atomic) reference count
we can use:
uint8_t ob_ref_local; // local reference count
uint32_t ob_ref_shared; // shared (atomic) reference count
using 5 bytes instead of 12.
If ob_ref_local would overflow, we can atomically move some of that count into ob_ref_shared.
if (++op->ob_ref_local == 0) {
atomic_add(&op->ob_ref_shared, 128);
op->ob_ref_local = 128;
}
ob_ref_shared can use the same approach to saturation and immortality that the default build currently does.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
未指定檔案或測試名稱。先從 free-threading 建置中 ob_ref_local 和 ob_ref_shared 的定義與使用開始,然後追蹤參照計數溢位、原子更新、飽和以及不朽行為。完成的標準是:較小的配置能夠正常運作,同時不改變參照計數的正確性或所述的溢位行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- performance
- Issue 類型
- 重構
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100