JIT: Set the IP and check for invalidation in `POP_TOP` only if `Py_Dealloc` is called.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
The optimizer removes many POP_TOPs, but quite a few remain.
The code for POP_TOP looks like this:
inst(POP_TOP, (value --)) {
PyStackRef_XCLOSE(value);
}
which is fine for the interprete but in the JIT, as POP_TOP is marked as escaping, we need to set the IP before and check for invalidation afterwards.
What we could do, is have a version of POP_TOP that sets the IP and checks for invalidation only if Py_Dealloc is called, so we don't need to add SET_IP and CHECK_VALIDITY.
The new form of POP_TOP would look like this:
op(_POP_TOP_SET_IP_CHECK_INVALID, (value --)) {
if (do_decref_and_refcnt_is_zero(value)) {
SET_IP()
Py_Dealloc()
CHECK_VALID();
}
}
_POP_TOP_SET_IP_CHECK_INVALID should be inserted in the same pass that we insert _SET_IP and _CHECK_VALIDITY as we know whether we need to insert those uops, and leave POP_TOP alone in those cases.
Overall, this should speed things up as it doesn't increase the overall code size, but it does execute less code in many cases.
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
Untersuche die JIT-Implementierung von POP_TOP und den Pass, der _SET_IP und _CHECK_VALIDITY einfügt. Verfolge do_decref_and_refcnt_is_zero sowie die vorhandenen Pfade SET_IP, Py_Dealloc und CHECK_VALID; abgeschlossen ist die Arbeit, wenn die spezialisierte Form nur dort eingefügt wird, wo sie benötigt wird, während POP_TOP an anderer Stelle unverändert bleibt und das Invalidation-Verhalten erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, python
- Bereich
- compilers, performance
- Issue-Typ
- Refactoring
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100