summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@hp.com>2014-12-17 08:52:06 -0800
committerJames E. Blair <jeblair@hp.com>2014-12-17 08:52:06 -0800
commitd5e03ac9307c9cc6f79fc22f15e177d3662dc936 (patch)
treeaf05aef54cef00296a8076ab6ca5a11aa57c8dc0
parent0f24beb72b340628a564ce8d755341eca70a4c40 (diff)
downloadgear-d5e03ac9307c9cc6f79fc22f15e177d3662dc936.tar.gz
Only wake relevant connections
As a performance improvement, on job submission, only wake connections that handle that job. Also, when a connection sends SLEEP, if there is a pending job it can handle, only wake that connection. Change-Id: Iff7cd28a7534f24ad4ea96c8f3ad55324e0237e2
-rw-r--r--gear/__init__.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/gear/__init__.py b/gear/__init__.py
index 1a182de..eb7cb9e 100644
--- a/gear/__init__.py
+++ b/gear/__init__.py
@@ -2859,12 +2859,19 @@ class Server(BaseClientServer):
.encode('utf8'))
request.connection.sendRaw(b'.\n')
- def wakeConnections(self):
+ def wakeConnection(self, connection):
+ p = Packet(constants.RES, constants.NOOP, b'')
+ if connection.state == 'SLEEP':
+ connection.changeState("AWAKE")
+ connection.sendPacket(p)
+
+ def wakeConnections(self, job=None):
p = Packet(constants.RES, constants.NOOP, b'')
for connection in self.active_connections:
if connection.state == 'SLEEP':
- connection.changeState("AWAKE")
- connection.sendPacket(p)
+ if job and job.name in connection.functions:
+ connection.changeState("AWAKE")
+ connection.sendPacket(p)
def reportTimingStats(self, ptype, duration):
"""Report processing times by packet type
@@ -2949,7 +2956,7 @@ class Server(BaseClientServer):
elif precedence == PRECEDENCE_LOW:
self.low_queue.append(job)
self._updateStats()
- self.wakeConnections()
+ self.wakeConnections(job)
def handleSubmitJob(self, packet):
return self._handleSubmitJob(packet, PRECEDENCE_NORMAL)
@@ -2995,7 +3002,7 @@ class Server(BaseClientServer):
def handlePreSleep(self, packet):
packet.connection.changeState("SLEEP")
if self.getJobForConnection(packet.connection, peek=True):
- self.wakeConnections()
+ self.wakeConnection(packet.connection)
def handleWorkComplete(self, packet):
self.handlePassthrough(packet, True)