python / python/cpython

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

Ouverte
#100,403 29 commentaires 3 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

interpreter-core
Langage dominant
Python
Étoiles
77.2k
Forks
36k
Merge moyen
1 j 9 h
PR mergées (30 j)
558

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par examiner les observations du benchmark dans cet issue ainsi que le PR gh-100958 associé. Le travail proposé consiste à comparer la stratégie générationnelle actuelle avec une seule génération et des seuils dynamiques ; sa réalisation nécessiterait de retenir une approche étayée par des résultats de performance, mais aucun fichier ni test précis n’est indiqué ici.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
backend, performance
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
20/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.