New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lots of unnecessary cpu wakeups #81

Closed
doy opened this Issue Mar 21, 2014 · 6 comments

Comments

Projects
None yet
4 participants
@doy
Copy link

doy commented Mar 21, 2014

It seems that when offlineimap is sleeping between syncs, it's being woken up every 50ms for some reason (strace shows repeated select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout) lines). This is not great for battery usage. I traced this down to the implementation of Condition.wait in python2's threading.py module (the equivalent code in python3 doesn't appear to have this problem, although I didn't look too deeply, and I'm not incredibly familiar with python). I'm not sure what offlineimap is using this method for, but it'd be nice if it could find a way to do it that didn't require polling with such a short interval.

@nicolas33 nicolas33 added this to the undefined milestone Jan 9, 2015

@spaetz

This comment has been minimized.

Copy link
Member

spaetz commented Mar 23, 2015

Yes, at least in python2, that is a problem. The thing is, that our main thread needs to be able to be interrupted by signals such as Ctrl-C.

This is function threadutils.py:exitnotifymonitorloop
As described in the comment, we need a timeout in that .get() call or Ctrl-C will never be catched (and we could potentially freeze forever without timeout). http://bugs.python.org/issue1360
On the other hand, a timeout will cause Python to wake up repeatedly (every 50ms if I remember correctly). I think it won't wake up if no timeout was specified.

Apparently this was fixed in python 3.2 so, we might be able to improve this in a Python3 world.

@nicolas33

This comment has been minimized.

Copy link
Member

nicolas33 commented Mar 23, 2015

Thank you much for your input spaetz!

@doy
Could you test https://github.com/nicolas33/offlineimap/tree/bug/81/cpu-wakeups please?

This is a hugly hack I wouldn't expect to solve all issues while it could effectively improve things a bit.

EDIT: forgot to say that if I get positive feedback soon, I'll merge it for the next stable I intend before April.

@nicolas33

This comment has been minimized.

Copy link
Member

nicolas33 commented Apr 6, 2015

Got negative feedbacks in the mailing list. There are other offenders in the best case and it doesn't address the issue at all in the worse case. Discarding above patch.

@dolohow

This comment has been minimized.

Copy link
Member

dolohow commented May 25, 2016

I can confirm that using Python3 solves the problem entirely. As Python3 support is on the way I would rather close this issue or add some new label.

@nicolas33

This comment has been minimized.

Copy link
Member

nicolas33 commented May 25, 2016

Will close with Py3 support.

nicolas33 added a commit that referenced this issue Jun 3, 2016

allow to run under python3 without special env
Github-Fix: #81 #81
Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
@nicolas33

This comment has been minimized.

Copy link
Member

nicolas33 commented Jun 4, 2016

Fixed in 1894a8f.
The fix is only valid when using Python 3, though.

@nicolas33 nicolas33 closed this Jun 4, 2016

@nicolas33 nicolas33 added wontfix and removed need contributor! labels Jun 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment