remove useless millisleep #4790

pull pstratem wants to merge 1 commits into bitcoin:master from pstratem:remove_net_millisleep changing 1 files +0 −2
  1. pstratem commented at 1:21 AM on August 30, 2014: contributor

    reduces time to service requests improving performance

    calls is unnecessary as select() blocks and on select() failure there is another MilliSleep()

  2. theuni commented at 2:07 AM on August 30, 2014: member

    This looks like a typical fail-safe for avoiding pegging the cpu in a tight loop. Are you sure there are no cases where the the thread ends up looping without a stall? There are plenty of cases where a select can return immediately without error.

  3. pstratem commented at 2:29 AM on August 30, 2014: contributor

    @theuni This handles all cases.

    timeout - essentially MilliSleep(50) error - MilliSleep(50) fd's ready - we dont want to sleep!

  4. sipa commented at 11:15 AM on August 30, 2014: member

    Untested ACK

  5. theuni commented at 8:44 PM on August 30, 2014: member

    @pstratem No problem. I didn't mean to imply that it really is needed, only that it may have a non-obvious use.

  6. pstratem commented at 6:29 PM on September 2, 2014: contributor

    @theuni I didn't take offense, sanity checking even the most trivial looking changes makes perfect sense.

  7. gmaxwell commented at 2:41 AM on September 3, 2014: contributor

    For those following at home. There are currently two sleeps in the network handling code— one in the thread with the select. One in the threadmessagehandler. The latter is necessary (or at least must be replaced with a semaphor) to prevent a busy loop. This one is not— it should be superfluous to the select, except— perhaps— if there are no connections.

    (Posix select is defined to sleep when empty, but someone might want to double check on windows.)

  8. pstratem commented at 2:45 AM on September 3, 2014: contributor

    should behave correctly with no connections, select() should sleep for the timeout period (select manpage specifically references calling select like this to get a high precision sleep function).

  9. pstratem commented at 2:46 AM on September 3, 2014: contributor

    tested on debian 7.6, ./bitcoind -connect=10.1.1.1 does not result in a busy loop

  10. jgarzik commented at 2:49 AM on September 3, 2014: contributor

    Yah, that's fine on *nix. Windows is the key platform to test, for select() behavior. it is already quite odd on windows, only working for some types of handles (sockets). No-socket behavior is precisely the area windows would be annoying ;p

  11. pstratem commented at 2:55 AM on September 3, 2014: contributor

    @jgarzik yes windows immediately returns WSAEINVAL if the three sets are empty

    This triggers the MilliSleep in the error handler

    There is only an issue if select returns a value other than -1 without blocking.

    That doesn't appear to happen on any platform.

  12. gmaxwell commented at 2:57 AM on September 3, 2014: contributor

    Okay, seems (according to the interwebs) that— indeed— windows returns an error instead of sleeping in the no socket case. But we already have a sleep in the error handling path.

    I've tested this on Linux with and without connections. ACK on the change— But I'd like to hear that this was tested with and without any connections (e.g. -connect=0.0.0.0, and check if Bitcoin is pegging the cpu) on Windows and Mac.

  13. remove useless millisleep
    reduces time to service requests improving performance
    9189f5fe4d
  14. BitcoinPullTester commented at 4:44 AM on September 3, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4790_9189f5fe4df1ac7ea6ca75ceada867beafda90a9/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  15. laanwj commented at 10:34 AM on September 3, 2014: member

    Never knew that -connect=0.0.0.0 could be used to not connect to any nodes. Having a way to not connect was one of my reasons for being in favor of #4687.

  16. gavinandresen commented at 1:15 PM on September 3, 2014: contributor

    ACK, tested on OSX with -connect=0.0.0.0

  17. gmaxwell commented at 8:46 PM on September 3, 2014: contributor

    @pstratem Can you get this crazy merge commit out of here? (just rewrite against master and force push) this could be fixed on merge too but it might safe someone a few minutes to fix it yourself.

  18. pstratem commented at 8:48 PM on September 3, 2014: contributor

    @gmaxwell i did... last night..?

  19. gmaxwell commented at 12:35 AM on September 4, 2014: contributor

    @pstratem Weird, github must have been displaying stale data for me.

  20. pstratem commented at 12:36 AM on September 4, 2014: contributor

    @gmaxwell I've found their caching to be consistently overly aggressive.

  21. laanwj merged this on Sep 4, 2014
  22. laanwj closed this on Sep 4, 2014

  23. laanwj referenced this in commit f2cc1ee439 on Sep 4, 2014
  24. wtogami referenced this in commit 6c82583a8d on Sep 9, 2014
  25. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me