mirror of
https://opendev.org/x/pyghmi
synced 2025-01-28 20:07:42 +00:00
Move packet queue into IO thread
The packet queue assembly in consumer threads made up a lot of thrashing and overhead. Moving this into the IO thread saves about 25% of the CPU overhead associated with 100 consumer threads. Change-Id: I44ba6888a68f58297469e0630c24c12d9246c706
This commit is contained in:
parent
a32f1080b1
commit
af02266b0b
@ -143,6 +143,9 @@ def define_worker():
|
||||
return _IOWorker
|
||||
|
||||
|
||||
pktqueue = collections.deque([])
|
||||
|
||||
|
||||
def _io_apply(function, args):
|
||||
global selectbreak
|
||||
evt = threading.Event()
|
||||
@ -163,6 +166,16 @@ def _io_sendto(mysocket, packet, sockaddr):
|
||||
pass
|
||||
|
||||
|
||||
def _io_graball(mysockets):
|
||||
for mysocket in mysockets:
|
||||
while True:
|
||||
rdata = _io_recvfrom(mysocket, 3000)
|
||||
if rdata is None:
|
||||
break
|
||||
rdata = rdata + (mysocket,)
|
||||
pktqueue.append(rdata)
|
||||
|
||||
|
||||
def _io_recvfrom(mysocket, size):
|
||||
mysocket.setblocking(0)
|
||||
ignoresockets.discard(mysocket)
|
||||
@ -261,7 +274,6 @@ class Session(object):
|
||||
keepalive_sessions = {}
|
||||
peeraddr_to_nodes = {}
|
||||
iterwaiters = []
|
||||
pktqueue = collections.deque([])
|
||||
#NOTE(jbjohnso):
|
||||
#socketpool is a mapping of sockets to usage count
|
||||
socketpool = {}
|
||||
@ -909,16 +921,6 @@ class Session(object):
|
||||
self._initsession()
|
||||
self._get_channel_auth_cap()
|
||||
|
||||
@classmethod
|
||||
def pulltoqueue(cls, mysockets, queue):
|
||||
for mysocket in mysockets:
|
||||
while True:
|
||||
rdata = _io_apply(_io_recvfrom, (mysocket, 3000))
|
||||
if rdata is None:
|
||||
break
|
||||
rdata = rdata + (mysocket,)
|
||||
queue.append(rdata)
|
||||
|
||||
@classmethod
|
||||
def wait_for_rsp(cls, timeout=None, callout=True):
|
||||
"""IPMI Session Event loop iteration
|
||||
@ -978,11 +980,11 @@ class Session(object):
|
||||
if timeout is None:
|
||||
return 0
|
||||
if _poller(timeout=timeout):
|
||||
cls.pulltoqueue(iosockets, cls.pktqueue)
|
||||
while len(cls.pktqueue):
|
||||
(data, sockaddr, mysocket) = cls.pktqueue.popleft()
|
||||
_io_apply(_io_graball, (iosockets, ))
|
||||
while len(pktqueue):
|
||||
(data, sockaddr, mysocket) = pktqueue.popleft()
|
||||
cls._route_ipmiresponse(sockaddr, data, mysocket)
|
||||
cls.pulltoqueue(iosockets, cls.pktqueue)
|
||||
_io_apply(_io_graball, (iosockets, ))
|
||||
sessionstodel = []
|
||||
sessionstokeepalive = []
|
||||
for session, parms in cls.keepalive_sessions.iteritems():
|
||||
|
Loading…
x
Reference in New Issue
Block a user