Skip to content
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

CPU usage leak #379

Closed
DavidMikeSimon opened this issue Mar 5, 2014 · 14 comments
Closed

CPU usage leak #379

DavidMikeSimon opened this issue Mar 5, 2014 · 14 comments

Comments

@DavidMikeSimon
Copy link

Running qtile master. Over a timespan of about 24 hours, qtile's CPU usage rises from trivially low to nearly 100%. In the worst stages, qtile is non-responsive to keyboard shortcuts, forcing me to kill it externally.

@tych0
Copy link
Member

tych0 commented Mar 5, 2014

I think this should be fixed in the latest development branch. Can you try
that and see if it fixes your problem?
On Mar 5, 2014 9:33 AM, "David Simon" notifications@github.com wrote:

Running qtile master. Over a timespan of about 24 hours, qtile's CPU usage
rises from trivially low to nearly 100%. In the worst stages, qtile is
non-responsive to keyboard shortcuts, forcing me to kill it externally.

Reply to this email directly or view it on GitHubhttps://github.com//issues/379
.

@DavidMikeSimon
Copy link
Author

Sorry, meant to say in the beginning that I was running on develop branch. :-)

@tych0
Copy link
Member

tych0 commented Mar 5, 2014

Ok, what widgets are you using?
On Mar 5, 2014 10:14 AM, "David Simon" notifications@github.com wrote:

Sorry, meant to say in the beginning that I was running on develop branch.
:-)

Reply to this email directly or view it on GitHubhttps://github.com//issues/379#issuecomment-36774249
.

@DavidMikeSimon
Copy link
Author

##-> Screens
screens = [
    Screen(
        top=bar.Bar(widgets=[
            widget.GroupBox(**Theme.groupbox),
            widget.Prompt(),
            widget.WindowName(**Theme.widget),

            widget.CPUGraph(graph_color='18BAEB', fill_color='1667EB.3', **Theme.graph),
            widget.MemoryGraph(graph_color='00FE81', fill_color='00B25B.3', **Theme.graph),

            #widget.CurrentLayout(**Theme.widget),
            widget.Systray(**Theme.systray),
            #widget.Sep(**Theme.sep),
            widget.BatteryIcon(**Theme.battery),
            widget.Battery(**Theme.battery_text),
            #widget.Sep(**Theme.sep),
            widget.Volume(theme_path='/usr/share/icons/Humanity-Dark/status/24/', **Theme.widget),
            widget.Clock(fmt='%a %d %b %I:%M %p', **Theme.widget),
            ], **Theme.bar),
    ),
    Screen(
        top=bar.Bar(widgets=[
            widget.GroupBox(**Theme.groupbox),
            widget.WindowName(**Theme.widget),
            #widget.CurrentLayout(**Theme.widget),
        ], **Theme.bar),
    )
]

@DavidMikeSimon
Copy link
Author

@tych0 Any thoughts on which widget might be causing the leak? I can just start removing them in a binary-search pattern to narrow it down, but since it takes several hours for the leak to be noticeable, that could take a while without a hint.

@DavidMikeSimon
Copy link
Author

I've disabled the graph and battery indicator widgets, and the leak seems to be gone. I'll try re-enabling the battery indicator and seeing what happens.

@DavidMikeSimon
Copy link
Author

@tych0 Still leaks with only the battery indicator (i.e. not the graph) enabled. I'll leave them both off again and see if that confirms the problem.

@cjbarnes18
Copy link
Contributor

Hi David,

Which Battery indicator are you using, text, icon or both?

I use Text and have not noticed any memory issues with it.

On 18 March 2014 12:18, David Simon notifications@github.com wrote:

@tych0 https://github.com/tych0 Still leaks with only the battery
indicator (i.e. not the graph) enabled. I'll leave them both off again and
see if that confirms the problem.


Reply to this email directly or view it on GitHubhttps://github.com//issues/379#issuecomment-37926022
.

Craig

@DavidMikeSimon
Copy link
Author

I was using both. I've verified that there is no leak when they're both disabled. I'll try just enabling the icon one.

@tych0
Copy link
Member

tych0 commented Mar 19, 2014

Hi David,

On Wed, Mar 19, 2014 at 06:26:32AM -0700, David Simon wrote:

I was using both. I've verified that there is no leak when they're both disabled. I'll try just enabling the icon one.

Thanks, that would be great. Both icons are using code that is fairly
fundamental to qtile, so if there is a leak there, we're leaking
everywhere and it would be good to fix :-).

\t

@DavidMikeSimon
Copy link
Author

@tych0 I have verified that the leak occurs even if only the icon indicator is enabled, though it is a significantly slower leak.

There's got to be a better way to instrument this. :-| What profiler tool for Python is useful for this sort of thing?

@CharString
Copy link
Contributor

I'm running on the v0.7.0 tag and both widget.Volume and widget.Battery use lots of CPU.

@DavidMikeSimon you can run qtile with

python -m cProfile -o /some/file.profile qtile

And after you stop qtile, you can inspect /some/file.profile with RunSnakeRun (or KCachegrind, but I have a KDE aversion).

@blotus
Copy link

blotus commented Apr 15, 2014

I also had this problem with the text Battery widget. Qtile was trying to open a non-existent file to get the battery status (only a snippet of strace output, it will try to open each file more than 80 times):

13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)
13:39:58 open("/sys/class/power_supply/BAT0/charge_now", O_RDONLY) = -1 ENOENT (No such file or directory)

Setting battery_name to BAT1 at the widget creation fixed it for me.
I'm not familiar enough with qtile widget system to pinpoint the problem, but it seems that some widget are called way too often, regardless of the update_interval value, and depending on what the widget does, it might uses large amount of CPU.

@dequis
Copy link
Member

dequis commented Aug 9, 2014

Fix! #472

@dequis dequis closed this as completed in c0a29c7 Aug 9, 2014
tych0 pushed a commit to tych0/qtile that referenced this issue Aug 11, 2014
Failing to find a valid file for the battery widget files means it will
retry later for no good reason - and each of those attempts will modify
the global BATTERY_INFO_FILES list, adding one filename at the beginning

The fix is simple, just make a copy of that list before modifying, and
additionally set a "negative cache" of filenames to avoid repeating

Thanks DavidMikeSimon for reducing this bug to this widget,
and blotus for pointing at the file open errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants