More refined time tracing. It seems the AMP connection is really the bottleneck.

This commit is contained in:
Griatch 2015-09-17 22:39:48 +02:00
parent d02b781be1
commit 018250e4e5
4 changed files with 16 additions and 4 deletions

View file

@ -355,6 +355,17 @@ class AMPProtocol(amp.AMP):
as batch parts get sent (or fails). as batch parts get sent (or fails).
""" """
now = time()
batch = dumps([(sessid, kwargs)])
hashid = "%s-%s" % (id(batch), now)
deferreds = [self.callRemote(command,
hashid=hashid,
data=batch,
ipart=0,
nparts=1).addErrback(self.errback, command.key)]
return deferreds
global _SENDBATCH global _SENDBATCH
if command: if command:
@ -472,6 +483,8 @@ class AMPProtocol(amp.AMP):
batch = self.batch_recv(hashid, data, ipart, nparts) batch = self.batch_recv(hashid, data, ipart, nparts)
for (sessid, kwargs) in batch: for (sessid, kwargs) in batch:
#print "msg portal -> server (server side):", sessid, msg, loads(ret["data"]) #print "msg portal -> server (server side):", sessid, msg, loads(ret["data"])
from evennia.server.profiling.timetrace import timetrace
kwargs["msg"] = timetrace(kwargs["msg"], "AMP.amp_msg_portal2server")
self.factory.server.sessions.data_in(sessid, self.factory.server.sessions.data_in(sessid,
text=kwargs["msg"], text=kwargs["msg"],
data=kwargs["data"]) data=kwargs["data"])
@ -496,7 +509,7 @@ class AMPProtocol(amp.AMP):
msg = timetrace(msg, "AMP.call_remote_MsgPortal2Server") msg = timetrace(msg, "AMP.call_remote_MsgPortal2Server")
return self.batch_send(MsgPortal2Server, sessid, return self.batch_send(MsgPortal2Server, sessid,
msg=msg if msg is not None else "", msg=msg if msg is not None else "",
data=data) data=data, force_send=True)
# Server -> Portal message # Server -> Portal message

View file

@ -163,7 +163,6 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
parsed data directly to self.data_in. parsed data directly to self.data_in.
""" """
if data and data[0] == IAC or self.iaw_mode: if data and data[0] == IAC or self.iaw_mode:
try: try:
#print "IAC mode" #print "IAC mode"

View file

@ -29,7 +29,7 @@ def timetrace(message, idstring, tracemessage="TEST_MESSAGE", final=False):
else: else:
t1 = time() t1 = time()
# print to log (important!) # print to log (important!)
print "timetrace (%s): dT=%fs, total=%fs." % (idstring, t1-tlast, t1-t0) print "** timetrace (%s): dT=%fs, total=%fs." % (idstring, t1-tlast, t1-t0)
if final: if final:
message = "%s (total %f)" % (tracemessage, t1-t0) message = "%s (total %f)" % (tracemessage, t1-t0)

View file

@ -602,7 +602,7 @@ class ServerSessionHandler(SessionHandler):
""" """
from evennia.server.profiling.timetrace import timetrace from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "ServerSession.data_in") text = timetrace(text, "ServerSessionHandler.data_in")
session = self.sessions.get(sessid, None) session = self.sessions.get(sessid, None)
if session: if session:
text = text and to_unicode(strip_control_sequences(text), encoding=session.encoding) text = text and to_unicode(strip_control_sequences(text), encoding=session.encoding)