JuicyPasta / Claymore-No-Fee-Proxy

Removes Claymore's 1-2% mining fee
138 stars 67 forks source link

High CPU Usage, why no blocking mode? #37

Open JsBergbau opened 6 years ago

JsBergbau commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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