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, why no blocking mode? #37

Open
JsBergbau opened this issue Mar 3, 2018 · 2 comments
Open

High CPU Usage, why no blocking mode? #37

JsBergbau opened this issue Mar 3, 2018 · 2 comments

Comments

@JsBergbau
Copy link

Hi JuicyPasta,

thanks for your mining proxy to stop greedy Claymore from getting too much money.

In your code you set

def receive_from(connection):

    buffer = ""

    # We set a 2 second time out depending on your
    # target this may need to be adjusted
connection.settimeout(0)

What background has setting "connection.settimeout(0)" ?
https://docs.python.org/2/library/socket.html

socket.settimeout(value)¶

Set a timeout on blocking socket operations. The value argument can be a nonnegative float expressing seconds, or None. If a float is given, subsequent socket operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. Setting a timeout of None disables timeouts on socket operations. s.settimeout(0.0) is equivalent to s.setblocking(0); s.settimeout(None) is equivalent to s.setblocking(1).

New in version 2.3.

If you don't set this the call is in so called blocking mode, means it returns only when there is new data. So CPU is used as little as possible.

When using this you could avaoid time.sleep(0.001) in 170
btw. I've changed to time.sleep(0.01) and now have reduced CPU usage a lot.

So do you have a special reason for the command in non blocking mode? Normally when programming network functions I work in blocking modes. Thus programs need a little CPU as possible.

@eLvErDe
Copy link

eLvErDe commented Apr 23, 2018

Hello guys,

I made a different version based on asyncio, which is even more lightweight.
You can check the code on my GitHub, it's currently targetting equihash but might be generic enough to work on ethash as well.

@r-a-n-d-o-m-u-s-e-r-n-a-m-e

Hi eLvErDe,
can you do anything with #36 this problem?

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

3 participants