python / python/cpython

Calls across stack chunks perform badly

Ouverte
#142,183 11 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

3.15 interpreter-core performance
Langage dominant
Python
Étoiles
77.2k
Forks
35.9k
Métriques de merge des PR
Métriques de PR en attente

Description

The Python stack is composed of a series of chunks of memory. These chunks are large, so we cross the boundaries infrequently and assume that it will never be on the fast path.

Unfortunately, it is possible to cross the boundary repeatedly if looping deep in the stack.

We should adjust the stack when crossing the boundary, to avoid doing so repeatedly.

Possible options include:

  1. Move the caller to the new chunk, so repeated calls do not cross the boundary.
  2. Instead of using a chunked stack, double the size of the stack and copy the old stack.

Both of these assume that we can move the frame. This is only possible if there are no pointers into the frame.
If a frames calls a native function taking an array of arguments, then there will be pointers into the frame.
So if we do any moving, we need to check for these pointers.

While we cannot move the frame, we can copy it, as long as the original remains. This is a bit wasteful, but shouldn't happen too often or waste too much space.

Linked PRs
  • gh-145789
  • gh-145828
  • gh-145829
  • gh-146123
  • gh-148681
  • gh-149097

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 PRs liés gh-145789, gh-145828, gh-145829, gh-146123, gh-148681 et gh-149097, puisque l’issue ne fournit ni fichiers ni tests. Le travail est considéré comme terminé lorsqu’il évite les franchissements répétés entre les segments de pile tout en préservant la correction lorsque des appels natifs maintiennent des pointeurs vers des frames.

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

Évaluation

Stack technique
python
Domaine
performance
Type d'issue
Bug
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

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