You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, select() is limited to 64 sockets by default. As a result, Bitcoin can communicate with no more than 63 peers. (Not 64, because the listening socket is also passed to select().) The default value of maxconnections=125 can never be reached.
Since listening nodes are important to the network, this may be worth fixing. All it takes is "#define FD_SETSIZE 1024" (or some other number greater than 64) before "#include <winsock2.h>" in compat.h. I tried it locally and now have over 100 connections.
@luke-jr With 1000 file descriptors, that effectively means O(1M) operations to construct these sets, which seems ridiculous. Is there any reason not to switch to using poll()?
At least the performance penalty only occurs when the larger number of descriptors is actually used. If maxconnections=125, there are at most 125^2 = 15-16k operations, even if FD_SETSIZE is 1024.
@jeremysawicki Sure, it's no argument against this pull request - it's a strict improvement. Nonetheless, it's something we should look at. It seems Windows only has a poll()-like call as of Vista though, and currently we try to be compatible with XP...
@sipa Windows doesn't have poll(). Vista and newer (only) do have a WSAPoll which was supposed to emulate poll(), but has some weird bugs that someone would need to look more into if it were used..
Activity
luke-jr commentedon Mar 24, 2013
Agreed.
Side note: Windows has stupidly inefficient FD_SET and FD_ISSET macros that iterate over an array to find the end
sipa commentedon Apr 25, 2013
I turned this into a pull request: #2569
sipa commentedon Apr 25, 2013
@luke-jr With 1000 file descriptors, that effectively means O(1M) operations to construct these sets, which seems ridiculous. Is there any reason not to switch to using poll()?
jeremysawicki commentedon Apr 25, 2013
At least the performance penalty only occurs when the larger number of descriptors is actually used. If maxconnections=125, there are at most 125^2 = 15-16k operations, even if FD_SETSIZE is 1024.
sipa commentedon Apr 25, 2013
@jeremysawicki Sure, it's no argument against this pull request - it's a strict improvement. Nonetheless, it's something we should look at. It seems Windows only has a poll()-like call as of Vista though, and currently we try to be compatible with XP...
luke-jr commentedon Apr 25, 2013
@sipa Windows doesn't have poll(). Vista and newer (only) do have a WSAPoll which was supposed to emulate poll(), but has some weird bugs that someone would need to look more into if it were used..
sipa commentedon Apr 29, 2013
Solved in #2569