Skip to content

Commit ab170c8

Browse files
perf: revert preload.
1 parent 792d32d commit ab170c8

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

apps/maxkb/settings/mem.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,16 @@
44
import threading
55
from maxkb.const import CONFIG
66
from common.utils.logger import maxkb_logger
7+
import random
78

89
CURRENT_PID=os.getpid()
9-
GC_THRESHOLD = (100, 5, 5)
1010
# 1 hour
1111
GC_INTERVAL = 3600
1212

13-
def change_gc_threshold():
14-
old_threshold = gc.get_threshold()
15-
gc.set_threshold(*GC_THRESHOLD)
16-
maxkb_logger.debug(f"(PID: {CURRENT_PID}) GC thresholds changed from {old_threshold}{GC_THRESHOLD}")
17-
1813
def force_gc():
1914
collected = gc.collect()
2015
maxkb_logger.debug(f"(PID: {CURRENT_PID}) Forced GC ({collected} objects collected)")
21-
threading.Timer(GC_INTERVAL, force_gc).start()
22-
23-
def init_memory_optimization():
24-
change_gc_threshold()
25-
force_gc()
26-
maxkb_logger.debug("(PID: {CURRENT_PID}) Memory optimization (GC tuning) started.")
16+
threading.Timer(GC_INTERVAL - random.randint(0, 900, force_gc).start()
2717

2818
if CONFIG.get("ENABLE_MEMORY_OPTIMIZATION", '1') == "1":
29-
init_memory_optimization()
19+
threading.Timer(GC_INTERVAL - random.randint(0, 900), force_gc).start()

0 commit comments

Comments
 (0)