-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
GH-93516: Speedup line number checks when tracing. #93763
Changes from 3 commits
6b2d840
47cb2ed
c087308
3e5d1fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,8 @@ typedef uint16_t _Py_CODEUNIT; | |
PyObject *co_exceptiontable; /* Byte string encoding exception handling \ | ||
table */ \ | ||
int co_flags; /* CO_..., see below */ \ | ||
int co_warmup; /* Warmup counter for quickening */ \ | ||
short co_warmup; /* Warmup counter for quickening */ \ | ||
short _co_linearray_entry_size; /* Size of each entry in _co_linearray */ \ | ||
\ | ||
/* The rest are not so impactful on performance. */ \ | ||
int co_argcount; /* #arguments, except *args */ \ | ||
|
@@ -90,6 +91,7 @@ typedef uint16_t _Py_CODEUNIT; | |
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \ | ||
void *_co_code; /* cached co_code object/attribute */ \ | ||
int _co_firsttraceable; /* index of first traceable instruction */ \ | ||
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 missed when this was added, but maybe we could move this member up with the other 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. Not without breaking code that accesses |
||
char *_co_linearray; /* array of line offsets */ \ | ||
/* Scratch space for extra data relating to the code object. \ | ||
Type is a void* to keep the format private in codeobject.c to force \ | ||
people to go through the proper APIs. */ \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Lazily create a table mapping bytecode offsets to line numbers to speed up | ||
calculation of line numbers when tracing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal since you were able to squeeze this in here, but we might want to consider making this the first byte of the line array (or a flag on the code object) if we end up getting rid of
co_warmup
later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally made it a bit in
co_flags
but I'm worried that might be considered an API change by some.