perf: Freeze GC right before starting background worker
BG worker forks are not CoW friendly. Freezing right before we start worker should lessen overall memory usage. Though this isn't useful much because at max you're sharing with 2 processes - master and horse. WorkerPool can improve this benefit a lot by forking each worker from master process and horse from forked processes. TBD when WorkerPool is out of beta.
This commit is contained in:
parent
fbe3174914
commit
29d28a460f
1 changed files with 4 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import gc
|
||||
import os
|
||||
import socket
|
||||
import time
|
||||
|
|
@ -234,6 +235,9 @@ def start_worker(
|
|||
"""Wrapper to start rq worker. Connects to redis and monitors these queues."""
|
||||
DEQUEUE_STRATEGIES = {"round_robin": RoundRobinWorker, "random": RandomWorker}
|
||||
|
||||
if frappe._tune_gc:
|
||||
gc.freeze()
|
||||
|
||||
with frappe.init_site():
|
||||
# empty init is required to get redis_queue from common_site_config.json
|
||||
redis_connection = get_redis_conn(username=rq_username, password=rq_password)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue