python / python/cpython

Mark all objects reachable from roots as live before doing main cyclic GC pass

未關閉
#126,491 7 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

interpreter-core performance type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Objects can only be cyclic garbage if they are not reachable.
So, if we can cheaply identify the majority of reachable objects before performing the (relatively slow) cycle detecting pass, we can save a lot of time.

Performing a transitive closure of all objects reachable from global roots (the sys and builtins modules as well as builtin class's dicts and sublasses) plus a transitive closure of all objects reachable from the stacks can eliminate >90% of all objects relatively cheaply.

Initial experiments show a ~3% speedup, with an almost 50% speedup of the most gc-heavy benchmark.

This idea has been proposed a few times.
@nascheme has definitely suggested it before. Perhaps he can add links to any prior discussion and/or experiments?

What makes this more feasible now is that the GC can see the evaluation stack of frames, thanks to #124392, so we would now expect that the vast majority of reachable objects can be cheaply marked, thus improving the efficiency of cycle detection considerably.

Linked PRs
  • gh-126502
  • gh-126983
  • gh-126984
  • gh-127110
  • gh-127519
  • gh-127770

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從本 issue 中的可達性提案、#124392 中對評估堆疊的變更,以及連結的 PR #126502、#126983、#126984、#127110、#127519 和 #127770 開始。先審閱這些討論和實驗;完成的標準是:在主要循環 GC 遍歷之前標記可達物件,並對宣稱的效能改善進行測量和驗證。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
performance
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
20/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。