You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting #81327
$ make && ./python -m test -R 3:3 test_pprint
...
Tests result: SUCCESS
(*) Find a way to explicitly deoptimize all code objects
Modules/gcmodule.c has a clear_freelists() function called by collect() if generation == NUM_GENERATIONS-1: on when gc.collect() is collected explicitly for example.
INADA-san wrote PR 13787 to disable opcache when Python is compiled in debug mode. Pablo and me approved the change, so I merged it.
Pablo wrote a more robust solution, PR 13789, to disable opcache only in regrtest, to look for memory leaks. But INADA-san had a good argument against this approach: #13789 (comment)
"The code object will be optimized only when ++co->co_opcache_flag == opcacheminruns. So decreasing min_runs by _setopcacheminruns()will cause some hot codes will be not optimized forever. I don't want to expose such switch."
I would prefer to keep this issue until a long term approach is designed.
Please revert this and use a separate build flag (e.g. DISABLE_INLINE_CACHES) for the refleaks run. (Or perhaps provide an -X flag to disable it without the need to recompile.)
I am developing new inline cache ideas and of course I need to run in debug mode, so I regularly end up wasting some time until I remember to add a patch that changes OPCACHE_MIN_RUNS back.
(Or perhaps provide an -X flag to disable it without the need to recompile.)
Giving the ability to control the cache size, at least at Python startup, is one option.
Or maybe need a generic -X flag to tell Python that libregrtest is tracking leaks, since we might need to change other parameters than only the opcode cache size.
Giving the ability to control the cache size, at least at Python startup, is one option.
I'd really prefer not to allow users to control cache sizes. There's basically no point in that; the only practically useful thing is to enable or disable it.
Or maybe need a generic -X flag to tell Python that libregrtest is tracking leaks, since we might need to change other parameters than only the opcode cache size.
I think we should go this way, maybe even less "public". If we add a -X, then it will be too visible. Maybe some env variable?
New changeset af5fa13 by Pablo Galindo in branch 'master': bpo-37146: Deactivate opcode cache only when using huntrleaks in the test suite (GH-24643) af5fa13
Activity
vstinner commentedon Jun 3, 2019
opcode cache for LOAD_GLOBAL introduced false alarm in memory leak hunting (python3 -m test -R 3:3 ...).
=> opcache: bpo-26219.
Before the change:
After the change:
The problem is that at each iteration of regrtest -R 3:3 (6 iterations), a few more code objects get this opcache allocated.
There are different solutions to fix regrtest -R 3:3.
(*) Always optimize:
(*) Never optimmize: disable opcache until a better fix can be found
(*) Find a way to explicitly deoptimize all code objects
Modules/gcmodule.c has a clear_freelists() function called by collect() if generation == NUM_GENERATIONS-1: on when gc.collect() is collected explicitly for example.
Lib/test/libregrtest/refleak.py also has a dash_R_cleanup() function which clears many caches.
Problem: currently, code objects are not explicitly tracked (for example, they are not tracked in a double linked list).
(*) Add way more warmup iterations to regrtest in buildbots.
I dislike this option. A build on a refleak buildbot worker already takes 2 to 3 hours. Adding more warmup would make a build even way more slower.
vstinner commentedon Jun 3, 2019
New changeset eddef86 by Victor Stinner (Inada Naoki) in branch 'master':
bpo-37146: disable opcache when Py_DEBUG is defined (GH-13787)
eddef86
vstinner commentedon Jun 3, 2019
INADA-san wrote PR 13787 to disable opcache when Python is compiled in debug mode. Pablo and me approved the change, so I merged it.
Pablo wrote a more robust solution, PR 13789, to disable opcache only in regrtest, to look for memory leaks. But INADA-san had a good argument against this approach:
#13789 (comment)
"The code object will be optimized only when ++co->co_opcache_flag == opcacheminruns. So decreasing min_runs by _setopcacheminruns()will cause some hot codes will be not optimized forever. I don't want to expose such switch."
I would prefer to keep this issue until a long term approach is designed.
vstinner commentedon Oct 1, 2019
It seems like nobody came up with a solution for the debug mode since June. I close the issue. Reopen it if you would like to propose a solution.
1st1 commentedon Oct 1, 2019
I think the only solution is to have a flag to disable optimizations, inlcluding this one.
gvanrossum commentedon Feb 19, 2021
Please revert this and use a separate build flag (e.g. DISABLE_INLINE_CACHES) for the refleaks run. (Or perhaps provide an -X flag to disable it without the need to recompile.)
I am developing new inline cache ideas and of course I need to run in debug mode, so I regularly end up wasting some time until I remember to add a patch that changes OPCACHE_MIN_RUNS back.
vstinner commentedon Feb 19, 2021
I reopen the issue (but I'm not interested by trying to fix it).
vstinner commentedon Feb 19, 2021
Giving the ability to control the cache size, at least at Python startup, is one option.
Or maybe need a generic -X flag to tell Python that libregrtest is tracking leaks, since we might need to change other parameters than only the opcode cache size.
1st1 commentedon Feb 19, 2021
I'd really prefer not to allow users to control cache sizes. There's basically no point in that; the only practically useful thing is to enable or disable it.
pablogsal commentedon Feb 19, 2021
I think we should go this way, maybe even less "public". If we add a -X, then it will be too visible. Maybe some env variable?
webstarnantes commentedon Feb 20, 2021
dans cette version pour securité maximale
https://backlinkstrong.com/
1 remaining item
[-]opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting[/-][+]SSl Securité version 3.9.2[/+][-]SSl Securité version 3.9.2[/-][+]opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting[/+]pablogsal commentedon Feb 28, 2021
New changeset af5fa13 by Pablo Galindo in branch 'master':
bpo-37146: Deactivate opcode cache only when using huntrleaks in the test suite (GH-24643)
af5fa13
vstinner commentedon Mar 8, 2021
New changeset 9f672a5 by Victor Stinner in branch 'master':
bpo-37146: Move _PyEval_DeactivateOpCache() to the internal C API (GH-24786)
9f672a5