This change stops sleekxmpp from spending huge amounts of time unnecessarily computing logging data that may never be used. This is a HUGE performance improvement; in some of my test runs, unnecessary string creation was accounting for > 60% of all CPU time.
Note that using % in a string will _always_ perform the sting substitutions, because the strings are constructed before the function is called. So log.debug('%s' % expensiveoperation()) will take about the same CPU time whether or not the logging level is DEBUG or INFO. if you use , no substitutions are performed unless the string is actually logged
This commit is contained in:

committed by
Lance Stout

parent
1baf139ca4
commit
deb52ad350
@@ -42,7 +42,7 @@ class feature_bind(base_plugin):
|
||||
Arguments:
|
||||
features -- The stream features stanza.
|
||||
"""
|
||||
log.debug("Requesting resource: %s" % self.xmpp.boundjid.resource)
|
||||
log.debug("Requesting resource: %s" , self.xmpp.boundjid.resource)
|
||||
iq = self.xmpp.Iq()
|
||||
iq['type'] = 'set'
|
||||
iq.enable('bind')
|
||||
@@ -55,7 +55,7 @@ class feature_bind(base_plugin):
|
||||
|
||||
self.xmpp.features.add('bind')
|
||||
|
||||
log.info("Node set to: %s" % self.xmpp.boundjid.full)
|
||||
log.info("Node set to: %s" , self.xmpp.boundjid.full)
|
||||
|
||||
if 'session' not in features['features']:
|
||||
log.debug("Established Session")
|
||||
|
@@ -123,7 +123,7 @@ class feature_mechanisms(base_plugin):
|
||||
|
||||
def _handle_fail(self, stanza):
|
||||
"""SASL authentication failed. Disconnect and shutdown."""
|
||||
log.info("Authentication failed: %s" % stanza['condition'])
|
||||
log.info("Authentication failed: %s" , stanza['condition'])
|
||||
self.xmpp.event("failed_auth", stanza, direct=True)
|
||||
self.xmpp.disconnect()
|
||||
return True
|
||||
|
Reference in New Issue
Block a user