CALL_FUNCTION_EX argument passing routine can be improved for vectorcalls
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 36k
- Merge moyen
- 1 j 9 h
- PR mergées (30 j)
- 558
Description
While working on https://github.com/python/cpython/issues/95126, I noticed that CALL_FUNCTION_EX for vectorcall Python functions is extremely wasteful. These are its steps:
CALL_FUNCTION_EXcallsdo_call_corewith aargstuple andkwargsdict.- Eventually it's detected that the function supports vectorcall, and it calls
_PyVectorcall_Call. This calls_PyStack_UnpackDict, which unpacks theargstuple andkwargsdict into a C array. - This C array is passed to the vectorcall function. Eventually calling
_PyEval_Vector. _PyEval_Vectorcalls_PyEvalFramePushAndInit, which sees that there's complex args, and recreates the tuple and args dict ininitialize_localsfrom the C array.- Frame is pushed and evaluated, then popped. End.
We shouldn't even be converting the arguments to a C array just to vectorcall. We should instead directly transfer ownership of args tuple and kwds dict because that would be significantly faster in this case (and save us the tuple and dict recreation dance).
CC @markshannon and @brandtbucher .
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Suivez le flux des arguments à travers do_call_core, _PyVectorcall_Call, _PyStack_UnpackDict, _PyEval_Vector, _PyEvalFramePushAndInit et initialize_locals. Comprenez d’abord comment CALL_FUNCTION_EX atteint les fonctions Python vectorcall et comment la propriété est gérée à chaque frontière. Le travail est terminé lorsque le chemin évite le tableau C intermédiaire et la recréation de tuple/dict, tout en préservant la propriété correcte des arguments et le comportement attendu.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- compilers
- Type d'issue
- Refactorisation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100