-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
bitcoin-qt -noconnect uses 100% CPU #1664
Comments
I don't think -noconnect was ever supported as a valid option. |
As Luke says, that wasn't an intended option as far as I know. But it sounds like a reasonable thing to support, though we should probably also audit the other cases were a no wasn't really anticipated. |
This also appears to happen when it simply has no nodes to connect to, even without -noconnect. In my case I have a testnet node that has no addresses to connect to, so it keeps cycling through them and the "bitcoin-opencon" thread takes a lot of CPU time. In my case, it keeps selecting the same peer every half a second (with a nonstandard port #, so after 50 tries), trying to connect to it:
Not yet sure why that takes so much CPU usage %, though, as the thread sleeps mostly. Edit: According to callgrind, most time is spent inside CAddrMan::Select(int), calling CAddrMan::Select_(int), calling GetRandInt(int). Is that random function so expensive? I think so, after changing to simply use rand(), putting at the top of addrman.cpp a hack
The CPU usage dropped back to 4% only. Still significant, but not close to holding up a core. Using rand might be good enough here, as there is no need for cryptographically secure number here. See also issue #1057. Anyway, using something like exponential backoff in the connection thread is probably the real fix. Just wanted to know why peer selection was so expensive. |
Is this fixed in 0.7.0? |
It doesn't use 100% CPU, but it doesn't work either - it still tries to connect:
|
I see Pieter's commit fixing the 100% CPU bug in the 0.7.0 code:
but nothing implementing "-noconnect" (which apparently was never intended to work anyway). |
Since -connect=X means "connect only to X", -noconnect would mean "don't just connect to one peer", which is exactly what it does :) Ok, I admit, it wasn't ever considered. |
|
I've used "-connect=127.0.0.1" in the past to get no connections. I'm wondering whether "-maxconnections=0" would work too:
The GUI says "0 active connections" but the log (above) appears to show some communication with peers, so I'm a bit confused about what's going on there. |
In particular, my client somehow received notification of a payment to one of my addresses (not a payment to self) while I was running with "-maxconnections=0". How can that happen?
When I try sending a payment it doesn't send, as expected:
but for some reason I was able to receive a payment. |
The CPU issue was solved, and |
Maybe I'm doing it wrong, but if I specify "-noconnect" in an attempt to have bitcoin-qt not connect to any peers, the ThreadOpenConnections2() function goes into a tight loop that runs forever.
The following 1-line change fixes the problem:
The text was updated successfully, but these errors were encountered: