Add RPC call setscriptthreadsenabled: allow to temp. throttle CPU usage #12965

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2018/04/svt changing 4 files +54 −1
  1. jonasschnelli commented at 8:46 am on April 12, 2018: contributor

    Bitcoin Core has been designed to synchronise/verify as fast as possible. This is usually desirable, though, on systems where other applications require a reasonable amount of CPU time (ex. desktop systems) the CPU usage maximisation of Bitcoin Core may be intrusive.

    This PR adds two RPC calls:

    • setscriptthreadsenabled allows to disable/re-enable the script verification threads during runtime.
    • scriptthreadsinfo show information about the script verification threads (enabled/disabled and num threads)

    This would be a base requirement for a “cpu throttle” feature in the GUI allowing one to temporary “throttle” verification (and therefore make the system usable for other tasks while syncing in the background)

    The concept-draft for long-term resource profile: https://gist.github.com/jonasschnelli/a3eb47147069b99d7c63d7da997b4225

    ToDo:

    • Add tests
    • Release notes
  2. jonasschnelli added the label RPC/REST/ZMQ on Apr 12, 2018
  3. jonasschnelli added the label Validation on Apr 12, 2018
  4. in src/rpc/blockchain.cpp:1656 in 13814ae538 outdated
    1651+
    1652+UniValue setscriptthreadsenabled(const JSONRPCRequest& request)
    1653+{
    1654+    if (request.fHelp || request.params.size() != 1) {
    1655+        throw std::runtime_error(
    1656+            "setscriptthreadsenabled\n"
    


    promag commented at 9:01 am on April 12, 2018:
    Missing parameter state.
  5. in src/rpc/blockchain.cpp:1657 in 13814ae538 outdated
    1652+UniValue setscriptthreadsenabled(const JSONRPCRequest& request)
    1653+{
    1654+    if (request.fHelp || request.params.size() != 1) {
    1655+        throw std::runtime_error(
    1656+            "setscriptthreadsenabled\n"
    1657+            "\nDisable/enable script verification threads and therefore reducing CPU usage on multicore systems.\n"
    


    promag commented at 9:01 am on April 12, 2018:
    Invert, Enable/disable script ...?
  6. in src/rpc/blockchain.cpp:1659 in 13814ae538 outdated
    1654+    if (request.fHelp || request.params.size() != 1) {
    1655+        throw std::runtime_error(
    1656+            "setscriptthreadsenabled\n"
    1657+            "\nDisable/enable script verification threads and therefore reducing CPU usage on multicore systems.\n"
    1658+            "Disabling script verification threads may result in a significant slow-down during synchronisation.\n"
    1659+            "Has no effect on single core machines or if started with -par=<-<numcores>\n"
    


    promag commented at 9:04 am on April 12, 2018:
    Should be if started with -par=1?
  7. promag commented at 9:05 am on April 12, 2018: member

    Concept ACK.

    I think this is almost only useful when changed in the UI right?

    Could have a couple of tests to exercise these new calls and the error.

    Edit: you already have tests in the TODO 😄

  8. JeremyRubin commented at 6:59 am on April 13, 2018: contributor

    Couple comments on the concept:

    • Maybe add a time argument (e.g., disable for 5 hours)
    • Maybe add code to differentiate between sync and receiving a new block. I can see why you might want to background sync, but when you are getting a new block, the pause won’t be that long and it is really good for the network if this is faster
    • Perhaps also good to control how many threads get used? E.g., use 2 threads out of 4
    • Why is this better than just restarting the node with fewer threads?
  9. jonasschnelli commented at 8:53 am on April 13, 2018: contributor

    @promag

    I think this is almost only useful when changed in the UI right?

    I think its useful for bitcoind users as well. Assume you want to do another CPU intense task on your system, you could setscriptthreadsenabled false, do your task and setscriptthreadsenabled true. @JeremyRubin Agree with all your features… I guess they could be implemented in another PR.

    Why is this better than just restarting the node with fewer threads?

    Restarting Bitcoin-Core just to reduce it’s script verification threads seems unideal. A restart is always painful (dbcache, partial re-validation).

  10. Add RPC call setscriptthreadsenabled/scriptthreadsinfo: allow to disable verification threads dfab6c6866
  11. jonasschnelli force-pushed on Apr 18, 2018
  12. jonasschnelli commented at 8:19 am on April 18, 2018: contributor
    Needed rebase
  13. MarcoFalke added the label Needs rebase on Jun 6, 2018
  14. DrahtBot commented at 5:20 pm on September 21, 2018: member
  15. DrahtBot added the label Up for grabs on Sep 21, 2018
  16. DrahtBot closed this on Sep 21, 2018

  17. laanwj removed the label Needs rebase on Oct 24, 2019
  18. DrahtBot locked this on Dec 16, 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-12-21 15:12 UTC

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