-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-37146: Allow to configure opcode cache and fix huntleaks by presetting it to 1 #13789
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
Conversation
Tested locally:
|
Tested also with |
Include/internal/pycore_pystate.h
Outdated
@@ -43,6 +43,10 @@ struct _pending_calls { | |||
int last; | |||
}; | |||
|
|||
struct _opcodecache_config { | |||
int minruns; | |||
}; |
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.
the struct is useless, just put directly the int into _ceval_runtime_state.
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 made a struct for easy extending more stuff in the config in the future.
I will remove it
Include/internal/pycore_pystate.h
Outdated
@@ -312,6 +317,10 @@ PyAPI_FUNC(void) _PyInterpreterState_DeleteExceptMain(_PyRuntimeState *runtime); | |||
|
|||
PyAPI_FUNC(void) _PyGILState_Reinit(_PyRuntimeState *runtime); | |||
|
|||
PyAPI_FUNC(void) _PyEval_SetOpcodeCacheMinRuns(int minruns); | |||
|
|||
PyAPI_FUNC(int) _PyEval_GetOpcodeCacheMinRuns(); |
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.
you should use: (void)
Lib/test/libregrtest/runtest.py
Outdated
@@ -206,6 +206,8 @@ def _test_module(the_module): | |||
def _runtest_inner2(ns, test_name): | |||
# Load the test function, run the test function, handle huntrleaks | |||
# and findleaks to detect leaks | |||
minruns = sys._getopcacheminruns() |
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 don't think that it matters to restore the old value. I'm not sure that sys._getopcacheminruns() is needed.
Python/pylifecycle.c
Outdated
@@ -737,6 +737,9 @@ _Py_PreInitializeFromPyArgv(const PyPreConfig *src_config, const _PyArgv *args) | |||
return status; | |||
} | |||
|
|||
// XXX: Add this properly to the commandline config |
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.
pleave remove this XXX. It doesn't have to be a cmdline option.
Lib/test/libregrtest/runtest.py
Outdated
@@ -206,6 +206,8 @@ def _test_module(the_module): | |||
def _runtest_inner2(ns, test_name): | |||
# Load the test function, run the test function, handle huntrleaks | |||
# and findleaks to detect leaks | |||
minruns = sys._getopcacheminruns() | |||
sys._setopcacheminruns(1) |
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.
That's wrong. Only dash_R() should be modified in libregrtest/refleak.py. You must not disable the opcache in runtest.py.
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.
Sorry, this was supposed to reset the original value. Check out my last fixup (bd3a951),
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 think you misunderstood my comment. You must not modify this function but dash_R() function.
When you're done making the requested changes, leave the comment: |
The code object will be optimized only when Please use #13787 for 3.8b1. |
…resetting it to 1
…ks by presetting it to 1
…huntleaks by presetting it to 1
…nd fix huntleaks by presetting it to 1
Ok, I will close this PR then. |
Maybe keep it around, it's sounds like a good fix for post-beta1. |
https://bugs.python.org/issue37146