From 3ad6206363389421c7860898cb3fdca8403a6bf6 Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Tue, 6 Sep 2016 09:47:56 +0000 Subject: [PATCH] =?UTF-8?q?Bug=201458=20-=20la=20page=20clusterstatus=20ne?= =?UTF-8?q?=20r=C3=A9pond=20plus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - drastically improved the performance of JobsState.AddJob call (used for example in clusterstatus page) in case of big job arrays. As an example : clusterstatus page took 30 seconds when there was a job array of 500 elements ; this now takes 3 seconds. The culprit was a conflicting hash (I don't remember why I didn't make a non conflicting hash in the first place), that was the same for each job array element. --- ClusterController/Job.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ClusterController/Job.py b/ClusterController/Job.py index 7b16064..fa69d70 100644 --- a/ClusterController/Job.py +++ b/ClusterController/Job.py @@ -27,7 +27,9 @@ class JobId: A single integer is no longer enough to identify a job because all elements in a job array share the same sge job identifier. To uniquely define a job array element, we also use the task id. """ + MAX_NUM_JOBS_IN_ARRAY = 1000000 def __init__( self, iJobId, iJobArrayElementId = None): + assert iJobArrayElementId <= self.MAX_NUM_JOBS_IN_ARRAY self.m_iJobId = iJobId self.m_iJobArrayElementId = iJobArrayElementId # None if this identifier does not refer to a job array element @@ -35,7 +37,10 @@ class JobId: """ required to use a JobId as a dict hash key """ - return self.m_iJobId # very simple hashing that conflicts only for job array elements + hash = self.m_iJobId * self.MAX_NUM_JOBS_IN_ARRAY + if self.m_iJobArrayElementId is not None: + hash += self.m_iJobArrayElementId + return hash def __eq__( self, other ): """