<div dir="ltr">Hi again, I got some interesting new information<br><div><div><div class="gmail_extra"><br><div class="gmail_quote">2015-03-23 17:20 GMT+01:00 Alvaro Gamez <span dir="ltr"><<a href="mailto:alvaro.gamez@hazent.com" target="_blank">alvaro.gamez@hazent.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> --- modulename: threading, funcname: wait<br><br><div><div class="gmail_extra">threading.py(235): print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ", timeout<br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX None<br>threading.py(236): if not self._is_owned():<br> --- modulename: threading, funcname: _is_owned<br>threading.py(228): if self.__lock.acquire(0):<br>threading.py(232): return True<br>threading.py(238): waiter = _allocate_lock()<br>threading.py(239): waiter.acquire()<br>threading.py(240): self.__waiters.append(waiter)<br>threading.py(241): saved_state = self._release_save()<br> --- modulename: threading, funcname: _release_save<br>threading.py(220): self.__lock.release() # No state to save<br>threading.py(242): try: # restore state no matter what (e.g., KeyboardInterrupt)<br>threading.py(243): if timeout is None: <br>threading.py(244): waiter.acquire()<br>threading.py(255): while True:<br>threading.py(256): gotit = waiter.acquire(0)<br>threading.py(257): if gotit:<br>threading.py(259): remaining = endtime - _time()<br>threading.py(260): if remaining <= 0:<br>threading.py(262): delay = min(delay * 2, remaining, .05)<br>threading.py(263): _sleep(delay)<br><br></div></div></div></blockquote><div><br></div><div>After placing some more XXX and the like lines (as I told I'm not experiencied with python, I'm sure there's a better way to do this), it seems that I've triggered some optimizations out that provide me a more complete trace.<br><br>threading.py(258): print "ZZZZZZZZZZZZZZZZZZZZZZZZZ ", timeout<br>ZZZZZZZZZZZZZZZZZZZZZZZZZ 1740<br><br></div></div>That threading invocation with a timeout of 1740 matches the value of 29minutes*60seconds of keepalive parameter.<br><br></div><div class="gmail_extra">I've applied attached patch to allow a keepalive time of 0 seconds (which internally equates to an infinite wait) and now CPU consumption is 0 and no wakeups are notified by powertop, so I think this is definitely the thing that is making offlineimap consume CPU while IDLING.<br><br></div><div class="gmail_extra">Of course attached patch is not a solution, because that 29 minutes is a recommendation of the RFC for IDLE connections, so this is a timeout that should definitely exist, and the one to blame here is Event.wait().<br><br></div><div class="gmail_extra">Best regards<br><br>diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py<br>index 68c8e33..c2c279b 100644<br>--- a/offlineimap/repository/IMAP.py<br>+++ b/offlineimap/repository/IMAP.py<br>@@ -72,7 +72,7 @@ class IMAPRepository(BaseRepository):<br> return self.getconfboolean("holdconnectionopen", 0)<br> <br> def getkeepalive(self):<br>- num = self.getconfint("keepalive", 0)<br>+ return self.getconfint("keepalive", 0)<br> if num == 0 and self.getidlefolders():<br> return 29*60<br> else:<br><br></div><div class="gmail_extra">-- <br><div>Álvaro Gámez Machado<br></div>
</div></div></div></div>