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

High CPU usage in idle state on Intel Mac when using Python3.8 #1298

Open
yanxurui opened this issue Nov 27, 2022 · 5 comments
Open

High CPU usage in idle state on Intel Mac when using Python3.8 #1298

yanxurui opened this issue Nov 27, 2022 · 5 comments
Assignees
Labels
Bug Bug report in proxy server

Comments

@yanxurui
Copy link

Check FAQs
Checked.

Describe the bug
I started the proxy from command line in my mac and noticed the CPU usage of the acceptor is very high even though there is zero load. Seems there is a while loop running inside the process?

To Reproduce
Steps to reproduce the behavior:

  1. clone the repo
  2. install depedencies
  3. checkout to v2.4.3
  4. python -m proxy --num-acceptors 1 --hostname 0.0.0.0 --log-level d
develop ✔ $ python -m proxy --num-acceptors 1 --hostname 0.0.0.0 --log-level d
2022-11-27 14:17:20,414 - pid:28662 [D] utils.set_open_file_limit:320 - Open file soft limit set to 1024
2022-11-27 14:17:20,415 - pid:28662 [I] plugins.load:85 - Loaded plugin proxy.http.proxy.HttpProxyPlugin
2022-11-27 14:17:20,416 - pid:28662 [I] tcp.listen:80 - Listening on 0.0.0.0:8899
2022-11-27 14:17:20,421 - pid:28662 [D] pool._start:148 - Started acceptor#0 process 28680
2022-11-27 14:17:20,423 - pid:28662 [I] pool.setup:105 - Started 1 acceptors in threadless (local) mode
2022-11-27 14:17:20,673 - pid:28680 [D] selector_events.__init__:59 - Using selector: KqueueSelector
2022-11-27 14:17:20,674 - pid:28680 [D] threadless.run:412 - Working on 0 works

Expected behavior
I expect the CPU usage of the proxy process to be very low when there is no load at all. However, the process is utilizing the entire core.

Version information

  • OS: Mac OS Monterey
  • Browser [e.g. chrome, safari]: N/A
  • Device: Mac
  • proxy.py Version: v2.4.3

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2022-11-27 at 14 18 30

@yanxurui yanxurui added the Bug Bug report in proxy server label Nov 27, 2022
@abhinavsingh
Copy link
Owner

Thanks for reporting. This is unusual. I'll look into it today.

@yanxurui
Copy link
Author

Thanks for the quick response. Without specifying num-acceptors, 4 acceptors will be launched and each of them are comsuming 70%~100% of a core, making the fan of my Mac work crasily. This can also be reproduced in the develop branch.

@abhinavsingh
Copy link
Owner

So I am using develop branch and used flags as you passed. I made a few requests through proxy.py and now I am using it for my entire MacOS system.

Below is a screenshot and video from the same duration

Screenshot 2022-11-27 at 5 21 17 PM

Screen.Recording.2022-11-27.at.5.23.12.PM.mov

I see with contact traffic through proxy.py, its consumption doesn't go over 5-7% which is expected.

  • I am wondering if this is related to Python 3.8.
  • I am also on a M2 chip machine. Are you experiencing this on an Intel machine?

I'll further try to also reproduce the scenario. If not, will ask you for more debugging information.

Stay with me :)

@yanxurui
Copy link
Author

Thanks. I am using an old mac
Screen Shot 2022-11-27 at 20 10 11

It looks good when I use Python 3.10.2

@abhinavsingh
Copy link
Owner

@yanxurui Awesome, thanks for confirming the same. I do have an older model in office :). I'll give a try on it tomorrow and share my findings.

@abhinavsingh abhinavsingh changed the title High CPU usage in idle state in mac High CPU usage in idle state on Intel Mac when using Python3.8 Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug report in proxy server
Projects
None yet
Development

No branches or pull requests

2 participants