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

idf_monitor.py huge CPU load (IDFGH-1634) #3884

Closed
no1seman opened this issue Aug 6, 2019 · 13 comments
Closed

idf_monitor.py huge CPU load (IDFGH-1634) #3884

no1seman opened this issue Aug 6, 2019 · 13 comments

Comments

@no1seman
Copy link

no1seman commented Aug 6, 2019

Environment

  • Development Kit: ESP32-Wrover-Kit
  • Kit version (for WroverKit/PicoKit/DevKitC): v4.1
  • Module or chip used: ESP32-WROVER-B
  • IDF version: v4.0-dev-1441-g6517c5033
  • Build System: CMake
  • Compiler version: xtensa-esp32-elf-gcc (crosstool-NG esp32-2019r1) 8.2.0
  • Operating System: Linux
  • Power Supply: USB|external 5V&Battery

Problem Description

After last esp-idf repo updates idf_monitor.py began to 100% load of one CPU core under linux (uname -a: Linux ubuntudev 4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux, ubuntu 18.04)

Expected Behavior

idf_monitor.py should not use so much CPU resources

Actual Behavior

Near 100% CPU load

Steps to repropduce

Code to reproduce this issue

Debug Logs

user@ubuntudev:~$ ps -aux | grep python
root       963  0.0  0.2 177688 17740 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root      1416  0.0  0.2 194396 20448 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
user      8308 **99.1**  0.1 498104 14528 pts/0    Rl+  15:01  15:20 python /home/user/esp/esp-mdf/esp-idf/tools/idf_monitor.py --port /dev/ttyUSB0 --baud 115200 ./build/beacon.elf
user      8598  0.0  0.0  21536  1044 pts/1    S+   15:16   0:00 grep --color=auto python
user@ubuntudev:~$ ps -aux | grep python
root       963  0.0  0.2 177688 17740 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root      1416  0.0  0.2 194396 20448 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
user      8308 **99.1**  0.1 498104 14528 pts/0    Rl+  15:01  15:23 python /home/user/esp/esp-mdf/esp-idf/tools/idf_monitor.py --port /dev/ttyUSB0 --baud 115200 ./build/beacon.elf
user      8600  0.0  0.0  21536  1044 pts/1    R+   15:16   0:00 grep --color=auto python
user@ubuntudev:~$ ps -aux | grep python
root       963  0.0  0.2 177688 17740 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root      1416  0.0  0.2 194396 20448 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
user      8308 **99.1**  0.1 498104 14528 pts/0    Rl+  15:01  15:24 python /home/user/esp/esp-mdf/esp-idf/tools/idf_monitor.py --port /dev/ttyUSB0 --baud 115200 ./build/beacon.elf
user      8602  0.0  0.0  21536  1040 pts/1    S+   15:16   0:00 grep --color=auto python
user@ubuntudev:~$ ps -aux | grep python
root       963  0.0  0.2 177688 17740 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root      1416  0.0  0.2 194396 20448 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
user      8308 **99.2**  0.1 498104 14528 pts/0    Rl+  15:01  15:25 python /home/user/esp/esp-mdf/esp-idf/tools/idf_monitor.py --port /dev/ttyUSB0 --baud 115200 ./build/beacon.elf
user      8604  0.0  0.0  21536  1008 pts/1    S+   15:16   0:00 grep --color=auto python
user@ubuntudev:~$ ps -aux | grep python
root       963  0.0  0.2 177688 17740 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root      1416  0.0  0.2 194396 20448 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
user      8308 **99.2**  0.1 498104 14528 pts/0    Rl+  15:01  15:26 python /home/user/esp/esp-mdf/esp-idf/tools/idf_monitor.py --port /dev/ttyUSB0 --baud 115200 ./build/beacon.elf
user      8606  0.0  0.0  21536  1088 pts/1    R+   15:16   0:00 grep --color=auto python
user@ubuntudev:~$ ps -aux | grep python
root       963  0.0  0.2 177688 17740 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root      1416  0.0  0.2 194396 20448 ?        Ssl  aug05   0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
user      8308 **99.1**  0.1 498104 14528 pts/0    Rl+  15:01  15:27 python /home/user/esp/esp-mdf/esp-idf/tools/idf_monitor.py --port /dev/ttyUSB0 --baud 115200 ./build/beacon.elf
user      8608  0.0  0.0  21536  1000 pts/1    S+   15:16   0:00 grep --color=auto python
@github-actions github-actions bot changed the title idf_monitor.py huge CPU load idf_monitor.py huge CPU load (IDFGH-1634) Aug 6, 2019
@negativekelvin
Copy link
Contributor

ac5508e

@pglen
Copy link

pglen commented Aug 14, 2019

I have the same issue on Linux Ubuntu. Appeared after update to IDF 4

System:

Linux ubuvb 5.0.0-25-generic #26-Ubuntu SMP Thu Aug 1 12:04:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

IDF:
I (525) cpu_start: ESP-IDF: v4.0-dev-1443-g39f090a4f

@ginkgm
Copy link
Collaborator

ginkgm commented Aug 15, 2019

@no1seman @negativekelvin @pglen

Sorry about this. It's due to the delay time too short here: https://github.com/espressif/esp-idf/blob/master/tools/idf_monitor.py#L493

Is there anyone can help me to test which value is proper on your OS? (Too large will cause the screen print delay/keyboarad respond delay, too small will use too much CPU resource) The unit is in second.

@no1seman
Copy link
Author

no1seman commented Aug 15, 2019

@ginkgm,
thank you for watching on the issue.
seems changing delay in: 'item = self.event_queue.get(False, 0.001)' to 'item = self.event_queue.get(False, 1.0)' doesn't help much:
image

PS I'm using ubuntu 18.04.3 LTS with latest core: 5.0.0-25-generic (5.0.0-25.82) as a virtualbox guest on windows 10 with 4 virtual CPUs and 8 Gb virtual RAM. Hardware: i7-8550U with 16 Gb RAM.

@negativekelvin
Copy link
Contributor

It should be item = self.event_queue.get(True, 0.001)

@no1seman
Copy link
Author

with item = self.event_queue.get(True, 0.01) logs printing looks good with #define SOCKETS_DEBUG LWIP_DBG_ON and intensive network operations: 4-5% CPU core load.

@pglen
Copy link

pglen commented Aug 15, 2019 via email

@dobairoland
Copy link
Collaborator

@pglen We usually don't put names into comments but you can open a Pull request for this and then your contribution will be logged in the form of a commit (including your name and email address).

@pglen
Copy link

pglen commented Aug 15, 2019 via email

@negativekelvin
Copy link
Contributor

@pglen there are two different queues so you don't want to remove the "second get". It is trying to block but uses the incorrect False parameter so the correct fix is changing it to True as shown above. Blocking is better than forcing a delay with sleep.

@pglen
Copy link

pglen commented Aug 15, 2019 via email

@pglen
Copy link

pglen commented Aug 15, 2019 via email

@ginkgm
Copy link
Collaborator

ginkgm commented Aug 16, 2019

@pglen it's under internal review now, I think you can see it soon~

Thanks for all your contribution

@igrr igrr closed this as completed in 24f9161 Aug 21, 2019
espressif-bot pushed a commit to espressif/esp-idf-monitor that referenced this issue Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants