mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
Issue #28618: Make hot functions using __attribute__((hot))
When Python is not compiled with PGO, the performance of Python on call_simple and call_method microbenchmarks depend highly on the code placement. In the worst case, the performance slowdown can be up to 70%. The GCC __attribute__((hot)) attribute helps to keep hot code close to reduce the risk of such major slowdown. This attribute is ignored when Python is compiled with PGO. The following functions are considered as hot according to statistics collected by perf record/perf report: * _PyEval_EvalFrameDefault() * call_function() * _PyFunction_FastCall() * PyFrame_New() * frame_dealloc() * PyErr_Occurred()
This commit is contained in:
parent
0cae609847
commit
c6944e7edc
4 changed files with 31 additions and 8 deletions
|
@ -718,7 +718,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
|||
return tstate->interp->eval_frame(f, throwflag);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyObject* _Py_HOT_FUNCTION
|
||||
_PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
|
||||
{
|
||||
#ifdef DXPAIRS
|
||||
|
@ -4771,7 +4771,7 @@ if (tstate->use_tracing && tstate->c_profilefunc) { \
|
|||
x = call; \
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
static PyObject* _Py_HOT_FUNCTION
|
||||
call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
|
||||
{
|
||||
PyObject **pfunc = (*pp_stack) - oparg - 1;
|
||||
|
@ -4844,7 +4844,7 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
|
|||
done before evaluating the frame.
|
||||
*/
|
||||
|
||||
static PyObject*
|
||||
static PyObject* _Py_HOT_FUNCTION
|
||||
_PyFunction_FastCall(PyCodeObject *co, PyObject **args, Py_ssize_t nargs,
|
||||
PyObject *globals)
|
||||
{
|
||||
|
|
|
@ -158,7 +158,7 @@ PyErr_SetString(PyObject *exception, const char *string)
|
|||
}
|
||||
|
||||
|
||||
PyObject *
|
||||
PyObject* _Py_HOT_FUNCTION
|
||||
PyErr_Occurred(void)
|
||||
{
|
||||
PyThreadState *tstate = PyThreadState_GET();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue