Improve python GC behavior
This commit is contained in:
parent
e6172a68d7
commit
7adca97358
@ -7,6 +7,8 @@ import logging
|
|||||||
import sys
|
import sys
|
||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
|
|
||||||
|
from freqtrade.util.gc_setup import gc_set_threshold
|
||||||
|
|
||||||
|
|
||||||
# check min. python version
|
# check min. python version
|
||||||
if sys.version_info < (3, 8): # pragma: no cover
|
if sys.version_info < (3, 8): # pragma: no cover
|
||||||
@ -36,6 +38,7 @@ def main(sysargv: List[str] = None) -> None:
|
|||||||
# Call subcommand.
|
# Call subcommand.
|
||||||
if 'func' in args:
|
if 'func' in args:
|
||||||
logger.info(f'freqtrade {__version__}')
|
logger.info(f'freqtrade {__version__}')
|
||||||
|
gc_set_threshold()
|
||||||
return_code = args['func'](args)
|
return_code = args['func'](args)
|
||||||
else:
|
else:
|
||||||
# No subcommand was issued.
|
# No subcommand was issued.
|
||||||
|
18
freqtrade/util/gc_setup.py
Normal file
18
freqtrade/util/gc_setup.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import gc
|
||||||
|
import logging
|
||||||
|
import platform
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def gc_set_threshold():
|
||||||
|
"""
|
||||||
|
Reduce number of GC runs to improve performance (explanation video)
|
||||||
|
https://www.youtube.com/watch?v=p4Sn6UcFTOU
|
||||||
|
|
||||||
|
"""
|
||||||
|
if platform.python_implementation() == "CPython":
|
||||||
|
# allocs, g1, g2 = gc.get_threshold()
|
||||||
|
gc.set_threshold(50_000, 500, 1000)
|
||||||
|
logger.debug("Adjusting python allocations to reduce GC runs")
|
Loading…
Reference in New Issue
Block a user