Yeela Kaplan has uploaded a new change for review. Change subject: oop: Use a single instance of IOProcess per SD ......................................................................
oop: Use a single instance of IOProcess per SD Next step after switching from RFH to IOPROC is to use a single IOProcess instance for each SD. Currently only a single IOProcess instance is used for all SDs. To avoid load on the system by holding many unused IOProcesses we will maintain dictionary: KEY - domainID, VALUE - (timestamp, IOPROC) When IOProc for domainID is used we will renew the timestamp, or delete the item from dictionary We will also maintain another dictionary: KEY - domainID, VALUE - IOPROC weakref, that will allow us to check if IOPROC obj is still alive or needs to be recreated. Change-Id: I383fe617ee4ce22de368ba54f980887d70ff37c5 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1126206 Signed-off-by: Yeela Kaplan <[email protected]> --- M lib/vdsm/config.py.in M vdsm/storage/outOfProcess.py 2 files changed, 36 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/31501/1 diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in index 69185e0..518d3ff 100644 --- a/lib/vdsm/config.py.in +++ b/lib/vdsm/config.py.in @@ -319,6 +319,8 @@ ('process_pool_timeout', '60', None), + ('ioprocess_timeout', '60', 'TTL of IOProcess that is not renewed'), + ('process_pool_max_slots_per_domain', '10', None), ('iscsi_default_ifaces', 'default', diff --git a/vdsm/storage/outOfProcess.py b/vdsm/storage/outOfProcess.py index 6230fad..e5c82af 100644 --- a/vdsm/storage/outOfProcess.py +++ b/vdsm/storage/outOfProcess.py @@ -24,6 +24,8 @@ import stat import sys import types +import time +import weakref from vdsm import constants from vdsm.config import config @@ -45,10 +47,13 @@ _oopImpl = RFH DEFAULT_TIMEOUT = config.getint("irs", "process_pool_timeout") +DEF_IOPROC_TIMEOUT = config.getint("irs", "ioprocess_timeout") HELPERS_PER_DOMAIN = config.getint("irs", "process_pool_max_slots_per_domain") -_procLock = threading.Lock() -_proc = {} +_procPoolLock = threading.Lock() +_procPool = {} +_refProcPool = {} +_rfhPool = {} log = logging.getLogger('oop') @@ -63,18 +68,38 @@ def getProcessPool(clientName): try: - return _proc[clientName] + if _oopImpl == IOPROC: + with _procPoolLock: + keys = sorted(_procPool, key=_procPool.get) + for k in keys: + if (time.time() - _procPool[k][0]) > DEF_IOPROC_TIMEOUT: + del _procPool[k] + else: + break + + procref = _refProcPool[clientName] + proc = procref() + if proc is None: + raise KeyError + else: + _procPool[clientName] = (time.time(), proc) + return proc + else: + return _rfhPool[clientName] except KeyError: - with _procLock: + with _procPoolLock: if _oopImpl == IOPROC: - if GLOBAL not in _proc: - _proc[GLOBAL] = _OopWrapper(IOProcess(DEFAULT_TIMEOUT)) - _proc[clientName] = _proc[GLOBAL] + proc = _OopWrapper(IOProcess(DEFAULT_TIMEOUT)) + _procPool[clientName] = (time.time(), proc) + _refProcPool[clientName] = weakref.ref(proc) + procref = _refProcPool[clientName] + + return procref() else: - _proc[clientName] = _OopWrapper( + _rfhPool[clientName] = _OopWrapper( RemoteFileHandlerPool(HELPERS_PER_DOMAIN)) - return _proc[clientName] + return _rfhPool[clientName] def getGlobalProcPool(): -- To view, visit http://gerrit.ovirt.org/31501 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I383fe617ee4ce22de368ba54f980887d70ff37c5 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yeela Kaplan <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
