GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||
GeezerVison is showing github.com — gh-131798: Split `CHECK_FUNCTION_VERSION` into two guards in the JIT by Sacul0457 · Pull Request #145080 · python/cpython Conversation
|
|
Is this optimization still correct/sound after #146101? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| op(_CHECK_FUNCTION_VERSION, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { | ||
| assert(sym_matches_type(callable, &PyFunction_Type)); | ||
| if (sym_get_func_version(callable) == func_version) { | ||
| REPLACE_OP(this_instr, _NOP, 0, 0); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I just realised this existing code I wrote might be wrong
The idea is that it's possible to modify a function version midway in a trace, so we need to recheck it or at least add a watcher at the first check.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@Sacul0457 would you be willing to help me fix this (please open a separate issue if so)? Basically you'd need to add a PyFunction_AddWatcher in the else case of this branch. (See what we do in _GUARD_TYPE_VERSION). It's just a callback that invalidates the executors (see type_watcher_callback).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sure, Ill open an issue and the PR in a bit
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hi, I was just taking a look at this issue and I've got a few questions:
PyFunction_AddWatcher only if the func_version was set properly, like what _GUARD_TYPE_VERSION version does?PyFunction_WatchCallback do I add to PyFunction_AddWatcher or am I suppose to create one similar to type_watcher_callbackI'll continue to look into this in the meantime, thx! :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We add a PyFunction_AddWatcher only if the func_version was set properly, like what _GUARD_TYPE_VERSION version does?
Yup!
If so, what PyFunction_WatchCallback do I add to PyFunction_AddWatcher or am I suppose to create one similar to type_watcher_callback
Yes you need to create your own one with its own ID similar to type_watcher_callback.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The function watcher needs to be more specific though: we want to invalidate for everything except for PyFunction_EVENT_DESTROY. As that doesn't actually invalidate any of our assumptions.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah ok ty!
Yes you need to create your own one with its own ID similar to type_watcher_callback.
Just one more thing on the callback (sorry!),
type_watcher_callback calls PyType_Unwatch, and so I'm guessing I also need to create some sort of PyFunc_Unwatch?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It should be PyFunction_ClearWatcher (check Objects/funcobject.c)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Found it thx!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Is this optimization still possible/correct with #146300? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Incorrectly marked as duplicate. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Documentation build overview
353 files changed ·
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.