python / python/cpython

Calls across stack chunks perform badly

Offen
#142,183 11 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

3.15 interpreter-core performance
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Durchsicht der verknüpften PRs gh-145789, gh-145828, gh-145829, gh-146123, gh-148681 und gh-149097, da das Issue keine Dateien oder Tests bereitstellt. Als abgeschlossen gilt die Arbeit, wenn wiederholte Übergänge zwischen Stack-Chunks vermieden werden und die Korrektheit erhalten bleibt, während native calls Pointer in Frames halten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
performance
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.