refactor: remove boost::thread_group usage #21016

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:remove_boost_threadgroup changing 12 files +44 −39
  1. fanquake commented at 7:16 am on January 27, 2021: member

    Post #18710, there isn’t much left using boost::thread_group, so should just be able to replace it with the standard library. This also removes the last use of boost::thread_interrupted.

    After this change, last piece of Boost Thread we’d be using is boost::shared_mutex. See the commentary here as to why it may be non-trivial to swap that for std::shared_mutex in the near future.

    Closes #17307

  2. fanquake added the label Refactoring on Jan 27, 2021
  3. in src/init.cpp:159 in 11cff38719 outdated
    155@@ -155,7 +156,7 @@ static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
    156 
    157 static std::thread g_load_block;
    158 
    159-static boost::thread_group threadGroup;
    160+static std::thread g_scheduler;
    


    MarcoFalke commented at 7:24 am on January 27, 2021:
    It doesn’t really make sense to run the scheduler without a thread, so I’d prefer to move this into the scheduler (like was done in #18710)

    fanquake commented at 7:45 am on January 29, 2021:
    Made some changes that should address this.
  4. DrahtBot commented at 7:55 am on January 27, 2021: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #21030 (refactor: move load block thread into ChainstateManager by fanquake)
    • #19064 (refactor: Cleanup thread ctor calls by hebasto)
    • #18722 (addrman: improve performance by using more suitable containers by vasild)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. MarcoFalke added the label Waiting for author on Jan 27, 2021
  6. fanquake force-pushed on Jan 27, 2021
  7. hebasto commented at 10:57 am on January 27, 2021: member

    This also removes the last use of boost::thread_interrupted.

    Concept ACK on it.

  8. fanquake force-pushed on Jan 27, 2021
  9. laanwj commented at 2:00 pm on January 27, 2021: member

    This also removes the last use of boost::thread_interrupted.

    Concept ACK thank youuu

  10. in src/init.cpp:1345 in 58b54e1fc2 outdated
    1341@@ -1342,7 +1342,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
    1342     node.scheduler = MakeUnique<CScheduler>();
    1343 
    1344     // Start the lightweight task scheduler thread
    1345-    threadGroup.create_thread([&] { TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); });
    1346+    g_scheduler = std::thread(&TraceThread<std::function<void()>>, "scheduler", [&] { node.scheduler->serviceQueue(); });
    


    jonatack commented at 2:38 pm on January 27, 2021:

    I’m probably missing some context so feel free to ignore: can this continue to use a lambda rather than std::function for possibly less compile time / run time overhead? This compiles and the tests pass for me locally.

    0-    g_scheduler = std::thread(&TraceThread<std::function<void()>>, "scheduler", [&] { node.scheduler->serviceQueue(); });
    1+    g_scheduler = std::thread([&] { TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); });
    

    hebasto commented at 2:58 pm on January 27, 2021:

    fanquake commented at 7:44 am on January 29, 2021:
    This change is now included.
  11. jonatack commented at 2:46 pm on January 27, 2021: member
    Concept ACK, nice. Debug build is clean.
  12. fanquake force-pushed on Jan 29, 2021
  13. fanquake commented at 7:05 am on January 29, 2021: member
    I’ve pushed some changes. One thing worth nothing here is that even though the CScheduler is sort of written / documented as if it will have multiple threads running serviceQueue(), the only place we actually do that is in the scheduler tests.
  14. fanquake referenced this in commit f538c25cd4 on Jan 29, 2021
  15. in src/scheduler.h:39 in 4b45d7857c outdated
    35@@ -35,6 +36,8 @@ class CScheduler
    36     CScheduler();
    37     ~CScheduler();
    38 
    39+    std::thread m_service_queue;
    


    laanwj commented at 7:34 am on January 29, 2021:
    I think m_service_queue is a bit of a weird name for a data structure that’s not a queue. m_service_thread maybe?

    fanquake commented at 7:44 am on January 29, 2021:
    Yea. I’ve changed this to m_service_thread.
  16. laanwj commented at 7:39 am on January 29, 2021: member

    This is a straightforward change. Code review ACK 4b45d7857c06c908d001d6b792fb85066f9ea60f

    Code review re-ACK dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f

  17. refactor: remove boost::thread_group usage dc8be12510
  18. fanquake force-pushed on Jan 29, 2021
  19. fanquake removed the label Waiting for author on Jan 29, 2021
  20. MarcoFalke commented at 11:05 am on January 29, 2021: member

    review ACK dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f 🔁

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3review ACK dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f 🔁
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUjKMQv6A8rVfG8beOl8DAx4YpJxPMaqL2eEohWtkv4k+F05ZO+qDK/XdyawBQXA
     8CntP5MQ1zS4/C1kBYE1WIrtgGFzeRzcPOT++Ig6qvLkAgtvQfEayIcpb02GTXDHw
     9ZcjZrUryf8rj2cxql07QmNnn4X8f41gG2GZ5DsxJsTIYPpluiXuirEBLXLprr+DS
    100Bp9eeOG8P/AssBd6oaTdhSWSPivmPk/CSqOqae+X9vPX4VA3g07qyq06QuMYxEw
    11D5td8Wf/mOtERTLk0PgqqTrhl0IhtcMmk156BYL58BcJtkDuo306TC7SBs8fVAkD
    12+lgfnvlXWyR/QZJ4EoqIFCff1Sz1XSzFQnsGkx57U1vvgGA+Q3WVC2kuwQT8ldmQ
    13mE+QiWUeKybZQQianBsmbbLi0G2uwIPaeK9dDKA3czCyZGdvjVg8OqbQOVqyQK+8
    14jXV9WTtktmV5CWjQuiPU1TM+215xbDU/JoUheDE5EHPhtki5XUUrLYWwlwYODxsT
    1573771cxI
    16=mxeP
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash d4a9b161264d0b7adbc481cbca5ceed62333c7b8ce658c5ce2fbf697aa94a943 -

  21. jonatack commented at 11:39 am on January 29, 2021: member
    Non-expert code review ACK dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f, also checked range-diff since last review and that local debug build is clean with gcc 10.2.1-6 on Debian
  22. MarcoFalke commented at 9:22 am on January 30, 2021: member
    (edited OP to say “Closes #17307”)
  23. laanwj merged this on Feb 1, 2021
  24. laanwj closed this on Feb 1, 2021

  25. fanquake referenced this in commit be7065623a on Feb 2, 2021
  26. sidhujag referenced this in commit d9e8d25994 on Feb 2, 2021
  27. fanquake referenced this in commit e3341dfaf7 on Feb 2, 2021
  28. fanquake deleted the branch on Feb 2, 2021
  29. MarcoFalke referenced this in commit 63984b38f0 on Apr 2, 2021
  30. fanquake referenced this in commit aa72ffb1c2 on Jul 12, 2021
  31. MarcoFalke referenced this in commit 7e1ba37b5d on Jul 12, 2021
  32. sidhujag referenced this in commit a5e2e68cf8 on Jul 14, 2021
  33. josibake referenced this in commit d052342899 on Jul 21, 2021
  34. Fabcien referenced this in commit 1121f6f391 on Feb 4, 2022
  35. Fabcien referenced this in commit 5d1d773738 on Feb 4, 2022
  36. DrahtBot locked this on Aug 16, 2022

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-29 00:12 UTC

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