python / python/cpython

Improving GC collections: dynamic thresholds, single generation gc and time barriers

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

まだ誰も着手していません。

interpreter-core
主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

説明

In the pursuit of trying to optimize GC runs it has been observed that the weak generational hypothesis may not apply that well to Python. This is because, according to this argument, in the presence of a mixel cycle GC + refcount GC strategy, young objects are mostly cleaned up by reference count, not by the GC. Is important as well that there is no segregation between the GC strategies and that the cycle GC needs to deal with objects that according to this will be mainly cleaned up by reference count alone.

This questions the utility of segregating GC by generations and indeed there is some evidence of this. I have been benchmarking the percentage of success of different generations in some programs (such as blach and mypy and a bunch of HTTP servers) and the success rate of the lower generations is generally small. Here is an example of running black over all the standard library:

Statistics for generation 0

Category Value
count 157917.000000
mean 1.192775
std 3.560391
min 0.000000
25% 0.000000
50% 0.000000
75% 0.480192
max 86.407768

Statistics for generation 1

Category Value
count 14346.000000
mean 2.670852
std 11.642815
min 0.000000
25% 0.000000
50% 0.000000
75% 0.388794
max 97.406097

Statistics for generation 2

Category Value
count 1280.000000
mean 45.698135
std 27.066735
min 0.000000
25% 31.965862
50% 54.618008
75% 67.038842
max 90.592705

I am currently investigating if having a single generation with a dynamic threshold that is similar to the strategy that we use currently for the last generation would be generally better to get better performance.

What do you think?

Linked PRs
  • gh-100958

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

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

はじめの一歩

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

調査の方向性

まず、この issue にあるベンチマークの観察結果と、リンクされている PR gh-100958 を確認してください。提案されている作業は、現在の世代戦略と、単一世代および動的なしきい値を比較することです。完了には、パフォーマンス結果に裏付けられた方針を決定する必要がありますが、ここでは具体的なファイルやテストは指定されていません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend, performance
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

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

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