-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Taskwarrior-tui uses a lot of CPU time when idle. #122
Comments
Thanks for reporting @desbma. I'm aware of this issue. It is related to this issue: #46 I believe the issue isn't the UI tick rate, but it is the polling for keyboard input in the background thread, which is currently between 5ms to 10ms. If you change these lines to 250ms your CPU consumption is going to decrease. You can try to build from source to test this: Lines 89 to 91 in 3ad7c46
However increasing the tick rate causes the race condition described the issue in #46. In this comment on that thread, I describe exactly what I think is going on: #46 (comment) This comment is where @donbex tested it with the current timing for the polling: #46 (comment) I'd happily accept PRs or changes or even just suggestions on how to solve it. I'm open to using any paradigm (e.g. Alternatively, I can make that a configuration option. If I do that, this problem will be much more easily resolved (albeit in a hacky way). |
I tried changing as you suggested with this patch:
then recompiling with |
That's odd. I thought that'd be the issue. Can you try increasing the tick_rate duration here: Line 75 in 3ad7c46
How many tasks do you have in your task list? I have about 30 or so tasks in my task list. This screenshot above is htop and taskwarrior-tui running in two different panes. The CPU usage of the taskwarrior-tui process is about 3.1%. At the top of the pane I have iTerm2 monitoring the CPU of the computer which is around 10%. I'm running the latest master with no changes for this screenshot. |
That is not to say that there aren't memory / CPU performance issues that need to be taken care of here. I'm happy to include any patch that you think will improve performance. I'm just a little surprised that htop is not showing the performance you are seeing with |
I'm also seeing similarly high numbers with
Any idea why htop is not reporting similarly high numbers? |
Around 100-150 depending on how you count.
This is not measuring the overhead of all the short lived Changing the tick rate to 1s instead of 250ms as you last suggested improves the CPU usage as expected, but it's still about 10% of usage which is way too high for a program that is idle. It should be negligible (<1%). I will see if I can work something out to improve it. |
Can we imagine a 1 minute tick auto refresh + a refresh on keypress and inotify events - write/update on the task database files? |
In the latest |
Ok nice, I realize I don't use the master on the computer where I spot it consume much. It is nice on the master. :-) |
I'm closing this since the CPU usage is now reasonable for me. |
I made a new release that addresses this issue: https://github.com/kdheepak/taskwarrior-tui/releases/tag/v0.11.0 |
taskwarrior-tui
uses a lot of CPU time when idle.By a lot I don't mean 4 cores at 100%, but still a significant amount (some numbers below), which is not expected for a program completely idle.
I care because I typically have a terminal open with taskwarrior-tui always running, and for example I want to avoid draining my laptop battery.
Here we have measured an approximation of the CPU consumed on startup, and when taskwarrior is idle for 60s (no keyboard interaction).
During 1 minute of runtime, we have consumed about 27.5s of CPU time, close to 50% CPU utilization of a single core, which is huge for a program doing mostly nothing.
Possible ideas to improve CPU usage (I have only looked very briefly at the code):
TTApp::update
to reduce the number oftask
invocations when nothing has changed. For example if~/.taskrc
has not changed, there is not need to query the columns for thenext
report everytime.@kdheepak If you agree I can help contribute some code for the second point.
The text was updated successfully, but these errors were encountered: