Is there similar PyEval_EvalFrameEx() function in PyPy?

We would like to monitor and log all external function calls from a class: when there the function call happen, we capture and log the frame. In python, there is the function PyEval_EvalFrameEx() we might add a callback inside. Is there a similar function in PyPy that would be called when the function call happens?

Did you consider the trace module? https://docs.python.org/2/library/trace.html 2015-05-26 11:45 GMT+02:00 Yicong Huang <hengha.mao@gmail.com>:
-- Amaury Forgeot d'Arc

Yes, we are trying to modify PyPy to meet the need. Our plans are: 1. Find a similar function as "PyEval_EvalFrameEx()" in PyPy, and add a function logFunction() inside it. 2. In logFunction(), analyze the frame/callstack. If it is a function call from "Class A" to external function, log the function call. If it is possible, we might only need to log the same function call only once to minimize the perfomrance overhead. The problem is we've no ideas on which function in PyPy is similar to "PyEval_EvalFrameEx()" in Python. Or do you have any alternative good ideas to do this? On Tue, May 26, 2015 at 6:01 PM, Amaury Forgeot d'Arc <amauryfa@gmail.com> wrote:

you will kill the JIT performance terribly if you do that. space.call or space.call_function (in pypy/objspace/std/objspace or pypy/interpreter/baseobjspace) are your candidates On Tue, May 26, 2015 at 12:31 PM, Yicong Huang <hengha.mao@gmail.com> wrote:

Great thanks! I think you are right. We might kill the JIT perfomance by introducing such work. Another possible solution is we could do it at module level. Is there a function smilar as " PyMODINIT_FUNC()" in Pypy? Here is the plan: 1. When the code try to import an external module, we invoke an inserted function doLog(). 2. doLog() function record the module name and all module's public function. In this way, I think we could greatly reduce the perfomance overhead. On Tue, May 26, 2015 at 6:32 PM, Maciej Fijalkowski <fijall@gmail.com> wrote:

Hi Yicong, On 26 May 2015 at 14:00, Yicong Huang <hengha.mao@gmail.com> wrote:
What do you mean by "an external module"? Is it a CPython C extension module imported via cpyext? I really think you want to look at sys.settrace() or sys.setprofile(). A bientôt, Armin.

Did you consider the trace module? https://docs.python.org/2/library/trace.html 2015-05-26 11:45 GMT+02:00 Yicong Huang <hengha.mao@gmail.com>:
-- Amaury Forgeot d'Arc

Yes, we are trying to modify PyPy to meet the need. Our plans are: 1. Find a similar function as "PyEval_EvalFrameEx()" in PyPy, and add a function logFunction() inside it. 2. In logFunction(), analyze the frame/callstack. If it is a function call from "Class A" to external function, log the function call. If it is possible, we might only need to log the same function call only once to minimize the perfomrance overhead. The problem is we've no ideas on which function in PyPy is similar to "PyEval_EvalFrameEx()" in Python. Or do you have any alternative good ideas to do this? On Tue, May 26, 2015 at 6:01 PM, Amaury Forgeot d'Arc <amauryfa@gmail.com> wrote:

you will kill the JIT performance terribly if you do that. space.call or space.call_function (in pypy/objspace/std/objspace or pypy/interpreter/baseobjspace) are your candidates On Tue, May 26, 2015 at 12:31 PM, Yicong Huang <hengha.mao@gmail.com> wrote:

Great thanks! I think you are right. We might kill the JIT perfomance by introducing such work. Another possible solution is we could do it at module level. Is there a function smilar as " PyMODINIT_FUNC()" in Pypy? Here is the plan: 1. When the code try to import an external module, we invoke an inserted function doLog(). 2. doLog() function record the module name and all module's public function. In this way, I think we could greatly reduce the perfomance overhead. On Tue, May 26, 2015 at 6:32 PM, Maciej Fijalkowski <fijall@gmail.com> wrote:

Hi Yicong, On 26 May 2015 at 14:00, Yicong Huang <hengha.mao@gmail.com> wrote:
What do you mean by "an external module"? Is it a CPython C extension module imported via cpyext? I really think you want to look at sys.settrace() or sys.setprofile(). A bientôt, Armin.
participants (4)
-
Amaury Forgeot d'Arc
-
Armin Rigo
-
Maciej Fijalkowski
-
Yicong Huang