Nekmo / amazon-dash

Hack your Amazon Dash to run what you want.
MIT License
828 stars 67 forks source link

High CPU usage on Raspberry Pi #84

Closed saurabhsharma001 closed 6 years ago

saurabhsharma001 commented 6 years ago

Put an x into all the boxes [ ] relevant to your issue (like this: [x])

What is the purpose of your issue?

Guideline for bug reports

You can delete this section if your report is not a bug

How to get your version: pip install

amazon-dash --version
python --version
pip --version
easy_install --version

Description

Upgraded to the latest version of Amazon Dash 1.2.0. The CPU usage is little less than previous version but still it hovers around 40-50%. I am using latest Raspbian on Raspberry Pi 3B+. The same raspberry is also running HomeAssistant.


  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  287 root      20   0   35084  31252   6472 S  70.6  3.3   5:55.02 amazon-dash
  435 homeass+  20   0  472424  88784  16560 S  60.7  9.4   2:35.33 hass
 2025 pi        20   0    8044   3220   2712 R   0.7  0.3   0:01.08 top
   66 root      20   0       0      0      0 S   0.3  0.0   0:02.35 mmcqd/0

What I Did

Upgrade from 1.1.1 to 1.2.0. The CPU usage came down about 10%.

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
saurabhsharma001 commented 6 years ago

More samples:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  287 root      20   0   35084  31252   6472 R  44.6  3.3   6:12.50 amazon-dash
  435 homeass+  20   0  472424  88752  16528 S  11.5  9.3   2:41.15 hass
 2025 pi        20   0    8044   3220   2712 R   1.0  0.3   0:01.40 top
  886 pi        20   0   11576   3704   2992 S   0.7  0.4   0:00.95 sshd
  299 avahi     20   0    6436   3116   2764 S   0.3  0.3   0:00.77 avahi-daemon
Nekmo commented 6 years ago

A CPU usage of 10% in a raspberry pi is a reasonable usage. Amazon-dash sniffs your network traffic. I have improved the filtering rules but there is not much more that can be improved.

A raspberry pi has a very limited hardware and amazon-dash will use more cpu if you have a lot of traffic in your network.

I can not improve CPU consumption any more without more help.

majuss commented 5 years ago

Couldn't we write the sniffer in C++ and reduce the CPU drain dramatically? For example with this lib: http://libtins.github.io/ if its possible I may invest some time.