classification
Title: Should PyObject_Call() call the profiler on C functions, use C_TRACE() macro?
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: haypo, inada.naoki, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-02-08 15:39 by haypo, last changed 2017-02-09 11:05 by haypo.

Files
File name Uploaded Description Edit
profiler_c_code.py haypo, 2017-02-09 11:05
Messages (2)
msg287343 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-02-08 15:39
call_function() and do_call_core() functions of Python/ceval.c use C_TRACE() macro to call the profiler, but PyObject_Call() and similar functions like _PyObject_FastCallKeywords() don't.

Is it a bug or a deliberate choice for performance?

Since PyObject_Call() and similar functions have now fast paths, I don't think that it's still needed to have these fast paths in ceval.c too. But I kept fast paths in ceval.c because of C_TRACE().
msg287402 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-02-09 11:05
Output of attached profiler_c_code.py example:
---
haypo@selma$ ./python profiler_c_code.py 
(<frame object at 0xf9d788>, 'call', None)
(<frame object at 0xf9d788>, 'return', 'h')
(<frame object at 0xf9d788>, 'call', None)
(<frame object at 0xf9d788>, 'return', 'e')
(<frame object at 0xf9d788>, 'call', None)
(<frame object at 0xf9d788>, 'return', 'l')
(<frame object at 0xf9d788>, 'call', None)
(<frame object at 0xf9d788>, 'return', 'l')
(<frame object at 0xf9d788>, 'call', None)
(<frame object at 0xf9d788>, 'return', 'o')
(<frame object at 0xf9d498>, 'c_call', <built-in function setprofile>)
---

Except of sys.setprofile(), the profiler doesn't see any C calls! list() and map() are simply "hidden".

So tools like coverage miss a lot of C call? Again, is it a compromise between performance and correctness, or just a regular bug?
History
Date User Action Args
2017-02-09 11:05:29hayposetfiles: + profiler_c_code.py

messages: + msg287402
2017-02-08 15:39:38haypocreate