You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CALL_LIST_APPEND specialization can make no progress #141367
CALL_LIST_APPEND requires self to be a PyList_CheckExact in bytecodes.c. However, the specialize.c doesn't check that. This means there's a possible discrepancy between what we specialize for and what we deopt.
The fix is to check that self is a list. It should be as simple as
@Fidget-Spinner , I've created a PR with your proposed solution, CI is green.
I've used _PyThreadState_GET instead of PyThreadState_GET because it's sligtly faster, IIUC.
And make test for both list and MyListappend specialization.
Rather than probing the stack tstate->current_frame->stackpointer[-2], we should pass the arguments to _Py_Specialize_Call.
We also need to add an additional guard in _CALL_LIST_APPEND that callable == interp->callable_cache.list_append.
Rather than probing the stack tstate->current_frame->stackpointer[-2], we should pass the arguments to _Py_Specialize_Call.
Ok, I'll investigate this.
We also need to add an additional guard in _CALL_LIST_APPEND that callable == interp->callable_cache.list_append.
Do we really need this since _GUARD_CALLABLE_LIST_APPEND is present?
Maybe we should remove checking DEOPT_IF(!PyList_CheckExact(self_o)) in _GUARD_CALLABLE_LIST_APPEND because _GUARD_NOS_LIST is already used in CALL_LIST_APPEND macro?
Do we really need this since _GUARD_CALLABLE_LIST_APPEND is present?
No we don't. I was just looking at the uop, not the whole instruction.
Maybe we should remove checking DEOPT_IF(!PyList_CheckExact(self_o)) in _GUARD_CALLABLE_LIST_APPEND because _GUARD_NOS_LIST is already used in CALL_LIST_APPEND macro?
Activity
efimov-mikhail commentedon Nov 10, 2025
@Fidget-Spinner , of course, I will take this, thanks.
efimov-mikhail commentedon Nov 11, 2025
Actually, it isn't affected.
You can see your own comment on PR with this change:
#134240 (comment)
So, basically, we should fix specialization on main branch only.
I'll create a PR soon.
Fidget-Spinner commentedon Nov 11, 2025
Great observation, thanks!
efimov-mikhail commentedon Nov 11, 2025
@Fidget-Spinner , I've created a PR with your proposed solution, CI is green.
I've used
_PyThreadState_GETinstead ofPyThreadState_GETbecause it's sligtly faster, IIUC.And make test for both
listandMyListappendspecialization.markshannon commentedon Nov 11, 2025
Rather than probing the stack
tstate->current_frame->stackpointer[-2], we should pass the arguments to_Py_Specialize_Call.We also need to add an additional guard in
_CALL_LIST_APPENDthatcallable == interp->callable_cache.list_append.efimov-mikhail commentedon Nov 11, 2025
Ok, I'll investigate this.
Do we really need this since
_GUARD_CALLABLE_LIST_APPENDis present?Maybe we should remove checking
DEOPT_IF(!PyList_CheckExact(self_o))in_GUARD_CALLABLE_LIST_APPENDbecause_GUARD_NOS_LISTis already used inCALL_LIST_APPENDmacro?markshannon commentedon Nov 11, 2025
No we don't. I was just looking at the uop, not the whole instruction.
Yes, that makes sense.
efimov-mikhail commentedon Nov 11, 2025
While working on this issue I've found this PR:
https://github.com/python/cpython/pull/132018/files#diff-af5c4ee62cca27529efe0febc3babfd5745cc1ae48a280a58605a8c85ee38942R335
Maybe we should change this test a little to use actual
SPECIALIZATION_THRESHOLDinstead of constant3?Fidget-Spinner commentedon Nov 11, 2025
Maybe not for this PR, but if you open another PR to fix it I'd be open to merging.
gh-141367: Use actual SPECIALIZATION_THRESHOLD value in specializatio…
gh-141367: Use CALL_LIST_APPEND instruction only for lists, not for l…
pythongh-141367: Use actual SPECIALIZATION_THRESHOLD value in special…
pythongh-141367: Use CALL_LIST_APPEND instruction only for lists, not…