Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-44590: Lazily allocate frame objects#27077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
79aeaf63b6a4e86f0ba408543c27423d4037bf6c30861a8d935e793c192094e3f601a7bd95c329961abc32af707ac7dbe8f33d2915c23a36910e99122e1c9bf84a3f01180a44c76de8915aeef11d2e1ce1b19f8bd619baed147d0325c6a71618b094e5da338dda0b0c5ecc0673b65a0f596213d386275e596c041039bca72cad33b77cf187decf209666b61890ed5b6593a348b775f13e8476b2File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -56,6 +56,7 @@ def temporary_filename(): | ||
| os_helper.unlink(filename) | ||
| class FaultHandlerTests(unittest.TestCase): | ||
markshannon marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| def get_output(self, code, filename=None, fd=None): | ||
| """ | ||
| Run the specified code in Python (in a new child process) and read the | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| All necessary data for executing a Python function (local variables, stack, | ||
| etc) is now kept in a per-thread stack. Frame objects are lazily allocated | ||
| on demand. This increases performance by about 7% on the standard benchmark | ||
| suite. Introspection and debugging are unaffected as frame objects are | ||
| always available when needed. Patch by Mark Shannon. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,7 +3,7 @@ | ||
| #include "pycore_pymem.h" // _Py_tracemalloc_config | ||
| #include "pycore_traceback.h" | ||
| #include "pycore_hashtable.h" | ||
| #include "frameobject.h" // PyFrame_GetBack() | ||
| #include <pycore_frame.h> | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m curious why this one is included with | ||
| #include "clinic/_tracemalloc.c.h" | ||
| /*[clinic input] | ||
| @@ -299,18 +299,16 @@ hashtable_compare_traceback(const void *key1, const void *key2) | ||
| static void | ||
| tracemalloc_get_frame(PyFrameObject *pyframe, frame_t *frame) | ||
| tracemalloc_get_frame(InterpreterFrame *pyframe, frame_t *frame) | ||
| { | ||
| frame->filename = unknown_filename; | ||
| int lineno = PyFrame_GetLineNumber(pyframe); | ||
| int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*2); | ||
| if (lineno < 0){ | ||
| lineno = 0; | ||
| } | ||
| frame->lineno = (unsigned int)lineno; | ||
| PyCodeObject *code = PyFrame_GetCode(pyframe); | ||
| PyObject *filename = code->co_filename; | ||
| Py_DECREF(code); | ||
| PyObject *filename = pyframe->f_code->co_filename; | ||
| if (filename == NULL){ | ||
| #ifdef TRACE_DEBUG | ||
| @@ -395,7 +393,7 @@ traceback_get_frames(traceback_t *traceback) | ||
| return; | ||
| } | ||
| PyFrameObject *pyframe = PyThreadState_GetFrame(tstate); | ||
| InterpreterFrame *pyframe = tstate->frame; | ||
| for (; pyframe != NULL;){ | ||
| if (traceback->nframe < _Py_tracemalloc_config.max_nframe){ | ||
| tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]); | ||
| @@ -406,8 +404,7 @@ traceback_get_frames(traceback_t *traceback) | ||
| traceback->total_nframe++; | ||
| } | ||
| PyFrameObject *back = PyFrame_GetBack(pyframe); | ||
| Py_DECREF(pyframe); | ||
| InterpreterFrame *back = pyframe->previous; | ||
| pyframe = back; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.