Repository navigation
Conversation
|
The C API function to set vectorcalls (https://docs.python.org/3/c-api/function.html#c.PyFunction_SetVectorcall) does a stop the world which seems like makes this unnecessary. Can see avoiding the stop the world being good, but would be better to me to improve the general path than make every vectorcall a little slower. |
Unfortunately using that consistently is going to be too slow. The worst case scenario here is lambdas/closures which typically get created a lot. Stopping the world to set it on all of those would be pretty bad. But I'm not sure there is much of a need to stop the world to set vector call? The entry point should have identical behavior as it not being replaced and so the place where it matters is around specialization / the interpreter avoiding interpreting it. And if you lose the race there it's not really different than losing the race to stopping the world. So maybe a relaxed load should be used everywhere? |
|
So lets make it faster; direct setting the pointer and then fixing the race because it was direct set raises other issues. If just setting without a stop the world is safe, lets make the C Function do that safe thing. Doing atomics always / everywhere does have an impact on performance; there are reasons choose other mechanisms in a lot of these places. |
Vectorcall can be updated on another thread in the free-threaded build if a JIT like CinderX or Numba were to compile the function. This should be ready using a relaxed atomic.