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

What is the point of "High CPU usage" message? #125

Closed
am11y opened this issue Oct 20, 2020 · 3 comments
Closed

What is the point of "High CPU usage" message? #125

am11y opened this issue Oct 20, 2020 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@am11y
Copy link

am11y commented Oct 20, 2020

I get it constantly on many different systems, and none of those are very old.

Plus nowhere on those systems do I really see high CPU usage reported from the system.

It just spams my standard output and really gets on my nerves. I have to delete it manually with each update.

Could you perhaps consider removing it?

Thanks.

@am11y am11y added the question Further information is requested label Oct 20, 2020
@oliver-zehentleitner
Copy link
Member

oliver-zehentleitner commented Oct 20, 2020

Hi am11y!

The point is, that each stream is running within its own thread. Even if that threads are working on different CPU cores, unfortunately Pythons GIL only executes one thread after the next in a cycle, not really parallel.

For example if you have 3 CPU cores you have 3 x 100% CPU power. But all threads of one python application can finally consume only 1 x 100% CPU. Even if the other 200% are free, the Python app cant use it!

It might depend of the subscriptions you have, but in my tests in peak times the transmitted data from binance is x 3 of the average traffik:
print_summary

So if you have in average 100% CPU usage the received items cant get processed as fast as they come in - the backlog is growing and if the backlog gets too big, the streams disconnects with error 1006. Sure it reconnects afterward, but you are also losing data more often than it would be necessary.

This is not easy to detect for most people, like you said, your system is not under full load, but your script can not acquire more!

In the future I want to replace threads with independent processes, they dont have the GIL restrictions.

This logging is new and I will try to find the right balance to avoid spamming the logs. In the next release it will be much less log entries through #124

If you have a lot of this entries, i bet you have also a lot of avoidable reconnects...

@am11y
Copy link
Author

am11y commented Oct 20, 2020

Thanks for explanation!

@oliver-zehentleitner
Copy link
Member

Your welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants