Optimize -regtest setgenerate block generation #5275

pull gavinandresen wants to merge 1 commits into bitcoin:master from gavinandresen:regtest_fast_blockgen changing 1 files +22 −8
  1. gavinandresen commented at 8:11 pm on November 13, 2014: contributor

    Speed up generating blocks in regression test mode, by moving block-creating and nonce-finding directly into the setgenerate RPC call (instead of starting up a mining thread and waiting for it to find a block).

    This makes the forknotify RPC test three times quicker, for example (10 seconds runtime instead of 30 seconds, assuming the initial blockchain cache is already built).

  2. gavinandresen force-pushed on Nov 13, 2014
  3. gavinandresen force-pushed on Nov 13, 2014
  4. in src/rpcmining.cpp: in 1bba5f4ac4 outdated
    164@@ -161,19 +165,30 @@ Value setgenerate(const Array& params, bool fHelp)
    165             nHeightEnd = nHeightStart+nGenerate;
    166         }
    167         int nHeightLast = -1;
    


    laanwj commented at 2:40 pm on November 14, 2014:

    Unused:

    0rpcmining.cpp: In function json_spirit::Value setgenerate(const Array&, bool):
    1rpcmining.cpp:167:13: warning: unused variable nHeightLast [-Wunused-variable]
    2         int nHeightLast = -1;
    3             ^
    
  5. laanwj commented at 2:42 pm on November 14, 2014: member
    ACK, works for me
  6. sipa commented at 5:04 pm on November 14, 2014: member
    utACK, though I would prefer just moving that regtest-specific block to a separate RPC…
  7. laanwj commented at 5:46 pm on November 14, 2014: member
    @sipa Agree that would be cleaner, but there’s no reason to do it in this pull.
  8. sipa commented at 5:48 pm on November 14, 2014: member
    This is changing the RPC interface anyway (by adding a return value). Reverting that later is imho not cleaner :) (but I’m still fine with merging it)
  9. Optimize -regtest setgenerate block generation
    Speed up generating blocks in regression test mode, by moving
    block-creating and nonce-finding directly into the setgenerate
    RPC call (instead of starting up a mining thread and waiting for
    it to find a block).
    
    This makes the forknotify RPC test three times quicker, for
    example (10 seconds runtime instead of 30 seconds, assuming
    the initial blockchain cache is already built).
    18379875bf
  10. gavinandresen force-pushed on Nov 14, 2014
  11. gavinandresen commented at 6:46 pm on November 14, 2014: contributor
    Fixed the unused variable nit, will merge as soon as Travis has a chance to do it’s thing. @sipa : a -regtest-only ‘generateblocks’ RPC that replaces the hacky setgenerate is a good idea. But not right now, please, I’m working on a couple of branches with tests that I want to get done and don’t want to spend time porting all the existing RPC tests away from setgenerate.
  12. sipa commented at 10:28 pm on November 14, 2014: member
    ACK
  13. gavinandresen merged this on Nov 17, 2014
  14. gavinandresen closed this on Nov 17, 2014

  15. gavinandresen referenced this in commit d6479ffc6a on Nov 17, 2014
  16. gavinandresen deleted the branch on Nov 17, 2014
  17. ghost commented at 5:00 am on November 28, 2014: none

    I am not opposed to optimizing regtest block generation. Heavy users of regtest, apparently Gavin included, might find a use case or two. After all, testing has been declared the bottleneck for development in general, so we need more of it, and I view this commit as a step in support of it.

    What seems out of place in the context of regtest here are error messages coming out of CheckProofOfWork, while the right nonce is searched for, misleadingly clogging the logs.

  18. laanwj commented at 8:36 am on November 28, 2014: member

    Heavy users of regtest, apparently Gavin included, might find a use case or two

    We’re all heavy users of regtest when waiting for Travis to finish. Optimizing here is indeed an overall win.

    The logical conclusion is that the miner optimization doesn’t make sense. Let’s remove it to simplify that part of the code. Less code to maintain and no drawbacks.

    That has been discussed before. Another feature that complicates the internal miner code, and doesn’t have much of a point for testing, is support for multiple threads. I’d not be opposed to removing those things. But anything related to the (non-regtest) internal miner has extremely low priority in my eyes. It works …

  19. jtimon commented at 9:56 pm on January 4, 2015: contributor
    I guess my point is that the only real use of the of the miner is in regtest mode. Therefore everything that is good for regtest mining is good mining in general as far as bitcoin core is concerned. As long as non-regtest mining keeps working, we don’t care about its performance. #4423 was rejected because the performance measured was hashrate in non-regtest mode, but the only mining performance measure that we should care about is regtest. To be clear, I’m not complaining about this change, it makes a lot of sense and it’s great that it’s merged. But I think we can make the if (Params().MineBlocksOnDemand()) part smaller and the whole mining code simpler if we’re willing to sacrifice non-regtest performance. There’s also another way to make regtest mining more similar to the others: by removing mining code that regtest doesn’t use like in #5599 (or @laanwj ’s proposal to remove multiple thread support for non-regtest mining). To reiterate and summarize: non-regtest mining performance is meaningless, and non-regtest mining code should be more like regtest mining (instead of the other way around).
  20. jtimon commented at 6:33 pm on January 24, 2015: contributor
    @21E14 #4793 should produce less “error messages coming out of CheckProofOfWork” and I also believe it should improve regtest mining performance a little bit, but as I say in that PR I haven’t tested.
  21. ghost commented at 6:37 am on January 26, 2015: none
    @jtimon Looks great!
  22. 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: 2024-09-29 07:12 UTC

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