Feature #66

number of cpu wakeups per second

Added by Thomas Haider 171 days ago. Updated 67 days ago.

Status :Closed Start :04/23/2008
Priority :Normal Due date :
Assigned to :- % Done :

100%

Category :Maildir
Target version :5.99.11
Resolution :


Description

While testing my system with powertop (http://www.lesswatts.org/) i noticed that offlineimap is responsible for nearly 50% of the cpu wakeups on my system. A reduction in this number would allow the cpu to stay longer in powersaving mode which in turn reduces power consumption.

Associated revisions

Revision 2a852a8f484cdaa8712d203262c26b33057143fb
Added by John Goerzen 69 days ago

Rework keepalive to use time.sleep() instead of event.wait()

This should improve power-management abilities some more

The catch is that we can't wait any longer for the kathread to
terminate. We were waiting for this in some cases. This is probably
not a big deal.

fixes deb#434074
fixes #66

Revision 8114877fae2003a2d305a7a264c43b8553675a05
Added by John Goerzen 70 days ago

Rework threadutil to use Queue for simplification and power-friendliness

Removes code and should avoid weird Python situation that causes cpu
wakeups

fixes deb#434074
fixes #66

History

04/28/2008 03:50 AM - The Omega

I would also appreciate a solution for this as offlineimap uses more than 1 Watt on my machine. Although I configured offlineimap to use a refresh period of 1 minute it wakes up 25 times PER SECOND!!!.

07/29/2008 07:48 AM - Martin Hicks

I was at Linux Symposium in Ottawa last week, and they were giving out lesswatts.org t-shirts. I think this
probably got me to think about running powertop on my laptop too. offlineimap was right at the top, all of
the time.

I started investigating, and finally came up with it last night. The problem is
the exitcondition.wait(1) in threadutil.py::exitnotifymonitorloop().

In my opinion, the python library is just dumb. They should allow some configurability
about how often you want to wake up. Here's the root problem (threading.py::Condition()):

def wait(self, timeout=None):                                                                                                                        
[...snip...]
try: # restore state no matter what (e.g., KeyboardInterrupt)
if timeout is None:
waiter.acquire()
if debug:
self._note("%s.wait(): got it", self)
else: # Balancing act: We can't afford a pure busy loop, so we # have to sleep; but if we sleep the whole timeout time, # we'll be unresponsive. The scheme here sleeps very # little at first, longer as time goes on, but never longer # than 20 times per second (or the timeout time remaining).

mh

08/02/2008 03:36 PM - John Goerzen

  • Status changed from New to Feedback
  • Category changed from Other to Maildir

Thanks for tracking this down! I believe the patch above should fix it for you. Please test and let me know.

08/02/2008 09:26 PM - John Goerzen

  • % Done changed from 0 to 100
  • Status changed from Feedback to Closed

08/05/2008 10:35 AM - Martin Hicks

Terrific. Works fine for me. Thanks for providing a patch.

Also available in: Atom PDF