perf_jit activated from a subinterpreter publishes JIT executors with the trampoline's unwind info
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
sys.activate_stack_trampoline() refuses to run while the JIT is active, but it only checks the current interpreter, and the perf state is process-wide. A subinterpreter can activate perf_jit while the main interpreter keeps its JIT.
import sys
from concurrent import interpreters
interpreters.create().exec("import sys; sys.activate_stack_trampoline('perf_jit')")
def hot(n):
t = 0
for i in range(n):
t += i & 3
return t
for _ in range(50):
hot(100000)
With PYTHON_JIT=1 ./python buggy_stuff.py on a --enable-experimental-jit build, the resulting /tmp/jit-.dump holds the JIT's executors (records named py::jit:executor), and every one of them is tagged with the unwind information of the 8-byte perf trampoline. Executor frames look different, so perf produces wrong stacks for samples inside JIT code.
Found while working on https://github.com/python/cpython/pull/157246
CPython versions tested on:
CPython main branch, 3.16
Operating systems tested on:
Linux
Linked PRs
- gh-157258
- gh-157324
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit sys.activate_stack_trampoline(), der Option perf_jit und der Reproduktion mit Subinterpreter aus dem Issue; führe dies auf einem Linux-Build mit experimentellem JIT mit PYTHON_JIT=1 aus und untersuche den erzeugten /tmp/jit-.dump. Verfolge, wie JIT-Executors Unwind-Informationen erhalten, und betrachte das Issue als gelöst, wenn Executor-Frames nicht mehr mit den Unwind-Daten des 8-Byte-perf-Trampolins gekennzeichnet sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers, performance
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100