-
-
Notifications
You must be signed in to change notification settings - Fork 34k
gh-143995: Eliminate redundant refcounting in the JIT from LOAD_ATTR_MODULE #143996
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
base: main
Are you sure you want to change the base?
Conversation
Objects/moduleobject.c
Outdated
| void | ||
| _PyModule_ExactDealloc(PyObject *self) | ||
| { | ||
| assert(PyModule_CheckExact(self)); | ||
| module_dealloc(self); | ||
| } | ||
|
|
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.
No need to do this. The main benefit of CLOSE_SPECIALIZED is to tell the bytecodes generator the call is non-escaping. In this case, this is actually escaping as deallocating a module object frees other data.
Python/bytecodes.c
Outdated
| macro(LOAD_ATTR_MODULE) = | ||
| unused/1 + | ||
| _LOAD_ATTR_MODULE + | ||
| _POP_TOP_MODULE + |
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.
Please use POP_TOP here
Python/optimizer_bytecodes.c
Outdated
| op(_POP_TOP_MODULE, (value --)) { | ||
| if (PyJitRef_IsBorrowed(value) || | ||
| sym_is_immortal(PyJitRef_Unwrap(value))) { | ||
| REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0); | ||
| } | ||
| } |
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.
Remove this please.
| } | ||
|
|
||
| op(_LOAD_ATTR_MODULE, (dict_version/2, index/1, owner -- attr)) { | ||
| op(_LOAD_ATTR_MODULE, (dict_version/2, index/1, owner -- attr, o)) { |
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.
Tests are failing because the case where this is promoted to globals successfully now has wrong stack effect. It should use the SHUFFLE/INSERT opcodes rather than LOAD_CONST_INLINE_BORROW.
If you'd like to look into it, let me know, otherwise I can fix this.
Generated `uops` before:
Generated `uops` after:
Diff:
The time cost for 1000000 iterations in the
testfuncin the test case is reduced from approximately 126 seconds to 120 seconds.LOAD_ATTR_MODULE#143995